summaryrefslogtreecommitdiff
path: root/src/selfstrap
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2018-02-07 16:39:17 -0500
committerAndrew Cady <d@jerkface.net>2018-02-07 16:39:17 -0500
commit93216cddf60bafa359c4fb1b57017cb10bbde9ff (patch)
tree595c38af312ab26e1950397243c3767ad86be77e /src/selfstrap
parent6382a62f3d3d40a685f0f17a82c03af221fa782b (diff)
avoid cutesy tar --to-command; instead extract to tempdir
Diffstat (limited to 'src/selfstrap')
-rwxr-xr-xsrc/selfstrap29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/selfstrap b/src/selfstrap
index 265fa25..72fda34 100755
--- a/src/selfstrap
+++ b/src/selfstrap
@@ -226,25 +226,28 @@ dpkg_unpack()
226 PKG=${PKG%%_*} 226 PKG=${PKG%%_*}
227 PKG=$PKG$multiarch 227 PKG=$PKG$multiarch
228 228
229 # TODO: always set status=installed if there is no preinst or postinst script 229 extract_tmp_ci "$deb"
230 install_metadata_from_tmp_ci # uses TARGET PKG SET_STATUS
231 remove_tmp_ci
230 232
231 command=$(cat <<'EOF'
232set -e
233if [ "$SET_STATUS" -a "$TAR_FILENAME" = ./control ]; then
234 (sed "/^Package:/a Status: install ok $SET_STATUS"; echo) >> "$TARGET"/var/lib/dpkg/status
235else
236 f=$TARGET/var/lib/dpkg/info/$PKG.${TAR_FILENAME#./}
237 cat > "$f"
238 chmod $TAR_MODE "$f"
239fi
240EOF
241)
242 (export PKG TARGET SET_STATUS; dpkg --ctrl-tarfile "$deb" | tar -x --to-command "$command") || die 'tar'
243 dpkg --fsys-tarfile "$deb" | 233 dpkg --fsys-tarfile "$deb" |
244 (cd "$TARGET" && tar -xv) | 234 (cd "$TARGET" && tar -xv) |
245 sed 's?^\.??; s?^/$?/.?; s?/$??' > "$TARGET/var/lib/dpkg/info/$PKG.list" 235 sed 's?^\.??; s?^/$?/.?; s?/$??' > "$TARGET/var/lib/dpkg/info/$PKG.list"
246} 236}
247 237
238install_metadata_from_tmp_ci() # uses TARGET PKG SET_STATUS
239{
240 (cd "$TARGET"/var/lib/dpkg/tmp.ci || die "cannot cd to /var/lib/dpkg/tmp.ci"
241# PKG=$(sed -n 's/^Package: *//p' control)
242 for f in *; do
243 [ "$f" = postinst ] && SET_STATUS=${SET_STATUS:+installed} || true
244 [ "$f" = control ] || mv "$f" "$TARGET"/var/lib/dpkg/info/"$PKG"."$f"
245 done
246 if [ "$SET_STATUS" -a -e control ]; then
247 (sed "/^Package:/a Status: install ok $SET_STATUS"; echo) < control >> "$TARGET"/var/lib/dpkg/status
248 fi)
249}
250
248verbosely() 251verbosely()
249{ 252{
250 if [ "$VERBOSE" ]; then 253 if [ "$VERBOSE" ]; then