From 390024541d52f78823c9884ebe8814350832521b Mon Sep 17 00:00:00 2001 From: Steven Penny Date: Tue, 27 May 2014 23:18:48 -0500 Subject: [PATCH] listfiles download if necessary listfiles was only working on packages that were already installed. You should be able to list a packages files even if it is not installed, especially if it has already been downloaded. The function will now download the package if necessary, without installing, in order to view the package files. Other small changes - conditional echo instead of piping to "head" in certain loops - download function was exiting upon failure, when really it should just skip to next package - simplified a grep statement --- apt-cyg | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/apt-cyg b/apt-cyg index 7069c4f..fa97623 100755 --- a/apt-cyg +++ b/apt-cyg @@ -148,17 +148,17 @@ apt-list () { apt-listfiles () { checkpackages + findworkspace + local pkg for pkg in $packages do - if [ -e /etc/setup/"$pkg".lst.gz ] + (( notfirst++ )) && echo + if [ ! -e /etc/setup/"$pkg".lst.gz ] then - gzip -cd /etc/setup/"$pkg".lst.gz - else - echo package $pkg is not installed + download "$pkg" || continue fi - echo - done | - head -c-1 + gzip -cd /etc/setup/"$pkg".lst.gz + done } apt-show () { @@ -166,6 +166,7 @@ apt-show () { checkpackages for pkg in $packages do + (( notfirst++ )) && echo awk ' $1 == query { print @@ -174,11 +175,9 @@ apt-show () { END { if (! fd) print "Unable to locate package " query - printf "\n" } ' RS='\n\n@ ' FS='\n' query="$pkg" setup.ini - done | - head -c-1 + done } apt-depends () { @@ -234,9 +233,9 @@ download () { awk '$1 == pc' RS='\n\n@ ' FS='\n' pc=$pkg setup.ini > release/$pkg/desc if [ ! -s release/$pkg/desc ] then - echo Package $pkg not found or ambiguous name, exiting + echo Package $pkg not found or ambiguous name rm -r release/"$pkg" - exit 1 + return 1 fi echo Found package $pkg >&2 @@ -263,6 +262,7 @@ download () { exit 1 fi + tar tf $file | gzip > /etc/setup/"$pkg".lst.gz echo $file } @@ -274,8 +274,7 @@ apt-search () { [[ $key ]] || key=$pkg for manifest in /etc/setup/*.lst.gz do - found=$(gzip -cd $manifest | grep -c "$key") - if (( found )) + if gzip -cd $manifest | grep -q "$key" then package=$(sed ' s,/etc/setup/,, @@ -320,12 +319,11 @@ apt-install () { echo echo Installing $pkg - file=$(download $pkg) + file=$(download $pkg) || continue cd release/$pkg echo Unpacking... - tar xvf $file -C / > /etc/setup/"$pkg".lst - gzip -f /etc/setup/"$pkg".lst + tar -x -C / -f $file # update the package database awk '