From 97da860684a324f95ae9de936660805a2565df74 Mon Sep 17 00:00:00 2001 From: Brian Inglis Date: Wed, 26 Oct 2016 21:38:05 -0600 Subject: [PATCH 1/2] indent install package loop code, support dash scripts, don't rename permanent first and last to run postinstall scripts --- apt-cyg | 115 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/apt-cyg b/apt-cyg index 84a2d5f..46a12db 100755 --- a/apt-cyg +++ b/apt-cyg @@ -441,71 +441,72 @@ function apt-install { local pkg dn bn requires wr package sbq script for pkg in "${pks[@]}" do + # 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 - 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/awk.$$ + mv /etc/setup/installed.db /etc/setup/installed.db-save + mv /tmp/awk.$$ /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=$(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 - 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 + # run all postinstall scripts + + [ -v noscripts ] && continue + find /etc/postinstall -name '*.*sh' | while read script # allow dash scripts 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++ )) + 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 - if (( wr )) - then - echo some required packages did not install, continuing - fi - - # run all postinstall scripts - - [ -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 + echo Package $pkg installed done } From bdd7ea86b1fba014314a1b0d5b4f60365d4d13cc Mon Sep 17 00:00:00 2001 From: Brian Inglis Date: Wed, 26 Oct 2016 21:43:12 -0600 Subject: [PATCH 2/2] run all postinstall scripts after all packages installed --- apt-cyg | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apt-cyg b/apt-cyg index 46a12db..675e271 100755 --- a/apt-cyg +++ b/apt-cyg @@ -496,9 +496,12 @@ function apt-install { echo some required packages did not install, continuing fi - # run all postinstall scripts + echo Package $pkg installed + + done - [ -v noscripts ] && continue + # 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 @@ -506,9 +509,7 @@ function apt-install { # don't rename permanent first and last to run postinstall scripts [[ $script != /etc/postinstall/[0z]p_*.*sh ]] && mv $script $script.done done - echo Package $pkg installed - - done + fi } function apt-remove {