Diff

Differences From Artifact [9250a4fcfd]:

To Artifact [4cb097f703]:


105
106
107
108
109
110
111







112
113
114
115
116
117


118
119
120
121

122
123
124
125
126
127
128
129
130



131



132
133

134
135
136
137
138
139
140
...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
if [ -d "pkgs/${pkg}" ]; then
	pkgdir="pkgs/${pkg}"
	pkgfile="${pkgdir}/info"
else
	pkgfile="pkgs/${pkg}"
	pkgdir="${pkgfile}"
fi







pkgdate="$(find "${pkgdir}" -type f -printf '%TY%Tm%Td%TH%TM.%TS\n' | cut -f 1-2 -d '.' | sort -n | tail -n 1)"

. "${pkgfile}"

archivedir="$(pwd)/ARCHIVE"
workdir="workdir-$$${RANDOM}${RANDOM}${RANDOM}"


mkdir "${workdir}" "${archivedir}"
cd "${workdir}" || exit 1
workdir="$(pwd)"


# Download
## Cleanup
rm -f src.new src

## Fetch file
wget -O src.new "${url}" || exit 1

## Verify signature
### XXX:TODO







## Move file into place
mv src.new src


# Decompress archive
## Determine type of archive
case "${url}" in
	*.tar.xz|*.tar.xz'?'*|*.txz)
		decompress='xz'
		;;
................................................................................
		exit 1
		;;
esac

## Do decompression
case "${decompress}" in
	unzip)
		unzip 'src' || die 'Unable to uncompress archive'
		;;
	*)
		"${decompress}" -dc src | tar -xf - || die 'Unable to uncompress archive'
		;;
esac

## Cleanup source
rm -f src

# If we just have one directory, use that directory







>
>
>
>
>
>
>
|





>
>
|



>
|
|
|

|
|

|
<
>
>
>

>
>
>
|
|
>







 







|


|







105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
...
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
if [ -d "pkgs/${pkg}" ]; then
	pkgdir="pkgs/${pkg}"
	pkgfile="${pkgdir}/info"
else
	pkgfile="pkgs/${pkg}"
	pkgdir="${pkgfile}"
fi

if [ ! -e "${pkgfile}" ]; then
	echo "Invalid package." >&2

	exit 1
fi

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)"

. "${pkgfile}"

archivedir="$(pwd)/ARCHIVE"
workdir="workdir-$$${RANDOM}${RANDOM}${RANDOM}"
srcfile="${archivedir}/${pkg}"
mkdir "${archivedir}" >/dev/null 2>/dev/null
mkdir "${workdir}" || exit 1
cd "${workdir}" || exit 1
workdir="$(pwd)"

if [ ! -e "${srcfile}" ]; then
	# Download
	## Cleanup
	rm -f src.new src

	## Fetch file
	wget -O src.new "${url}" || exit 1

	## Verify signature

	src_sha256="$(openssl sha256 'src.new' | sed 's@^.*= @@')"
	if [ "${src_sha256}" != "${sha256}" ]; then
		echo "SHA256 mismatch:  Downloaded: ${src_sha256} != Expected: ${sha256}" >&2

		exit 1
	fi

	## Move file into place
	mv src.new "${archivedir}/${pkg}"
fi

# Decompress archive
## Determine type of archive
case "${url}" in
	*.tar.xz|*.tar.xz'?'*|*.txz)
		decompress='xz'
		;;
................................................................................
		exit 1
		;;
esac

## Do decompression
case "${decompress}" in
	unzip)
		unzip "${srcfile}" || die 'Unable to uncompress archive'
		;;
	*)
		"${decompress}" -dc "${srcfile}" | tar -xf - || die 'Unable to uncompress archive'
		;;
esac

## Cleanup source
rm -f src

# If we just have one directory, use that directory