Skip to content

Commit

Permalink
Revise remove command
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Steven Penny committed May 14, 2014
1 parent 3ecc4ee commit 1b3c49d
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions apt-cyg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

1 comment on commit 1b3c49d

@kou1okada
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's seems pretty nice!
But on some case it can not remove packages that are not required by apt-cyg.
For example, the gawk-debuginfo package is not required by apt-cyg.
But it contains "gawk.exe.dbg" file.
Therefore, the gawk-debuginfo package can not be removed as below:

$ apt-cyg remove gawk-debuginfo
usr/lib/debug/usr/bin/gawk.exe.dbg
apt-cyg cannot remove package gawk-debuginfo, exiting

Please sign in to comment.