Diff

Differences From Artifact [9250a4fcfd]:

To Artifact [4cb097f703]:


   105    105   if [ -d "pkgs/${pkg}" ]; then
   106    106   	pkgdir="pkgs/${pkg}"
   107    107   	pkgfile="${pkgdir}/info"
   108    108   else
   109    109   	pkgfile="pkgs/${pkg}"
   110    110   	pkgdir="${pkgfile}"
   111    111   fi
   112         -pkgdate="$(find "${pkgdir}" -type f -printf '%TY%Tm%Td%TH%TM.%TS\n' | cut -f 1-2 -d '.' | sort -n | tail -n 1)"
          112  +
          113  +if [ ! -e "${pkgfile}" ]; then
          114  +	echo "Invalid package." >&2
          115  +
          116  +	exit 1
          117  +fi
          118  +
          119  +pkgdate="$(find "${pkgdir}" -type f -printf '%TY%Tm%Td%TH%TM.%TS\n' 2>/dev/null | cut -f 1-2 -d '.' | sort -n | tail -n 1)"
   113    120   
   114    121   . "${pkgfile}"
   115    122   
   116    123   archivedir="$(pwd)/ARCHIVE"
   117    124   workdir="workdir-$$${RANDOM}${RANDOM}${RANDOM}"
   118         -mkdir "${workdir}" "${archivedir}"
          125  +srcfile="${archivedir}/${pkg}"
          126  +mkdir "${archivedir}" >/dev/null 2>/dev/null
          127  +mkdir "${workdir}" || exit 1
   119    128   cd "${workdir}" || exit 1
   120    129   workdir="$(pwd)"
   121    130   
   122         -# Download
   123         -## Cleanup
   124         -rm -f src.new src
          131  +if [ ! -e "${srcfile}" ]; then
          132  +	# Download
          133  +	## Cleanup
          134  +	rm -f src.new src
   125    135   
   126         -## Fetch file
   127         -wget -O src.new "${url}" || exit 1
          136  +	## Fetch file
          137  +	wget -O src.new "${url}" || exit 1
   128    138   
   129         -## Verify signature
   130         -### XXX:TODO
          139  +	## Verify signature
          140  +	src_sha256="$(openssl sha256 'src.new' | sed 's@^.*= @@')"
          141  +	if [ "${src_sha256}" != "${sha256}" ]; then
          142  +		echo "SHA256 mismatch:  Downloaded: ${src_sha256} != Expected: ${sha256}" >&2
   131    143   
   132         -## Move file into place
   133         -mv src.new src
          144  +		exit 1
          145  +	fi
          146  +
          147  +	## Move file into place
          148  +	mv src.new "${archivedir}/${pkg}"
          149  +fi
   134    150   
   135    151   # Decompress archive
   136    152   ## Determine type of archive
   137    153   case "${url}" in
   138    154   	*.tar.xz|*.tar.xz'?'*|*.txz)
   139    155   		decompress='xz'
   140    156   		;;
................................................................................
   153    169   		exit 1
   154    170   		;;
   155    171   esac
   156    172   
   157    173   ## Do decompression
   158    174   case "${decompress}" in
   159    175   	unzip)
   160         -		unzip 'src' || die 'Unable to uncompress archive'
          176  +		unzip "${srcfile}" || die 'Unable to uncompress archive'
   161    177   		;;
   162    178   	*)
   163         -		"${decompress}" -dc src | tar -xf - || die 'Unable to uncompress archive'
          179  +		"${decompress}" -dc "${srcfile}" | tar -xf - || die 'Unable to uncompress archive'
   164    180   		;;
   165    181   esac
   166    182   
   167    183   ## Cleanup source
   168    184   rm -f src
   169    185   
   170    186   # If we just have one directory, use that directory