From 1b3c49da148dd9e61ada3eae35f8e2c583f98755 Mon Sep 17 00:00:00 2001 From: Steven Penny Date: Wed, 14 May 2014 18:13:39 -0500 Subject: [PATCH] Revise remove command 1. print a list of all files and dependencies of those files used by apt-cyg 2. if any are found in the files list of the package to be removed, then fail Unrelated, added an echo each time a postinstall script is run, the name of the script --- apt-cyg | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/apt-cyg b/apt-cyg index b5e29af..cdbc48e 100755 --- a/apt-cyg +++ b/apt-cyg @@ -322,7 +322,7 @@ case "$command" in for pkg in $packages do - already=`grep -c "^$pkg " /etc/setup/installed.db` + already=$(grep -c "^$pkg " /etc/setup/installed.db) if (( already )) then echo Package $pkg is already installed, skipping @@ -429,16 +429,12 @@ case "$command" in # run all postinstall scripts - pis=`ls /etc/postinstall/*.sh 2>/dev/null | wc -l` - if (( pis )) - then - echo Running postinstall scripts - for script in /etc/postinstall/*.sh - do - $script - mv $script $script.done - done - fi + find /etc/postinstall -name '*.sh' | while read script + do + echo Running $script + $script + mv $script $script.done + done echo Package $pkg installed done @@ -449,20 +445,25 @@ case "$command" in for pkg in $packages do - already=`grep -c "^$pkg " /etc/setup/installed.db` + already=$(grep -c "^$pkg " /etc/setup/installed.db) if (( ! already )) then echo Package $pkg is not installed, skipping continue fi - for req in cygwin coreutils gawk bzip2 tar bash - do - if [[ $pkg = $req ]] - then - echo apt-cyg cannot remove package $pkg, exiting - exit 1 - fi - done + + cygcheck awk bash bunzip2 grep gzip mv sed tar xargs xz | awk ' + NR>1 && + /bin/ && + ! fd[$NF]++ && + $0 = $NF + ' FS='\' > /tmp/cygcheck.txt + + if apt-cyg listfiles $pkg | grep -wf /tmp/cygcheck.txt + then + echo apt-cyg cannot remove package $pkg, exiting + exit 1 + fi if [ ! -e /etc/setup/"$pkg".lst.gz ] then echo Package manifest missing, cannot remove $pkg. Exiting