Skip to content

Commit

Permalink
listfiles download if necessary
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Steven Penny committed May 28, 2014
1 parent 13a9f58 commit 3900245
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions apt-cyg
Original file line number Diff line number Diff line change
Expand Up @@ -148,24 +148,25 @@ 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 () {
findworkspace
checkpackages
for pkg in $packages
do
(( notfirst++ )) && echo
awk '
$1 == query {
print
Expand All @@ -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 () {
Expand Down Expand Up @@ -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

Expand All @@ -263,6 +262,7 @@ download () {
exit 1
fi

tar tf $file | gzip > /etc/setup/"$pkg".lst.gz
echo $file
}

Expand All @@ -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/,,
Expand Down Expand Up @@ -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 '
Expand Down

0 comments on commit 3900245

Please sign in to comment.