spk view spk-archive @ rev 58

spk: show package log with --log
author Christophe Lincoln <pankso@slitaz.org>
date Thu May 17 15:49:44 2012 +0200 (2012-05-17)
parents 0a61f00e2373
children fb6acdd2617c
line source
1 #!/bin/bash
2 #
3 # Spk-Archive - SliTaz Package Archive Manager
4 #
5 # NOT COMPLETE: Still need to re-write (just what was grabbed from tazpkg)
6 #
7 # Authors : See the AUTHORS files
9 source /usr/lib/slitaz/libspk.sh
11 usage() {
12 name=$(basename $0)
13 cat << EOT
15 $(boldify $(gettext "Usage:")) $name [command] package
17 $(boldify $(gettext "Commands:"))
18 pack
19 repack [--config]
20 extract
21 recompress
23 $(boldify "$(gettext "Example:")")
24 $name extract clex
26 EOT
27 exit 0
28 }
30 # Extract a package with cpio and gzip/lzma to the current directory.
31 # Parameters: package_file
32 extract_package() {
33 local package_file=$1
34 local package_name=$(package_name $package_file)
36 eval_gettext "Extracting \$package_name... "
37 cpio -idm --quiet < ${package_file##*/} && rm -f ${package_file##*/}
38 status
40 gettext "Extracting the pseudo fs... "
41 unlzma -c fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
42 status
43 }
45 # Extract .tazpkg cpio archive into a directory.
46 # Parameters: package_file results_directory
47 extract() {
48 local package_file=$1
49 local target_dir=$2
51 # validate the file
52 check_valid_tazpkg $package_file
54 # find the package name
55 local package_name=$(package_name $package_file)
57 # Create destination directory
58 local dest_dir=$(pwd)/$package_name
59 [ -n "$target_dir" ] && dest_dir=$target_dir/$package_name
60 mkdir -p $dest_dir
62 newline
63 echo $(boldify $(gettext "Extracting:")) $package_name
64 separator
66 gettext "Copying original package..."
67 cp $package_file $dest_dir
68 status
69 pushd $dest_dir > /dev/null
70 extract_package $package $package_file
71 popd > /dev/null
72 separator
73 eval_gettext "\$package_name is extracted to: \$dest_dir"; newline
74 newline
75 }
77 # Recompress .tazpkg cpio archive with lzma.
78 # Parameters: package_file
79 recompress() {
80 local package_file=$1
81 valid_tazpkg $package_file
83 local package_name=$(package_name $package_file)
85 newline
86 echo $(boldify $(gettext "Recompressing:")) $package_name
87 separator
89 mkdir -p $TMP_DIR
91 gettext "Copying original package..."
92 cp $package_file $TMP_DIR
93 status
95 pushd $TMP_DIR > /dev/null
96 extract_package $package_file
98 gettext "Recompressing the fs... "
99 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
100 rm -rf fs
101 status
102 popd > /dev/null
104 gettext "Creating new package... "
105 find $TMP_DIR -print | cpio -o -H newc --quiet > \
106 $(basename $package_file).$$ && mv -f \
107 $(basename $package_file).$$ \
108 $(basename $package_file)
109 status
111 rm -rf $TMP_DIR
112 }
114 case $1 in
115 extract|-e)
116 extract_package $2 $3 ;;
117 recompress|-r)
118 recompress $2 ;;
119 *)
120 usage ;;
121 esac