Skip to content

Commit ef13dfc

Browse files
authored
apt-cyg pull 93 Postinstall fixes
apt-cyg pull 93 Postinstall fixes transcode-open/apt-cyg#93
1 parent 59c6db1 commit ef13dfc

File tree

1 file changed

+61
-58
lines changed

1 file changed

+61
-58
lines changed

apt-cyg

Lines changed: 61 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -455,72 +455,75 @@ function apt-install {
455455
for pkg in "${pks[@]}"
456456
do
457457

458-
if grep -q "^$pkg " /etc/setup/installed.db
459-
then
460-
echo Package $pkg is already installed, skipping
461-
continue
462-
fi
463-
(( sbq++ )) && echo
464-
echo Installing $pkg
458+
# indent package loop code
459+
if grep -q "^$pkg " /etc/setup/installed.db
460+
then
461+
echo Package $pkg is already installed, skipping
462+
continue
463+
fi
464+
(( sbq++ )) && echo
465+
echo Installing $pkg
465466

466-
download $pkg
467-
read dn bn </tmp/dwn
468-
echo Unpacking...
467+
download $pkg
468+
read dn bn </tmp/dwn
469+
echo Unpacking...
469470

470-
cd "$cache/$mirrordir/$dn"
471-
tar -x -C / -f $bn
472-
# update the package database
471+
cd "$cache/$mirrordir/$dn"
472+
tar -x -C / -f $bn
473+
# update the package database
473474

474-
gawk '
475-
ins != 1 && pkg < $1 {
476-
print pkg, bz, 0
477-
ins = 1
478-
}
479-
1
480-
END {
481-
if (ins != 1) print pkg, bz, 0
482-
}
483-
' pkg="$pkg" bz=$bn /etc/setup/installed.db > /tmp/gawk.$$
484-
mv /etc/setup/installed.db /etc/setup/installed.db-save
485-
mv /tmp/gawk.$$ /etc/setup/installed.db
475+
awk '
476+
ins != 1 && pkg < $1 {
477+
print pkg, bz, 0
478+
ins = 1
479+
}
480+
1
481+
END {
482+
if (ins != 1) print pkg, bz, 0
483+
}
484+
' pkg="$pkg" bz=$bn /etc/setup/installed.db > /tmp/awk.$$
485+
mv /etc/setup/installed.db /etc/setup/installed.db-save
486+
mv /tmp/awk.$$ /etc/setup/installed.db
486487

487-
[ -v nodeps ] && continue
488-
# recursively install required packages
488+
[ -v nodeps ] && continue
489+
# recursively install required packages
489490

490-
requires=$(gawk '$1=="requires", $0=$2' FS=': ' desc)
491-
cd ~-
492-
wr=0
493-
if [[ $requires ]]
494-
then
495-
echo Package $pkg requires the following packages, installing:
496-
echo $requires
497-
for package in $requires
498-
do
499-
if grep -q "^$package " /etc/setup/installed.db
500-
then
501-
echo Package $package is already installed, skipping
502-
continue
503-
fi
504-
apt-cyg install --noscripts $package || (( wr++ ))
505-
done
506-
fi
507-
if (( wr ))
508-
then
509-
echo some required packages did not install, continuing
510-
fi
491+
requires=$(awk '$1=="requires", $0=$2' FS=': ' desc)
492+
cd ~-
493+
wr=0
494+
if [[ $requires ]]
495+
then
496+
echo Package $pkg requires the following packages, installing:
497+
echo $requires
498+
for package in $requires
499+
do
500+
if grep -q "^$package " /etc/setup/installed.db
501+
then
502+
echo Package $package is already installed, skipping
503+
continue
504+
fi
505+
apt-cyg install --noscripts $package || (( wr++ ))
506+
done
507+
fi
508+
if (( wr ))
509+
then
510+
echo some required packages did not install, continuing
511+
fi
511512

512-
# run all postinstall scripts
513+
echo Package $pkg installed
513514

514-
[ -v noscripts ] && continue
515-
find /etc/postinstall -name '*.sh' | while read script
516-
do
517-
echo Running $script
518-
$script
519-
mv $script $script.done
520-
done
521-
echo Package $pkg installed
515+
done
522516

523-
done
517+
# run all postinstall scripts after all packages installed
518+
if [ ! -v noscripts ]; then
519+
find /etc/postinstall -name '*.*sh' | while read script # allow dash scripts
520+
do
521+
echo Running $script
522+
$script
523+
# don't rename permanent first and last to run postinstall scripts
524+
[[ $script != /etc/postinstall/[0z]p_*.*sh ]] && mv $script $script.done
525+
done
526+
fi
524527
}
525528

526529
function apt-remove {

0 commit comments

Comments
 (0)