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
This commit is contained in:
Steven Penny 2014-05-27 23:18:48 -05:00
parent 13a9f583b4
commit 390024541d
1 changed files with 15 additions and 17 deletions

32
apt-cyg
View File

@ -148,17 +148,17 @@ apt-list () {
apt-listfiles () { apt-listfiles () {
checkpackages checkpackages
findworkspace
local pkg
for pkg in $packages for pkg in $packages
do do
if [ -e /etc/setup/"$pkg".lst.gz ] (( notfirst++ )) && echo
if [ ! -e /etc/setup/"$pkg".lst.gz ]
then then
gzip -cd /etc/setup/"$pkg".lst.gz download "$pkg" || continue
else
echo package $pkg is not installed
fi fi
echo gzip -cd /etc/setup/"$pkg".lst.gz
done | done
head -c-1
} }
apt-show () { apt-show () {
@ -166,6 +166,7 @@ apt-show () {
checkpackages checkpackages
for pkg in $packages for pkg in $packages
do do
(( notfirst++ )) && echo
awk ' awk '
$1 == query { $1 == query {
print print
@ -174,11 +175,9 @@ apt-show () {
END { END {
if (! fd) if (! fd)
print "Unable to locate package " query print "Unable to locate package " query
printf "\n"
} }
' RS='\n\n@ ' FS='\n' query="$pkg" setup.ini ' RS='\n\n@ ' FS='\n' query="$pkg" setup.ini
done | done
head -c-1
} }
apt-depends () { apt-depends () {
@ -234,9 +233,9 @@ download () {
awk '$1 == pc' RS='\n\n@ ' FS='\n' pc=$pkg setup.ini > release/$pkg/desc awk '$1 == pc' RS='\n\n@ ' FS='\n' pc=$pkg setup.ini > release/$pkg/desc
if [ ! -s release/$pkg/desc ] if [ ! -s release/$pkg/desc ]
then then
echo Package $pkg not found or ambiguous name, exiting echo Package $pkg not found or ambiguous name
rm -r release/"$pkg" rm -r release/"$pkg"
exit 1 return 1
fi fi
echo Found package $pkg >&2 echo Found package $pkg >&2
@ -263,6 +262,7 @@ download () {
exit 1 exit 1
fi fi
tar tf $file | gzip > /etc/setup/"$pkg".lst.gz
echo $file echo $file
} }
@ -274,8 +274,7 @@ apt-search () {
[[ $key ]] || key=$pkg [[ $key ]] || key=$pkg
for manifest in /etc/setup/*.lst.gz for manifest in /etc/setup/*.lst.gz
do do
found=$(gzip -cd $manifest | grep -c "$key") if gzip -cd $manifest | grep -q "$key"
if (( found ))
then then
package=$(sed ' package=$(sed '
s,/etc/setup/,, s,/etc/setup/,,
@ -320,12 +319,11 @@ apt-install () {
echo echo
echo Installing $pkg echo Installing $pkg
file=$(download $pkg) file=$(download $pkg) || continue
cd release/$pkg cd release/$pkg
echo Unpacking... 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 # update the package database
awk ' awk '