Skip to content

Commit

Permalink
apt-cyg pull 93 Postinstall fixes
Browse files Browse the repository at this point in the history
apt-cyg pull 93 Postinstall fixes

transcode-open/apt-cyg#93
  • Loading branch information
andykimpe authored Jun 17, 2024
1 parent 59c6db1 commit ef13dfc
Showing 1 changed file with 61 additions and 58 deletions.
119 changes: 61 additions & 58 deletions apt-cyg
Original file line number Diff line number Diff line change
Expand Up @@ -455,72 +455,75 @@ function apt-install {
for pkg in "${pks[@]}"
do

if grep -q "^$pkg " /etc/setup/installed.db
then
echo Package $pkg is already installed, skipping
continue
fi
(( sbq++ )) && echo
echo Installing $pkg
# indent package loop code
if grep -q "^$pkg " /etc/setup/installed.db
then
echo Package $pkg is already installed, skipping
continue
fi
(( sbq++ )) && echo
echo Installing $pkg

download $pkg
read dn bn </tmp/dwn
echo Unpacking...
download $pkg
read dn bn </tmp/dwn
echo Unpacking...

cd "$cache/$mirrordir/$dn"
tar -x -C / -f $bn
# update the package database
cd "$cache/$mirrordir/$dn"
tar -x -C / -f $bn
# update the package database

gawk '
ins != 1 && pkg < $1 {
print pkg, bz, 0
ins = 1
}
1
END {
if (ins != 1) print pkg, bz, 0
}
' pkg="$pkg" bz=$bn /etc/setup/installed.db > /tmp/gawk.$$
mv /etc/setup/installed.db /etc/setup/installed.db-save
mv /tmp/gawk.$$ /etc/setup/installed.db
awk '
ins != 1 && pkg < $1 {
print pkg, bz, 0
ins = 1
}
1
END {
if (ins != 1) print pkg, bz, 0
}
' pkg="$pkg" bz=$bn /etc/setup/installed.db > /tmp/awk.$$
mv /etc/setup/installed.db /etc/setup/installed.db-save
mv /tmp/awk.$$ /etc/setup/installed.db

[ -v nodeps ] && continue
# recursively install required packages
[ -v nodeps ] && continue
# recursively install required packages

requires=$(gawk '$1=="requires", $0=$2' FS=': ' desc)
cd ~-
wr=0
if [[ $requires ]]
then
echo Package $pkg requires the following packages, installing:
echo $requires
for package in $requires
do
if grep -q "^$package " /etc/setup/installed.db
then
echo Package $package is already installed, skipping
continue
fi
apt-cyg install --noscripts $package || (( wr++ ))
done
fi
if (( wr ))
then
echo some required packages did not install, continuing
fi
requires=$(awk '$1=="requires", $0=$2' FS=': ' desc)
cd ~-
wr=0
if [[ $requires ]]
then
echo Package $pkg requires the following packages, installing:
echo $requires
for package in $requires
do
if grep -q "^$package " /etc/setup/installed.db
then
echo Package $package is already installed, skipping
continue
fi
apt-cyg install --noscripts $package || (( wr++ ))
done
fi
if (( wr ))
then
echo some required packages did not install, continuing
fi

# run all postinstall scripts
echo Package $pkg installed

[ -v noscripts ] && continue
find /etc/postinstall -name '*.sh' | while read script
do
echo Running $script
$script
mv $script $script.done
done
echo Package $pkg installed
done

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

function apt-remove {
Expand Down

0 comments on commit ef13dfc

Please sign in to comment.