rev |
line source |
pankso@6
|
1 #!/bin/sh
|
pankso@646
|
2 #
|
al@795
|
3 # TazPkg - Tiny autonomous zone packages manager.
|
pankso@6
|
4 #
|
paul@662
|
5 # This is a lightweight packages manager for *.tazpkg files written in SHell
|
al@795
|
6 # script. It works well with Busybox ash shell and bash. TazPkg lets you
|
pankso@646
|
7 # list, install, remove, download or get information about a package. You
|
pankso@646
|
8 # can use 'tazpkg usage' to get a list of commands with short descriptions.
|
al@795
|
9 # TazPkg also resolves dependencies and can upgrade packages from a mirror.
|
pankso@6
|
10 #
|
al@757
|
11 # (C) 2007-2015 SliTaz - GNU General Public License v3.
|
pankso@6
|
12 #
|
al@633
|
13 # Authors: See the AUTHORS files
|
pankso@27
|
14 #
|
pankso@6
|
15
|
al@795
|
16
|
pankso@6
|
17 ####################
|
pankso@6
|
18 # Script variables #
|
pankso@6
|
19 ####################
|
pankso@6
|
20
|
slaxemulator@588
|
21 . /etc/slitaz/slitaz.conf
|
pankso@307
|
22 . /etc/slitaz/tazpkg.conf
|
pankso@6
|
23
|
pankso@590
|
24 . /lib/libtaz.sh
|
pankso@661
|
25 . /usr/lib/slitaz/libpkg.sh
|
al@825
|
26 . @@MODULES@@/find-depends
|
pankso@590
|
27
|
pankso@595
|
28 # Internationalization.
|
al@694
|
29 export TEXTDOMAIN='tazpkg'
|
al@707
|
30 _() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; echo; }
|
al@707
|
31 _n() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; }
|
al@707
|
32 _p() {
|
al@811
|
33 local S="$1" P="$2" N="$3"; shift 3;
|
al@707
|
34 printf "$(ngettext "$S" "$P" "$N")" "$@"; }
|
al@694
|
35
|
pankso@343
|
36
|
al@834
|
37 # Translate category names (must be last in line)
|
al@834
|
38
|
al@834
|
39 translate_category() {
|
al@834
|
40 sed "s|base-system$|$(_ base-system)|; s|x-window$|$(_ x-window)|;
|
al@834
|
41 s|utilities$|$(_ utilities)|; s|network$|$(_ network)|;
|
al@834
|
42 s|graphics$|$(_ graphics)|; s|multimedia$|$(_ multimedia)|;
|
al@834
|
43 s|office$|$(_ office)|; s|development$|$(_ development)|;
|
al@834
|
44 s|system-tools$|$(_ system-tools)|; s|security$|$(_ security)|;
|
al@834
|
45 s|games$|$(_ games)|; s|misc$|$(_ misc)|; s|meta$|$(_ meta)|;
|
al@834
|
46 s|non-free$|$(_ non-free)|; s|all$|$(_ all)|; s|extra$|$(_ extra)|"
|
al@834
|
47 }
|
al@834
|
48
|
al@834
|
49
|
al@834
|
50 # Remove all --parameters from cmdline
|
al@834
|
51 #-------------------------------------
|
al@834
|
52 # (thanks to libtaz.sh all --parameters are already set to variables)
|
al@834
|
53
|
al@834
|
54 IFS=$'\n'
|
al@834
|
55 set -- $(echo "$*" | sed '/^--/d')
|
al@834
|
56 unset IFS
|
al@834
|
57
|
al@834
|
58
|
pankso@307
|
59 # Initialize some variables to use words rather than numbers for functions
|
pankso@307
|
60 # and actions.
|
al@804
|
61
|
al@804
|
62 COMMAND="$1"
|
al@804
|
63 PACKAGE="${2%/}"
|
al@812
|
64 PACKAGE_DIR="$(cd $(dirname "$PACKAGE" 2>/dev/null) 2>/dev/null; pwd)"
|
al@694
|
65 [ -n "$PACKAGE" ] && PACKAGE_FILE="$PACKAGE_DIR/${PACKAGE##*/}"
|
pascal@427
|
66 if [ -f "$PACKAGE" ]; then
|
pankso@10
|
67 # Set pkg basename for install, extract
|
al@812
|
68 PACKAGE="$(basename "$PACKAGE" .tazpkg 2>/dev/null)"
|
pankso@10
|
69 else
|
pankso@10
|
70 # Pkg name for remove, search and all other cmds
|
al@804
|
71 PACKAGE="${PACKAGE%.tazpkg}"
|
pankso@10
|
72 fi
|
al@804
|
73 TARGET_DIR="$3"
|
al@804
|
74 TOP_DIR="$(pwd)"
|
al@804
|
75 TMP_DIR="/tmp/$RANDOM"
|
al@804
|
76 INSTALL_LIST=''
|
gokhlayeh@419
|
77 SAVE_CACHE_DIR="$CACHE_DIR"
|
pankso@6
|
78
|
pankso@6
|
79 # Path to tazpkg used dir and configuration files
|
al@804
|
80 MIRROR="$PKGS_DB/mirror"
|
al@836
|
81 export BLOCKED="$PKGS_DB/blocked-packages.list"
|
al@836
|
82 export UP_LIST="$PKGS_DB/packages.up"
|
slaxemulator@588
|
83 DEFAULT_MIRROR="$ONLINE_PKGS"
|
pankso@6
|
84
|
al@811
|
85 # TazPkg version
|
al@811
|
86 VERSION=$(awk -F$'\t' '$1=="tazpkg"{print $2}' $PKGS_DB/installed.info)
|
al@811
|
87 # User Agent
|
al@836
|
88 export UA="TazPkg-$VERSION"
|
al@811
|
89
|
al@813
|
90 #title 'DEBUG'; emsg "<b>COMMAND</b>=\"$COMMAND\"\n<b>PACKAGE</b>=\"$PACKAGE\"\n<b>PACKAGE_FILE</b>=\"$PACKAGE_FILE\"\n<b>TARGET_DIR</b>=\"$TARGET_DIR\"\n<b>TOP_DIR</b>=\"$TOP_DIR\"\n<b>TMP_DIR</b>=\"$TMP_DIR\"\n<b>INSTALL_LIST</b>=\"$INSTALL_LIST\"\n<b>SAVE_CACHE_DIR</b>=\"$SAVE_CACHE_DIR\"\n<b>MIRROR</b>=\"$MIRROR\"\n<b>BLOCKED</b>=\"$BLOCKED\"\n<b>UP_LIST</b>=\"$UP_LIST\"\n<b>DEFAULT_MIRROR</b>=\"$DEFAULT_MIRROR\"\n<b>VERSION</b>=\"$VERSION\""; footer
|
pascal@515
|
91
|
al@694
|
92
|
pankso@6
|
93 ####################
|
pankso@6
|
94 # Script functions #
|
pankso@6
|
95 ####################
|
pankso@6
|
96
|
al@694
|
97
|
al@717
|
98 # Interactive mode
|
al@717
|
99
|
al@717
|
100 im() { tty -s; }
|
al@717
|
101
|
al@717
|
102
|
pankso@6
|
103 # Print the usage.
|
al@694
|
104
|
al@603
|
105 usage () {
|
al@785
|
106 cat <<EOT
|
pankso@600
|
107
|
al@702
|
108 $(_ 'SliTaz package manager - Version: %s' $(colorize 34 $VERSION))
|
al@694
|
109
|
al@694
|
110 $(boldify "$(_ 'Usage:')")
|
al@694
|
111 $(_ 'tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]')
|
al@694
|
112
|
al@694
|
113 $(boldify "$(_ 'SHell:')") tazpkg shell
|
al@694
|
114
|
al@694
|
115 $(boldify "$(_ 'Commands:')")
|
al@707
|
116 $(optlist "\
|
al@707
|
117 usage $(_ 'Print this short usage')
|
al@811
|
118 -h help $(_ 'Show help on the TazPkg commands')
|
al@707
|
119 -a activity $(_ 'Show TazPkg activity log')
|
al@811
|
120 -cc clean-cache $(_ 'Clean all packages downloaded in cache directory')
|
al@811
|
121 shell $(_ 'Run interactive TazPkg shell')
|
al@811
|
122
|
al@707
|
123 -l list $(_ 'List installed packages on the system')
|
al@707
|
124 -lm list-mirror $(_ 'List all available packages on the mirror')
|
al@811
|
125 list-config $(_ 'List the configuration files')
|
al@811
|
126
|
al@811
|
127 -s search $(_ 'Search for a package by pattern or name')
|
al@811
|
128 -sp search-pkgname $(_ 'Search on mirror for package having a particular file')
|
al@811
|
129 -sf search-file $(_ 'Search for file in all installed packages files')
|
al@811
|
130
|
al@811
|
131 -g get $(_ 'Download a package into the current directory')
|
al@811
|
132 -i install $(_ 'Install a local package')
|
al@811
|
133 -gi get-install $(_ 'Download and install a package from the mirror')
|
al@811
|
134 install-list $(_ 'Install all packages from a list of packages')
|
al@811
|
135 get-install-list $(_ 'Download and install a list of packages from the mirror')
|
al@811
|
136 -r remove $(_ 'Remove the specified package and all installed files')
|
al@811
|
137 reconfigure $(_ 'Replay post install script from package')
|
al@811
|
138 link $(_ 'Link a package from another SliTaz installation')
|
al@811
|
139 set-release $(_ 'Change release and update packages')
|
al@811
|
140 add-flavor $(_ 'Install the flavor list of packages')
|
al@811
|
141 install-flavor $(_ 'Install the flavor list of packages and remove other ones')
|
al@811
|
142
|
al@707
|
143 info $(_ 'Print information about a package')
|
al@811
|
144 -d desc $(_ 'Print description of a package')
|
al@707
|
145 -lf list-files $(_ 'List the files installed with a package')
|
al@811
|
146 -b|u block|unblock $(_ 'Block an installed package version or unblock it for upgrade')
|
al@811
|
147 check $(_ 'Verify consistency of installed packages')
|
al@811
|
148 bugs $(_ 'Show known bugs in packages')
|
al@811
|
149 depends $(_ 'Display dependencies tree')
|
al@811
|
150 rdepends $(_ 'Display reverse dependencies tree')
|
al@707
|
151 -e extract $(_ 'Extract a (*.tazpkg) package into a directory')
|
al@707
|
152 pack $(_ 'Pack an unpacked or prepared package tree')
|
al@707
|
153 repack $(_ 'Create a package archive from an installed package')
|
al@707
|
154 repack-config $(_ 'Create a package archive with configuration files')
|
al@707
|
155 recompress $(_ 'Rebuild a package with a better compression ratio')
|
al@707
|
156 convert $(_ 'Convert alien package to tazpkg')
|
al@811
|
157 list-suggested $(_ 'Print list of suggested packages')
|
al@811
|
158
|
al@811
|
159 recharge $(_ 'Recharge your packages.list from the mirror')
|
al@811
|
160 up|help-up $(_ 'Check packages %s to list and install latest upgrades' $CHECKSUM)
|
al@811
|
161 -sm setup-mirror $(_ 'Change the mirror URL configuration')
|
al@811
|
162 setup-undigest $(_ 'Update an undigest mirror')
|
al@707
|
163 list-undigest $(_ 'List undigest mirrors')
|
al@811
|
164 add-undigest $(_ 'Add an undigest mirror')
|
al@707
|
165 remove-undigest $(_ 'Remove an undigest mirror')
|
al@707
|
166 ")
|
al@603
|
167 EOT
|
pankso@6
|
168 }
|
pankso@6
|
169
|
al@694
|
170
|
pankso@464
|
171 usage_up() {
|
al@785
|
172 cat <<EOT
|
al@694
|
173 $(emsg "<b>$(_ 'Usage for command up:')</b>") tazpkg up [$(_ 'option')]
|
al@694
|
174
|
al@707
|
175 * $(longline "$(_ 'Without options run in interactive mode and ask before install')")
|
al@694
|
176
|
al@694
|
177 $(boldify "$(_ 'Where options are:')")
|
al@707
|
178 $(optlist "\
|
al@707
|
179 -c --check $(_ 'Check only for available upgrades')
|
al@707
|
180 -r --recharge $(_ 'Force recharge of packages list and check')
|
al@707
|
181 -i --install $(_ 'Check for upgrades and install them all')
|
al@707
|
182 ")
|
al@694
|
183
|
al@694
|
184 $(boldify "$(_ 'Example:')")
|
pankso@464
|
185 tazpkg up --recharge --install
|
pankso@464
|
186 tazpkg up -c -r
|
al@603
|
187 EOT
|
pankso@464
|
188 }
|
pankso@464
|
189
|
al@694
|
190
|
paul@662
|
191 # Check if dir exists
|
al@694
|
192
|
al@803
|
193 check_dir() {
|
al@811
|
194 if [ ! -d "$1" ]; then
|
al@707
|
195 action 'Creating folder "%s"...' "$1"
|
al@707
|
196 mkdir -p "$1"
|
pankso@584
|
197 status
|
pankso@584
|
198 return 1
|
pankso@584
|
199 fi
|
pankso@584
|
200 }
|
pankso@584
|
201
|
al@694
|
202
|
al@803
|
203 # Check if the directories and files used by TazPkg exist.
|
al@803
|
204 # If not and user is root we create them.
|
al@803
|
205
|
al@803
|
206 check_base_dir() {
|
al@805
|
207 if [ "$(id -u)" == '0' ]; then
|
pankso@590
|
208 check_dir $1$CACHE_DIR
|
pankso@590
|
209 check_dir $1$INSTALLED
|
pankso@594
|
210 check_dir $1$SLITAZ_LOGS
|
al@700
|
211 if [ ! -f "$1$PKGS_DB/mirror" ]; then
|
al@700
|
212 echo "${DEFAULT_MIRROR%/}/" > $1$PKGS_DB/mirror
|
al@700
|
213 [ -n "$1" ] && cp $PKGS_DB/packages.* $1$PKGS_DB/
|
pankso@590
|
214 fi
|
pankso@590
|
215 fi
|
pankso@590
|
216 }
|
pankso@590
|
217 check_base_dir
|
pankso@590
|
218
|
al@694
|
219
|
pankso@6
|
220 # Check for a package name on cmdline.
|
al@694
|
221
|
al@803
|
222 check_for_package_on_cmdline() {
|
pankso@6
|
223 if [ -z "$PACKAGE" ]; then
|
pankso@600
|
224 newline
|
al@694
|
225 _ 'Please specify a package name on the command line.'
|
pankso@600
|
226 newline
|
al@707
|
227 exit 1
|
pankso@6
|
228 fi
|
pankso@6
|
229 }
|
pankso@6
|
230
|
al@694
|
231
|
paul@437
|
232 # Check if the package (*.tazpkg) exists before installing or extracting.
|
al@694
|
233
|
al@803
|
234 check_for_package_file() {
|
pankso@9
|
235 if [ ! -f "$PACKAGE_FILE" ]; then
|
pankso@600
|
236 newline
|
al@813
|
237 _ 'Unable to find file "%s"' "$PACKAGE_FILE"
|
al@603
|
238 newline
|
al@707
|
239 exit 1
|
pankso@6
|
240 fi
|
pankso@6
|
241 }
|
pankso@6
|
242
|
al@694
|
243
|
pankso@6
|
244 # Check for the receipt of an installed package.
|
al@694
|
245
|
al@803
|
246 check_for_receipt() {
|
al@707
|
247 if [ ! -f "$1$INSTALLED/$PACKAGE/receipt" ]; then
|
pankso@600
|
248 newline
|
al@707
|
249 _ 'Unable to find the receipt "%s"' "$1$INSTALLED/$PACKAGE/receipt"
|
al@603
|
250 newline
|
al@707
|
251 exit 1
|
pankso@6
|
252 fi
|
pankso@6
|
253 }
|
pankso@6
|
254
|
al@694
|
255
|
al@700
|
256 # Get repositories priority using $PKGS_DB/priority.
|
al@804
|
257 # In this file undigest repos are called by their names and main mirror
|
al@804
|
258 # by 'main'. Sort order: priority
|
al@694
|
259
|
al@803
|
260 look_for_priority() {
|
al@804
|
261 [ -s "$PKGS_DB/priority" ] && priority=$(cat $PKGS_DB/priority)
|
al@804
|
262
|
al@700
|
263 for rep in main $(ls $PKGS_DB/undigest 2>/dev/null); do
|
al@804
|
264 if [ ! -s "$PKGS_DB/priority" ] || ! grep -q ^$rep$ $PKGS_DB/priority; then
|
al@694
|
265 priority=$(echo -e "$priority\n$rep")
|
al@694
|
266 fi
|
al@694
|
267 done
|
al@694
|
268 priority=$(echo "$priority" | sed '/^$/d' | \
|
al@694
|
269 while read line; do
|
al@804
|
270 case $line in
|
al@818
|
271 (main) echo $PKGS_DB;;
|
al@818
|
272 (*) echo $PKGS_DB/undigest/$line;;
|
al@804
|
273 esac
|
al@694
|
274 done)
|
gokhlayeh@386
|
275 }
|
gokhlayeh@386
|
276
|
al@694
|
277
|
pascal@110
|
278 # Get package name in a directory
|
al@694
|
279
|
al@803
|
280 package_fullname_in_dir() {
|
al@804
|
281 [ ! -f "$1/receipt" ] && return
|
al@804
|
282 EXTRAVERSION=''
|
gokhlayeh@407
|
283 . $1/receipt
|
al@804
|
284 echo "$PACKAGE-$VERSION$EXTRAVERSION"
|
pascal@110
|
285 }
|
pascal@110
|
286
|
al@694
|
287
|
pascal@110
|
288 # Get package name that is already installed.
|
al@694
|
289
|
al@803
|
290 get_installed_package_pathname() {
|
pascal@121
|
291 for i in $2$INSTALLED/${1%%-*}*; do
|
al@804
|
292 [ ! -d $i ] && continue
|
al@804
|
293 if [ "$1" == "$(package_fullname_in_dir $i)" ]; then
|
al@804
|
294 echo "$i"
|
pascal@110
|
295 return
|
pascal@110
|
296 fi
|
pascal@110
|
297 done
|
pascal@110
|
298 }
|
pascal@110
|
299
|
al@694
|
300
|
pankso@6
|
301 # Check if a package is already installed.
|
al@694
|
302
|
al@803
|
303 check_for_installed_package() {
|
al@813
|
304 if [ -n "$(get_installed_package_pathname "$PACKAGE" "$1")" ]; then
|
pankso@600
|
305 newline
|
al@813
|
306 _ '"%s" package is already installed.' "$(colorize 34 "$PACKAGE")"
|
al@707
|
307 longline "$(_ 'You can use the --forced option to force installation.')"
|
al@603
|
308 newline
|
al@603
|
309 exit 0
|
pankso@6
|
310 fi
|
pankso@6
|
311 }
|
pankso@6
|
312
|
al@694
|
313
|
pankso@6
|
314 # Check for packages.list to download and install packages.
|
al@694
|
315
|
al@803
|
316 check_for_packages_list() {
|
al@700
|
317 list_path="$PKGS_DB/packages.list"
|
al@633
|
318 if [ ! -f "$list_path" ]; then
|
al@828
|
319 if [ $(id -u) -eq 0 ]; then
|
pankso@71
|
320 tazpkg recharge
|
pankso@71
|
321 else
|
pankso@600
|
322 newline
|
al@702
|
323 _ 'Unable to find the list "%s"' $list_path
|
al@694
|
324 _ \
|
pankso@344
|
325 "You must probably run 'tazpkg recharge' as root to get the latest list of
|
al@694
|
326 packages available on the mirror."
|
al@603
|
327 newline
|
al@603
|
328 exit 0
|
pankso@71
|
329 fi
|
pankso@6
|
330 fi
|
pankso@6
|
331 }
|
pankso@6
|
332
|
al@694
|
333
|
al@701
|
334 # Check for installed.info - local file with format of packages.info
|
al@707
|
335 # "installed.info" is absent on not clean installs; check it and re-generate if needed.
|
al@701
|
336
|
al@803
|
337 check_for_installed_info() {
|
al@757
|
338 info_path="$ROOT$PKGS_DB/installed.info"
|
al@701
|
339 if [ ! -f "$info_path" ]; then
|
al@805
|
340 if [ "$(id -u)" == '0' ]; then
|
al@814
|
341 _ 'File "%s" generated. Please wait...' 'installed.info'
|
al@757
|
342 for pkg in $ROOT$PKGS_DB/installed/*/receipt; do
|
al@701
|
343 unset_receipt
|
al@701
|
344 . $pkg
|
al@701
|
345 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
|
al@701
|
346 DEPENDS=$(echo $DEPENDS) # remove newlines from some receipts
|
al@805
|
347 MD5="$(fgrep " $PACKAGE-$VERSION$EXTRAVERSION.tazpkg" \
|
al@805
|
348 $ROOT$PKGS_DB/installed.md5 | awk '{print $1}')"
|
al@701
|
349 cat >> $info_path << EOT
|
al@805
|
350 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $MD5
|
al@701
|
351 EOT
|
al@701
|
352 done
|
al@701
|
353 else
|
al@702
|
354 _ 'Unable to find file "%s"' installed.info
|
al@701
|
355 _ 'Please run tazpkg as root.'
|
al@701
|
356 exit 1
|
al@701
|
357 fi
|
al@701
|
358 fi
|
al@805
|
359
|
al@814
|
360 # Check for md5 field (#9) in the installed.info
|
al@814
|
361 if [ -n "$(awk -F$'\t' 'BEGIN{ n = "" } { if(NF != 9){ n = "o"; } } END{ print n }' $info_path)" ]; then
|
al@814
|
362 _n 'File "%s" generated. Please wait...' 'installed.info.new'
|
al@814
|
363 awk -F$'\t' -vm="$ROOT$PKGS_DB/installed.md5" 'BEGIN{OFS="\t"}
|
al@814
|
364 {
|
al@814
|
365 if (NF != 9) {
|
al@814
|
366 pkg = $1 "-" $2 ".tazpkg";
|
al@814
|
367 "fgrep " pkg " " m " | cut -c-32" | getline $9;
|
al@814
|
368 $9 = ($9 == "") ? "00000000000000000000000000000000" : $9;
|
al@814
|
369 }
|
al@814
|
370 print;
|
al@814
|
371 }' $info_path > $info_path.new
|
al@814
|
372 mv -f $info_path.new $info_path
|
al@814
|
373 status
|
al@814
|
374 fi
|
al@701
|
375 }
|
al@701
|
376
|
al@701
|
377
|
al@803
|
378 get_cache_dir() {
|
gokhlayeh@419
|
379 echo $rep > $tmp/rep
|
al@804
|
380 if [ "$rep" == "$PKGS_DB" ]; then
|
pankso@586
|
381 CACHE_DIR="$SAVE_CACHE_DIR/$SLITAZ_RELEASE/packages"
|
al@804
|
382 elif [ "${rep%-incoming}" == "$rep" ]; then
|
gokhlayeh@419
|
383 CACHE_DIR="$SAVE_CACHE_DIR/${rep##*/}/packages"
|
gokhlayeh@419
|
384 else
|
gokhlayeh@419
|
385 rep="${rep%-incoming}"
|
gokhlayeh@419
|
386 CACHE_DIR="$SAVE_CACHE_DIR/${rep##*/}/packages-incoming"
|
gokhlayeh@419
|
387 fi
|
al@804
|
388 [ ! -d "$CACHE_DIR" ] && mkdir -p $CACHE_DIR
|
gokhlayeh@419
|
389 echo $CACHE_DIR > $tmp/cachedir
|
gokhlayeh@419
|
390 }
|
gokhlayeh@419
|
391
|
al@694
|
392
|
pascal@261
|
393 # get an already installed package from packages.equiv
|
al@694
|
394
|
al@803
|
395 equivalent_pkg() {
|
al@700
|
396 for i in $(grep -hs "^$1=" $PKGS_DB/packages.equiv \
|
al@700
|
397 $PKGS_DB/undigest/*/packages.equiv | sed "s/^$1=//"); do
|
gokhlayeh@409
|
398 if echo $i | fgrep -q : ; then
|
pascal@226
|
399 # format 'alternative:newname'
|
pascal@226
|
400 # if alternative is installed then substitute newname
|
al@804
|
401 if [ -f "$2$INSTALLED/${i%:*}/receipt" ]; then
|
paul@662
|
402 # substitute package dependency
|
al@804
|
403 echo "${i#*:}"
|
pascal@226
|
404 return
|
pascal@226
|
405 fi
|
pascal@226
|
406 else
|
pascal@226
|
407 # if alternative is installed then nothing to install
|
al@804
|
408 if [ -f "$2$INSTALLED/$i/receipt" ]; then
|
pascal@226
|
409 # substitute installed package
|
al@804
|
410 echo "$i"
|
pascal@226
|
411 return
|
pascal@226
|
412 fi
|
pascal@226
|
413 fi
|
pascal@226
|
414 done
|
pascal@226
|
415 # if not found in packages.equiv then no substitution
|
al@804
|
416 echo "$1"
|
pascal@226
|
417 }
|
pascal@226
|
418
|
al@694
|
419
|
pascal@261
|
420 # get a virtual package from packages.equiv
|
al@694
|
421
|
al@803
|
422 virtual_pkg() {
|
pankso@598
|
423 for i in $(for rep in $priority; do
|
al@804
|
424 grep -hs "^$1=" $rep/packages.equiv
|
gokhlayeh@386
|
425 done | sed "s/^$1=//"); do
|
gokhlayeh@409
|
426 if echo $i | fgrep -q : ; then
|
pascal@261
|
427 # format 'alternative:newname'
|
pascal@261
|
428 # if alternative is installed then substitute newname
|
al@804
|
429 if [ -f "$2$INSTALLED/${i%:*}/receipt" ]; then
|
paul@662
|
430 # substitute package dependency
|
al@804
|
431 echo "${i#*:}"
|
pascal@261
|
432 return
|
pascal@261
|
433 fi
|
pascal@261
|
434 else
|
pascal@262
|
435 # unconditional substitution
|
al@804
|
436 echo "$i"
|
pascal@261
|
437 return
|
pascal@261
|
438 fi
|
pascal@261
|
439 done
|
pascal@261
|
440 }
|
pascal@261
|
441
|
al@694
|
442
|
pascal@190
|
443 # Get package filename available on the mirror
|
al@694
|
444
|
al@803
|
445 get_package_filename() {
|
al@811
|
446 # input: "<package_name>" or "<package_name>-<version>" (ex. "nano" or "nano-2.4.0")
|
al@811
|
447 local pkg equiv
|
gokhlayeh@386
|
448 for rep in $priority; do
|
al@811
|
449 pkg=$(awk -F$'\t' -vp="$1" 'p==$1||p==$1"-"$2{print $1"-"$2}' $rep/packages.info)
|
al@811
|
450
|
al@811
|
451 if [ -n "$pkg" ]; then
|
al@811
|
452 get_cache_dir; break
|
al@811
|
453 fi
|
gokhlayeh@386
|
454 done
|
pascal@226
|
455 if [ -z "$pkg" ]; then
|
paul@662
|
456 # Check for virtual package
|
pascal@261
|
457 equiv=$(virtual_pkg $1)
|
pascal@226
|
458 if [ "$equiv" != "$1" ]; then
|
al@804
|
459 PACKAGE="$equiv"
|
al@813
|
460 get_package_filename "$PACKAGE"
|
pascal@226
|
461 return
|
pascal@226
|
462 fi
|
pascal@226
|
463 fi
|
al@804
|
464 echo "$pkg"
|
pascal@190
|
465 }
|
pascal@190
|
466
|
al@694
|
467
|
al@811
|
468 # Check for a package in packages DB. Used by get and get-install to grep
|
pankso@6
|
469 # package basename.
|
al@694
|
470
|
al@803
|
471 check_for_package_in_list() {
|
al@811
|
472 local filename check_only
|
pascal@202
|
473 check_only="$1"
|
al@813
|
474 filename="$(get_package_filename "$PACKAGE")"
|
al@804
|
475 if [ -n "$filename" ]; then
|
al@804
|
476 PACKAGE="$filename"
|
al@804
|
477 CACHE_DIR="$(cat $tmp/cachedir)"
|
al@804
|
478 rep="$(cat $tmp/rep)"
|
gokhlayeh@419
|
479 rm -f $tmp/rep $tmp/cachedir
|
pankso@6
|
480 else
|
pankso@600
|
481 newline
|
al@813
|
482 _ 'Unable to find package "%s" in the mirrored packages list.' "$PACKAGE"
|
pankso@600
|
483 newline
|
pascal@202
|
484 [ -n "$check_only" ] && return 1
|
pankso@6
|
485 exit 0
|
pankso@6
|
486 fi
|
pankso@6
|
487 }
|
pankso@6
|
488
|
al@694
|
489
|
pascal@183
|
490 # Log this activity
|
al@603
|
491 # (there log_pkg because we have log() in libtaz.sh)
|
al@694
|
492
|
al@803
|
493 log_pkg() {
|
pascal@207
|
494 local extra
|
al@694
|
495
|
al@804
|
496 [ "$1" == 'Installed' ] && \
|
al@827
|
497 extra=" - $(fgrep " $PACKAGE-$VERSION" $PKGS_DB/installed.$SUM | awk '{ print $1 }')"
|
al@694
|
498
|
al@804
|
499 [ -e "$LOG" ] || touch $LOG
|
al@804
|
500
|
al@804
|
501 [ -w "$LOG" ] &&
|
al@694
|
502 echo "$(date +'%F %T') - $1 - $PACKAGE ($VERSION$EXTRAVERSION)$extra" >> $LOG
|
pascal@183
|
503 }
|
pascal@183
|
504
|
al@694
|
505
|
pascal@648
|
506 # Download a get-package script from this mirror
|
al@694
|
507
|
al@803
|
508 download_get_script() {
|
al@804
|
509 local p i
|
pascal@648
|
510 for p in $priority ; do
|
pascal@648
|
511 for i in $(cat $p/mirror) ; do
|
pascal@648
|
512 case "$i" in
|
al@804
|
513 http://*|https://*|ftp://*)
|
al@811
|
514 busybox wget -q -T 30 -U $UA -O $2 \
|
al@804
|
515 ${i%packages/*}packages/get/$1 && return 0 ;;
|
pascal@648
|
516 esac
|
pascal@648
|
517 done
|
pascal@648
|
518 done
|
pascal@648
|
519 return 1
|
pascal@648
|
520 }
|
pascal@648
|
521
|
al@694
|
522
|
pascal@187
|
523 # Download a file from this mirror
|
al@694
|
524
|
al@803
|
525 download_from() {
|
al@811
|
526 # input: "<mirror_url>+" "<package_name>-<version>.tazpkg"
|
al@811
|
527 local i
|
al@811
|
528 for i in $1; do
|
pascal@187
|
529 case "$i" in
|
pankso@580
|
530 # Mirror URL can have a trailing slash or not.
|
al@811
|
531 http://* | https://* | ftp://*)
|
al@811
|
532 busybox wget -c -q -T 30 -U $UA ${i%/}/$2 2>/dev/null && break ;;
|
al@694
|
533 *)
|
al@811
|
534 ln -sf ${i%/}/$2 . && break ;;
|
pascal@187
|
535 esac
|
pascal@187
|
536 done
|
pascal@187
|
537 }
|
pascal@187
|
538
|
al@694
|
539
|
pascal@17
|
540 # Download a file trying all mirrors
|
al@694
|
541
|
al@803
|
542 download() {
|
al@811
|
543 # input: <package_name>-<version>.tazpkg
|
pascal@187
|
544 local i
|
pascal@225
|
545 case "$1" in
|
al@811
|
546 *.tazpkg)
|
al@811
|
547 for i in $priority; do
|
al@811
|
548 if [ -n "$(awk -F$'\t' -vp="$1" 'p==$1"-"$2".tazpkg"{print $1}' \
|
al@811
|
549 $i/packages.info)" ]; then
|
al@811
|
550 download_from "$(cat $i/mirror)" "$@" && return
|
al@811
|
551 fi
|
al@811
|
552 done
|
al@811
|
553 ;;
|
pascal@225
|
554 esac
|
al@811
|
555
|
al@694
|
556 for i in $(cat $(for rep in $priority; do echo $rep/mirror; done) 2>/dev/null); do
|
pascal@191
|
557 download_from "$i" "$@" && break
|
pascal@17
|
558 done
|
pascal@17
|
559 }
|
pascal@17
|
560
|
al@694
|
561
|
pascal@297
|
562 # Extract a package with cpio and gzip/lzma.
|
al@694
|
563
|
al@803
|
564 extract_package() {
|
al@702
|
565 action 'Extracting package...'
|
al@813
|
566 cpio -idm --quiet < "${PACKAGE_FILE##*/}" && rm -f "${PACKAGE_FILE##*/}"
|
pascal@297
|
567 if [ -f fs.cpio.lzma ]; then
|
pascal@816
|
568 unlzma < fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
|
gokhlayeh@355
|
569 elif [ -f fs.cpio.gz ]; then
|
gokhlayeh@383
|
570 zcat fs.cpio.gz | cpio -idm --quiet && rm fs.cpio.gz
|
pascal@297
|
571 fi
|
al@814
|
572 status
|
pankso@6
|
573 }
|
pankso@6
|
574
|
al@694
|
575
|
al@803
|
576 remove_with_path() {
|
gokhlayeh@385
|
577 # Avoid dirname errors by checking for argument.
|
al@813
|
578 [ -n "$1" ] || return
|
pankso@598
|
579
|
pascal@299
|
580 local dir
|
pascal@299
|
581 rm -f $1 2>/dev/null
|
pascal@299
|
582 dir="$1"
|
pascal@299
|
583 while [ "$dir" != "/" ]; do
|
al@813
|
584 dir="$(dirname "$dir")"
|
al@813
|
585 rmdir "$dir" 2>/dev/null || break
|
pascal@299
|
586 done
|
pascal@299
|
587 }
|
pascal@299
|
588
|
al@694
|
589
|
al@803
|
590 grepesc() {
|
pascal@377
|
591 sed 's/\[/\\[/g'
|
pascal@377
|
592 }
|
pascal@377
|
593
|
al@694
|
594
|
al@795
|
595 # Print short package description
|
al@795
|
596 print_short_description() {
|
al@795
|
597 local short_desc=''
|
al@795
|
598 for LC in $LANG ${LANG%_*}; do
|
al@795
|
599 if [ -e "$PKGS_DB/packages-desc.$LC" ]; then
|
al@795
|
600 short_desc=$(grep -e "^$1 " $PKGS_DB/packages-desc.$LC | cut -d' ' -f2)
|
al@795
|
601 fi
|
al@795
|
602 done
|
pascal@797
|
603 [ -z "$short_desc" -a -s $PKGS_DB/packages.info ] &&
|
al@795
|
604 short_desc="$(awk -F$'\t' -vp="$PACKAGE" '{if($1==p){print $4;exit}}' $PKGS_DB/packages.info)"
|
al@795
|
605 longline "$short_desc"
|
al@795
|
606 }
|
al@795
|
607
|
al@795
|
608
|
MikeDSmith25@135
|
609 # This function installs a package in the rootfs.
|
al@694
|
610
|
al@803
|
611 install_package() {
|
pascal@20
|
612 ROOT=$1
|
pascal@20
|
613 if [ -n "$ROOT" ]; then
|
al@694
|
614 # Get absolute path
|
al@694
|
615 ROOT=$(realpath $ROOT)
|
pascal@20
|
616 fi
|
gokhlayeh@408
|
617 {
|
MikeDSmith25@134
|
618 # Create package path early to avoid dependencies loop
|
pascal@122
|
619 mkdir -p $TMP_DIR
|
al@813
|
620 { cd $TMP_DIR ; cpio --quiet -i receipt >/dev/null 2>&1; } < "$PACKAGE_FILE"
|
pascal@122
|
621 . $TMP_DIR/receipt
|
al@701
|
622 # FIXME: legacy?
|
pascal@224
|
623 if grep -q ^pre_depends $TMP_DIR/receipt; then
|
pascal@224
|
624 pre_depends $ROOT
|
pascal@224
|
625 fi
|
al@694
|
626
|
paul@662
|
627 # Keep modifiers and file list on upgrade
|
al@813
|
628 cp "$ROOT$INSTALLED/$PACKAGE/modifiers" \
|
al@813
|
629 "$ROOT$INSTALLED/$PACKAGE/files.list" $TMP_DIR 2>/dev/null
|
al@813
|
630 rm -rf "$ROOT$INSTALLED/$PACKAGE" 2>/dev/null
|
al@694
|
631
|
pascal@122
|
632 # Make the installed package data dir to store
|
pascal@122
|
633 # the receipt and the files list.
|
al@813
|
634 mkdir -p "$ROOT$INSTALLED/$PACKAGE"
|
al@813
|
635 cp $TMP_DIR/modifiers "$ROOT$INSTALLED/$PACKAGE" 2>/dev/null
|
al@813
|
636 cp $TMP_DIR/files.list "$ROOT$INSTALLED/$PACKAGE" 2>/dev/null
|
pascal@249
|
637 rm -rf $TMP_DIR 2> /dev/null
|
al@814
|
638 sed -i "/ $(basename "$PACKAGE_FILE")$/d" $ROOT$PKGS_DB/installed.$SUM 2>/dev/null
|
al@813
|
639 cd "$(dirname "$PACKAGE_FILE")"
|
al@813
|
640 $CHECKSUM "$(basename "$PACKAGE_FILE")" >> $ROOT$PKGS_DB/installed.$SUM
|
gokhlayeh@408
|
641 }
|
al@694
|
642
|
MikeDSmith25@134
|
643 # Resolve package deps.
|
pascal@120
|
644 check_for_deps $ROOT
|
al@694
|
645 if [ -n "$MISSING_PACKAGE" ]; then
|
pascal@120
|
646 install_deps $ROOT
|
pascal@120
|
647 fi
|
pankso@6
|
648 mkdir -p $TMP_DIR
|
al@700
|
649 [ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> $ROOT$PKGS_DB/$INSTALL_LIST-processed
|
al@694
|
650
|
al@812
|
651 title 'Installation of package "%s"' "$PACKAGE"
|
al@812
|
652
|
al@813
|
653 short_desc="$(print_short_description "$PACKAGE")"
|
al@813
|
654 [ -n "$short_desc" ] && echo "$short_desc" && separator '-'
|
al@791
|
655
|
al@702
|
656 action 'Copying package...'
|
al@812
|
657 cp "$PACKAGE_FILE" "$TMP_DIR"
|
pankso@6
|
658 status
|
al@694
|
659
|
al@812
|
660 cd "$TMP_DIR"
|
pankso@6
|
661 extract_package
|
al@812
|
662 SELF_INSTALL='0'
|
al@812
|
663 EXTRAVERSION=''
|
al@812
|
664 CONFIG_FILES=''
|
al@694
|
665
|
pankso@6
|
666 # Include temporary receipt to get the right variables.
|
pankso@6
|
667 . $PWD/receipt
|
pascal@273
|
668 cd $ROOT$INSTALLED
|
al@694
|
669
|
al@701
|
670 # FIXME: legacy?
|
pascal@20
|
671 if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then
|
al@603
|
672 action "Checking post install dependencies..."
|
al@813
|
673 [ -f "$INSTALLED/$PACKAGE/receipt" ]
|
pascal@20
|
674 if ! status; then
|
al@702
|
675 _ 'Please run "%s" in / and retry.' "tazpkg install $PACKAGE_FILE"
|
pascal@273
|
676 rm -rf $TMP_DIR
|
pascal@20
|
677 exit 1
|
pascal@20
|
678 fi
|
pascal@20
|
679 fi
|
al@694
|
680
|
pascal@273
|
681 # Get files to remove if upgrading
|
al@813
|
682 if [ -f "$PACKAGE/files.list" ]; then
|
pascal@273
|
683 while read file; do
|
pascal@377
|
684 grep -q "^$(echo $file | grepesc)$" $TMP_DIR/files.list && continue
|
al@813
|
685 for i in $(cat "$PACKAGE/modifiers" 2>/dev/null ;
|
al@813
|
686 fgrep -sl "$PACKAGE" */modifiers | cut -d/ -f1 ); do
|
pascal@377
|
687 grep -qs "^$(echo $file | grepesc)$" $i/files.list && continue 2
|
pascal@273
|
688 done
|
pascal@273
|
689 echo $file
|
al@813
|
690 done < "$PACKAGE/files.list" > $TMP_DIR/files2remove.list
|
pascal@273
|
691 fi
|
al@694
|
692
|
pascal@21
|
693 # Remember modified packages
|
al@694
|
694 {
|
al@694
|
695 check=false
|
al@694
|
696 for i in $(fgrep -v [ $TMP_DIR/files.list); do
|
al@694
|
697 [ -e "$ROOT$i" ] || continue
|
al@694
|
698 [ -d "$ROOT$i" ] && continue
|
al@694
|
699 echo "- $i"
|
al@694
|
700 check=true
|
al@694
|
701 done ;
|
al@694
|
702 $check && \
|
al@694
|
703 for i in *; do
|
al@694
|
704 [ "$i" == "$PACKAGE" ] && continue
|
al@694
|
705 [ -s $i/files.list ] || continue
|
al@694
|
706 awk "{ printf \"$i %s\\n\",\$1 }" < $i/files.list
|
al@694
|
707 done;
|
al@694
|
708 } | awk '
|
pascal@299
|
709 {
|
pascal@299
|
710 if ($1 == "-" || file[$2] != "") {
|
pascal@299
|
711 file[$2] = file[$2] " " $1
|
pascal@299
|
712 if ($1 != "-") {
|
pascal@299
|
713 if (pkg[$1] == "") all = all " " $1
|
pascal@299
|
714 pkg[$1] = pkg[$1] " " $2
|
pascal@299
|
715 }
|
pascal@299
|
716 }
|
pascal@299
|
717 }
|
pascal@299
|
718 END {
|
pascal@299
|
719 for (i = split(all, p, " "); i > 0; i--)
|
pascal@299
|
720 for (j = split(pkg[p[i]], f, " "); j > 0; j--)
|
pascal@299
|
721 printf "%s %s\n",p[i],f[j];
|
pascal@299
|
722 }
|
pascal@299
|
723 ' | while read dir file; do
|
al@813
|
724 if grep -qs ^$dir$ "$PACKAGE/modifiers"; then
|
pascal@299
|
725 # Do not overload an overloaded file !
|
al@813
|
726 rm $TMP_DIR$file 2>/dev/null
|
pascal@299
|
727 continue
|
pascal@299
|
728 fi
|
al@813
|
729 grep -qs "^$PACKAGE$" $dir/modifiers && continue
|
pascal@299
|
730 if [ -s "$dir/volatile.cpio.gz" ]; then
|
pascal@299
|
731 # We can modify backed up files without notice
|
gokhlayeh@383
|
732 zcat $dir/volatile.cpio.gz | cpio -t --quiet | \
|
pascal@299
|
733 grep -q "^${file#/}$" && continue
|
pascal@299
|
734 fi
|
pascal@299
|
735 echo "$PACKAGE" >> $dir/modifiers
|
pascal@21
|
736 done
|
pascal@299
|
737
|
pascal@273
|
738 cd $TMP_DIR
|
al@813
|
739 cp receipt files.list "$ROOT$INSTALLED/$PACKAGE"
|
al@694
|
740
|
pascal@20
|
741 # Copy the description if found.
|
pankso@6
|
742 if [ -f "description.txt" ]; then
|
al@813
|
743 cp description.txt "$ROOT$INSTALLED/$PACKAGE"
|
pankso@6
|
744 fi
|
al@694
|
745
|
pascal@128
|
746 # Copy the md5sum if found.
|
slaxemulator@588
|
747 if [ -f "$CHECKSUM" ]; then
|
al@813
|
748 cp $CHECKSUM "$ROOT$INSTALLED/$PACKAGE"
|
pascal@128
|
749 fi
|
al@694
|
750
|
pankso@38
|
751 # Pre install commands.
|
al@813
|
752 if grep -q ^pre_install "$ROOT$INSTALLED/$PACKAGE/receipt"; then
|
pascal@20
|
753 pre_install $ROOT
|
pankso@6
|
754 fi
|
al@712
|
755
|
al@712
|
756 if [ -n "$CONFIG_FILES" ]; then
|
pascal@144
|
757 # save 'official' configuration files
|
al@702
|
758 action 'Saving configuration files...'
|
pascal@144
|
759 for i in $CONFIG_FILES; do
|
pascal@539
|
760 { cd fs ; find ${i#/} -type f 2> /dev/null; cd ..; }
|
gokhlayeh@416
|
761 done | { cd fs ; cpio -o -H newc --quiet | gzip -9; cd ..; } > \
|
al@813
|
762 "$ROOT$INSTALLED/$PACKAGE/volatile.cpio.gz"
|
al@694
|
763
|
al@712
|
764 if [ -z "$newconf" ]; then
|
al@712
|
765 # keep user configuration files
|
al@712
|
766 for i in $CONFIG_FILES; do
|
al@712
|
767 { cd fs ; find ${i#/} -type f 2> /dev/null; cd ..; }
|
al@712
|
768 done | while read i; do
|
al@712
|
769 [ -e $ROOT/$i ] || continue
|
al@712
|
770 cp -a $ROOT/$i fs/$i
|
al@712
|
771 done
|
al@712
|
772 fi
|
pascal@144
|
773 status
|
pascal@144
|
774 fi
|
al@694
|
775
|
al@702
|
776 action 'Installing package...'
|
al@795
|
777 [ "$(busybox ls fs/* 2>/dev/null)" ] && cp -af fs/* $ROOT/
|
pankso@6
|
778 status
|
al@694
|
779
|
pascal@273
|
780 if [ -s files2remove.list ]; then
|
al@702
|
781 action 'Removing old package...'
|
pascal@273
|
782 while read file; do
|
pascal@299
|
783 remove_with_path $ROOT$file
|
pascal@273
|
784 done < files2remove.list
|
pascal@299
|
785 true
|
pascal@273
|
786 status
|
pascal@273
|
787 fi
|
al@694
|
788
|
pankso@6
|
789 # Remove the temporary random directory.
|
al@603
|
790 action "Removing all tmp files..."
|
al@694
|
791 cd ..; rm -rf $TMP_DIR
|
pankso@6
|
792 status
|
al@694
|
793
|
pankso@38
|
794 # Post install commands.
|
al@813
|
795 if grep -q ^post_install "$ROOT$INSTALLED/$PACKAGE/receipt"; then
|
al@795
|
796 action "Execute post-install commands..."
|
pascal@20
|
797 post_install $ROOT
|
al@795
|
798 status
|
pankso@6
|
799 fi
|
al@694
|
800
|
al@694
|
801 # Update-desktop-database if needed.
|
al@813
|
802 if [ "$(fgrep .desktop "$ROOT$INSTALLED/$PACKAGE/files.list" | fgrep /usr/share/applications/)" ]; then
|
gokhlayeh@356
|
803 updatedesktopdb=yes
|
gokhlayeh@356
|
804 fi
|
al@694
|
805
|
slaxemulator@369
|
806 # Update-mime-database if needed.
|
al@813
|
807 if [ "$(fgrep /usr/share/mime "$ROOT$INSTALLED/$PACKAGE/files.list")" ]; then
|
slaxemulator@369
|
808 updatemimedb=yes
|
slaxemulator@369
|
809 fi
|
al@694
|
810
|
slaxemulator@567
|
811 # Update-icon-database
|
al@813
|
812 if [ "$(fgrep /usr/share/icon/hicolor "$ROOT$INSTALLED/$PACKAGE/files.list")" ]; then
|
slaxemulator@567
|
813 updateicondb=yes
|
slaxemulator@567
|
814 fi
|
al@694
|
815
|
slaxemulator@534
|
816 # Compile glib schemas if needed.
|
al@813
|
817 if [ "$(fgrep /usr/share/glib-2.0/schemas "$ROOT$INSTALLED/$PACKAGE/files.list")" ]; then
|
slaxemulator@534
|
818 compile_schemas=yes
|
slaxemulator@534
|
819 fi
|
al@694
|
820
|
slaxemulator@588
|
821 # Update depmod list
|
al@813
|
822 if [ "$(fgrep /lib/modules "$ROOT$INSTALLED/$PACKAGE/files.list")" ]; then
|
slaxemulator@588
|
823 updatedepmod=yes
|
slaxemulator@588
|
824 fi
|
al@694
|
825
|
al@701
|
826 # Update installed.info
|
psychomaniak@714
|
827 check_for_installed_info
|
al@701
|
828 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
|
al@701
|
829 DEPENDS=$(echo $DEPENDS) # remove newlines from some receipts
|
al@827
|
830 PKG_SUM="$(fgrep " $PACKAGE-$VERSION$EXTRAVERSION.tazpkg" "$ROOT$PKGS_DB/installed.$SUM" | cut -d' ' -f1)"
|
al@757
|
831 II=$ROOT$PKGS_DB/installed.info
|
al@707
|
832 sed -i "/^$PACKAGE /d" $II # remove old entry
|
al@813
|
833 cat >> $II <<EOT
|
al@814
|
834 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $PKG_SUM
|
al@701
|
835 EOT
|
al@814
|
836 #awk -F$'\t' -vp="$PACKAGE" '$1==p' $ROOT$PKGS_DB/packages.info > $II
|
al@707
|
837 TEMP_FILE=$(mktemp)
|
al@707
|
838 sort $II > $TEMP_FILE; mv -f $TEMP_FILE $II; chmod a+r $II; unset II
|
al@701
|
839
|
al@813
|
840 cd "$TOP_DIR"
|
al@813
|
841 footer "$(_ 'Package "%s" (%s) is installed.' "$PACKAGE" "$VERSION$EXTRAVERSION")"
|
al@694
|
842
|
pascal@183
|
843 # Log this activity
|
al@603
|
844 [ -n "$ROOT" ] || log_pkg Installed
|
al@796
|
845
|
al@796
|
846 # Remove package from upgrade list
|
pascal@797
|
847 [ -s $UP_LIST ] && sed -i "/^$PACKAGE\$/d" $UP_LIST
|
pankso@6
|
848 }
|
pankso@6
|
849
|
al@694
|
850
|
pascal@648
|
851 # This function may be called by a get script.
|
al@694
|
852
|
al@803
|
853 abort_package() {
|
pascal@648
|
854 cd $CUR_DIR
|
pascal@648
|
855 rm -rf $TMP_DIR
|
pascal@648
|
856 echo "${1:-Abort $PACKAGE.}"
|
pascal@648
|
857 exit 1
|
pascal@648
|
858 }
|
pascal@648
|
859
|
al@694
|
860
|
paul@662
|
861 # This function installs a package from a get script in the rootfs.
|
al@694
|
862
|
al@803
|
863 install_package_from_get_script() {
|
pascal@648
|
864 SCRIPT="$1"
|
pascal@648
|
865 ROOT="$2"
|
al@811
|
866 [ -d "$ROOT$INSTALLED/$PACKAGE" ] && exit 1
|
pascal@648
|
867
|
pascal@648
|
868 grep -q no-check-certificate $SCRIPT &&
|
al@811
|
869 [ ! -d "$INSTALLED/wget" ] && tazpkg get-install wget
|
pascal@648
|
870
|
pascal@648
|
871 mkdir -p $TMP_DIR && cd $TMP_DIR
|
al@811
|
872 saved="$PACKAGE"
|
pankso@661
|
873 unset_receipt
|
al@811
|
874 PACKAGE="$saved"
|
al@811
|
875
|
pascal@648
|
876 set -e
|
pascal@648
|
877 . $SCRIPT
|
pascal@659
|
878 set +e
|
al@811
|
879 [ -d "$PACKAGE-$VERSION" ] || cd $TMP_DIR
|
al@811
|
880 [ -d "$PACKAGE-$VERSION" ] || abort_package \
|
al@813
|
881 "$(_ 'Could not download "%s" from "%s". Exiting.' "${TARBALL:-$PACKAGE}" "${WGET_URL:-$WEB_SITE}")"
|
al@702
|
882
|
al@811
|
883 if [ ! -s "$PACKAGE-$VERSION/receipt" ]; then
|
al@813
|
884 cat > "$PACKAGE-$VERSION/receipt" <<EOT
|
pascal@648
|
885 # SliTaz package receipt.
|
pascal@648
|
886
|
pascal@648
|
887 PACKAGE="$PACKAGE"
|
pascal@667
|
888 VERSION="${VERSION:-unknown}"
|
pascal@648
|
889 CATEGORY="${CATEGORY:-non-free}"
|
pascal@648
|
890 WEB_SITE="$WEB_SITE"
|
pascal@648
|
891 SHORT_DESC="${SHORT_DESC:-$PACKAGE}"
|
pascal@648
|
892 MAINTAINER="${MAINTAINER:-nobody@slitaz.org}"
|
pascal@648
|
893 EOT
|
pascal@648
|
894 for i in LICENSE TARBALL WGET_URL CONFIG_FILES SUGGESTED \
|
pascal@697
|
895 PROVIDE DEPENDS HOST_ARCH TAGS EXTRA_SOURCE_FILES ; do
|
pascal@648
|
896 eval "[ -n \"\$$i\" ] && echo \"$i=\\\"\$$i\\\"\""
|
al@813
|
897 done >> "$PACKAGE-$VERSION/receipt"
|
pascal@648
|
898 fi
|
pascal@648
|
899
|
al@813
|
900 DEPENDS="$(unset DEPENDS; . "$PACKAGE-$VERSION/receipt"; echo $DEPENDS)"
|
al@813
|
901 for i in $(find_depends "$PACKAGE-$VERSION/fs"); do
|
pascal@659
|
902 case " $DEPENDS " in
|
al@694
|
903 *\ $i\ *) continue;;
|
pascal@659
|
904 esac
|
al@813
|
905 grep -q '^DEPENDS="' "$PACKAGE-$VERSION/receipt" ||
|
al@813
|
906 echo 'DEPENDS=""' >> "$PACKAGE-$VERSION/receipt"
|
al@813
|
907 sed -i "s/^DEPENDS=\"/&$i /" "$PACKAGE-$VERSION/receipt"
|
pascal@659
|
908 done
|
pascal@659
|
909
|
pascal@808
|
910 TAZPKG_PACK=gzip
|
al@813
|
911 tazpkg pack "$PACKAGE-$VERSION"
|
pascal@648
|
912
|
pascal@648
|
913 # Clean to save RAM memory before installation
|
al@813
|
914 rm -rf "$PACKAGE-$VERSION"
|
pascal@648
|
915
|
al@834
|
916 if [ -n "$get" ]; then
|
al@813
|
917 mv "$PACKAGE-$VERSION.tazpkg" "$TOP_DIR"
|
pascal@793
|
918 else
|
pascal@793
|
919 # Install pseudo package
|
al@813
|
920 tazpkg install "$PACKAGE-$VERSION.tazpkg" --root=$ROOT
|
al@813
|
921 mv "$PACKAGE-$VERSION.tazpkg" $CACHE_DIR
|
pascal@793
|
922 fi
|
pascal@648
|
923
|
pascal@648
|
924 # Clean
|
al@813
|
925 cd "$TOP_DIR"
|
pascal@648
|
926 rm -rf $TMP_DIR
|
pascal@648
|
927 }
|
pascal@648
|
928
|
al@694
|
929
|
pascal@122
|
930 # Check for loop in deps tree.
|
al@694
|
931
|
al@803
|
932 check_for_deps_loop() {
|
al@811
|
933 local list pkg="$1" deps
|
pascal@122
|
934 shift
|
pascal@122
|
935 [ -n "$1" ] || return
|
al@811
|
936 list=''
|
al@694
|
937
|
pascal@122
|
938 # Filter out already processed deps
|
pascal@122
|
939 for i in $@; do
|
pascal@122
|
940 case " $ALL_DEPS" in
|
al@702
|
941 *\ $i\ *) ;;
|
al@702
|
942 *) list="$list $i";;
|
pascal@122
|
943 esac
|
pascal@122
|
944 done
|
pascal@122
|
945 ALL_DEPS="$ALL_DEPS$list "
|
pascal@122
|
946 for i in $list; do
|
pascal@122
|
947 [ -f $i/receipt ] || continue
|
pascal@122
|
948 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
|
pascal@122
|
949 case " $deps " in
|
al@811
|
950 *\ $pkg\ *)
|
al@811
|
951 print_pkgname
|
al@811
|
952 echo -e "$MSG $i"; MSG='';;
|
al@811
|
953 *)
|
al@811
|
954 check_for_deps_loop $pkg $deps;;
|
pascal@122
|
955 esac
|
pascal@122
|
956 done
|
pascal@122
|
957 }
|
pascal@122
|
958
|
al@694
|
959
|
pankso@6
|
960 # Check for missing deps listed in a receipt packages.
|
al@694
|
961
|
al@803
|
962 check_for_deps() {
|
pascal@116
|
963 local saved;
|
al@811
|
964 saved="$PACKAGE"
|
pascal@116
|
965 mkdir -p $TMP_DIR
|
al@813
|
966 { cd $TMP_DIR ; cpio --quiet -i receipt >/dev/null 2>&1; } < "$PACKAGE_FILE"
|
pascal@116
|
967 . $TMP_DIR/receipt
|
al@811
|
968 PACKAGE="$saved"
|
pascal@116
|
969 rm -rf $TMP_DIR
|
al@633
|
970
|
al@633
|
971 num=0
|
al@694
|
972 for pkgorg in $DEPENDS; do
|
pascal@164
|
973 i=$(equivalent_pkg $pkgorg $1)
|
pascal@120
|
974 if [ ! -d "$1$INSTALLED/$i" ]; then
|
pankso@6
|
975 MISSING_PACKAGE=$i
|
al@633
|
976 num=$(($num+1))
|
pascal@122
|
977 elif [ ! -f "$1$INSTALLED/$i/receipt" ]; then
|
al@813
|
978 _ 'WARNING! Dependency loop between "%s" and "%s".' "$PACKAGE" "$i"
|
pankso@6
|
979 fi
|
pankso@6
|
980 done
|
al@633
|
981
|
al@707
|
982 if [ -n "$MISSING_PACKAGE" ]; then
|
al@813
|
983 title "$(_ 'Tracking dependencies for package "%s"' "$PACKAGE")"
|
al@694
|
984 for pkgorg in $DEPENDS; do
|
pascal@164
|
985 i=$(equivalent_pkg $pkgorg $1)
|
pascal@120
|
986 if [ ! -d "$1$INSTALLED/$i" ]; then
|
al@811
|
987 MISSING_PACKAGE="$i"
|
al@702
|
988 _ 'Missing package "%s"' $MISSING_PACKAGE
|
pankso@6
|
989 fi
|
pankso@6
|
990 done
|
al@707
|
991 footer "$(_p \
|
al@707
|
992 '%s missing package to install.' \
|
al@707
|
993 '%s missing packages to install.' $num \
|
al@707
|
994 $num)"
|
pankso@6
|
995 fi
|
pankso@6
|
996 }
|
pankso@6
|
997
|
al@694
|
998
|
pankso@598
|
999 # Install all missing deps. Auto install or ask user then install all missing
|
al@811
|
1000 # deps from local dir, CD-ROM, media or from the mirror. In case we want to
|
pankso@6
|
1001 # install packages from local, we need a packages.list to find the version.
|
al@694
|
1002
|
al@803
|
1003 install_deps() {
|
al@811
|
1004 local root=''
|
pascal@121
|
1005 [ -n "$1" ] && root="--root=$1"
|
al@811
|
1006
|
al@811
|
1007 if [ "$AUTO_INSTALL_DEPS" == 'yes' ]; then
|
al@603
|
1008 answer=0
|
pankso@308
|
1009 else
|
pankso@600
|
1010 newline
|
al@696
|
1011 confirm "$(_ 'Install all missing dependencies? (y/N)')"
|
al@603
|
1012 answer=$?
|
pankso@600
|
1013 newline
|
pankso@308
|
1014 fi
|
al@811
|
1015
|
al@813
|
1016 if [ "$answer" -eq 0 ] && [ -z "$nodeps" ]; then
|
al@694
|
1017 for pkgorg in $DEPENDS; do
|
pascal@164
|
1018 pkg=$(equivalent_pkg $pkgorg $1)
|
pascal@120
|
1019 if [ ! -d "$1$INSTALLED/$pkg" ]; then
|
al@811
|
1020 local list="$INSTALL_LIST"
|
pascal@121
|
1021 [ -n "$list" ] || list="$TOP_DIR/packages.list"
|
pankso@6
|
1022 # We can install packages from a local dir by greping
|
pankso@6
|
1023 # the TAZPKG_BASENAME in the local packages.list.
|
al@813
|
1024 found='0'
|
pascal@121
|
1025 if [ -f "$list" ]; then
|
al@702
|
1026 _ 'Checking if package "%s" exists in local list...' $pkg
|
pascal@110
|
1027 mkdir $TMP_DIR
|
pascal@110
|
1028 for i in $pkg-*.tazpkg; do
|
pascal@124
|
1029 [ -f $i ] || continue
|
gokhlayeh@408
|
1030 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $i
|
al@813
|
1031 [ "$(. $TMP_DIR/receipt; echo "$PACKAGE")" == "$pkg" ] || continue
|
pascal@121
|
1032 if grep -q ^$(package_fullname_in_dir $TMP_DIR).tazpkg$ $list
|
pascal@110
|
1033 then
|
al@813
|
1034 found='1'
|
pascal@121
|
1035 tazpkg install $i $root --list=$list
|
pascal@110
|
1036 break
|
pascal@110
|
1037 fi
|
pascal@110
|
1038 done
|
pascal@110
|
1039 rm -rf $TMP_DIR
|
pascal@153
|
1040 fi
|
pankso@6
|
1041 # Install deps from the mirror.
|
pascal@153
|
1042 if [ $found -eq 0 ]; then
|
al@700
|
1043 if [ ! -f "$PKGS_DB/packages.list" ]; then
|
pankso@6
|
1044 tazpkg recharge
|
pankso@6
|
1045 fi
|
pascal@120
|
1046 tazpkg get-install $pkg $root
|
pankso@6
|
1047 fi
|
pankso@6
|
1048 fi
|
pankso@6
|
1049 done
|
pankso@6
|
1050 else
|
pankso@600
|
1051 newline
|
al@813
|
1052 _ 'Leaving dependencies for package "%s" unresolved.' "$PACKAGE"
|
al@702
|
1053 _ 'The package is installed but will probably not work.'
|
pankso@600
|
1054 newline
|
pankso@6
|
1055 fi
|
pankso@6
|
1056 }
|
pankso@6
|
1057
|
al@694
|
1058
|
pankso@279
|
1059 # Search pattern in installed packages.
|
al@694
|
1060
|
al@803
|
1061 search_in_installed_packages() {
|
al@834
|
1062 _ 'Installed packages'; separator '-'
|
al@811
|
1063 num='0'
|
al@834
|
1064 TMPLIST="$(mktemp)"
|
al@834
|
1065
|
al@834
|
1066 awk -F$'\t' -vpattern="$PATTERN" -vt="$TMPLIST" '
|
al@834
|
1067 BEGIN { IGNORECASE = 1 }
|
al@834
|
1068 index($1 "-" $2, pattern) {
|
al@834
|
1069 printf "%-24s%-18s%s\n", $1, $2, $3;
|
al@834
|
1070 printf "1" >> t
|
al@834
|
1071 }' "$PKGS_DB/installed.info" | translate_category
|
al@834
|
1072 num="$(wc -m < $TMPLIST)"; rm $TMPLIST
|
al@694
|
1073
|
al@707
|
1074 footer "$(_p \
|
al@707
|
1075 '%s installed package found for "%s"' \
|
al@707
|
1076 '%s installed packages found for "%s"' $num \
|
al@707
|
1077 $num "$PATTERN")"
|
pankso@54
|
1078 }
|
pankso@54
|
1079
|
al@694
|
1080
|
pankso@279
|
1081 # Search in packages.list for available pkgs.
|
al@694
|
1082
|
al@803
|
1083 search_in_packages_list() {
|
al@811
|
1084 _ 'Available packages'; separator '-'
|
al@811
|
1085 num='0'
|
al@811
|
1086 TMPLIST="$(mktemp)"
|
al@811
|
1087
|
al@811
|
1088 for i in $PKGS_DB/packages.info $PKGS_DB/undigest/*/packages.info; do
|
al@834
|
1089 [ -e "$i" ] && awk -F$'\t' -vpattern="$PATTERN" -vt="$TMPLIST" '
|
al@811
|
1090 BEGIN { IGNORECASE = 1 }
|
al@811
|
1091 index($1 "-" $2, pattern) {
|
al@834
|
1092 printf "%-24s%-18s%s\n", $1, $2, $3;
|
al@811
|
1093 printf "1" >> t
|
al@834
|
1094 }' "$i" | translate_category
|
pascal@187
|
1095 done
|
al@811
|
1096
|
al@811
|
1097 for i in $PKGS_DB/extra.list $PKGS_DB/undigest/*/extra.list; do
|
al@834
|
1098 [ -e "$i" ] && awk -F'|' -vpattern="$PATTERN" -vt="$TMPLIST" '
|
al@811
|
1099 BEGIN { IGNORECASE = 1 }
|
al@811
|
1100 index($1 "-" $5, pattern) {
|
al@834
|
1101 printf "%-24s%-18s%s\n", $1 " (extra)", $5, $4;
|
al@811
|
1102 printf "1" >> t
|
al@834
|
1103 }' "$i" | translate_category
|
al@811
|
1104 done
|
al@811
|
1105
|
al@811
|
1106 if [ ! -f "$PKGS_DB/packages.info" ]; then
|
pankso@600
|
1107 newline
|
al@707
|
1108 longline "$(_ \
|
al@707
|
1109 "No \"%s\" found to check for mirrored packages. For more results, please run \
|
al@811
|
1110 \"%s\" once as root before searching." 'packages.info' 'tazpkg recharge')"
|
pankso@600
|
1111 newline
|
pankso@54
|
1112 fi
|
al@811
|
1113
|
al@811
|
1114 num="$(wc -m < $TMPLIST)"; rm $TMPLIST
|
al@707
|
1115 footer "$(_p \
|
al@707
|
1116 '%s available package found for "%s"' \
|
al@707
|
1117 '%s available packages found for "%s"' $num \
|
al@707
|
1118 $num $PATTERN)"
|
pankso@54
|
1119 }
|
pankso@54
|
1120
|
al@694
|
1121
|
pankso@279
|
1122 # search --mirror: Search in packages.txt for available pkgs and give more
|
pankso@279
|
1123 # info than --list or default.
|
al@694
|
1124
|
al@803
|
1125 search_in_packages_txt() {
|
al@834
|
1126 _ 'Matching packages name with version and desc'; separator '-'
|
al@811
|
1127 num='0'
|
al@834
|
1128 TMPLIST="$(mktemp)"
|
al@834
|
1129
|
al@834
|
1130 for i in $PKGS_DB/packages.info $PKGS_DB/undigest/*/packages.info; do
|
al@834
|
1131 [ -e "$i" ] && awk -F$'\t' -vpattern="$PATTERN" -vt="$TMPLIST" '
|
al@834
|
1132 BEGIN { IGNORECASE = 1 }
|
al@834
|
1133 index($1 " " $2 " " $4, pattern) {
|
al@834
|
1134 split($7, s, " ");
|
al@834
|
1135 printf "%s\n%s\n%s\n%s (%s installed)\n\n", $1, $2, $4, s[1], s[2];
|
al@834
|
1136 printf "1" >> t;
|
al@834
|
1137 }' "$i"
|
pascal@187
|
1138 done
|
al@811
|
1139
|
al@834
|
1140 if [ ! -f "$PKGS_DB/packages.info" ]; then
|
pankso@600
|
1141 newline
|
al@707
|
1142 longline "$(_ \
|
al@707
|
1143 "No \"%s\" found to check for mirrored packages. For more results, please run \
|
al@834
|
1144 \"%s\" once as root before searching." 'packages.info' 'tazpkg recharge')"
|
pankso@600
|
1145 newline
|
pankso@54
|
1146 fi
|
al@811
|
1147
|
al@834
|
1148 num="$(wc -m < $TMPLIST)"; rm $TMPLIST
|
al@707
|
1149 footer "$(_p \
|
al@707
|
1150 '%s available package found for "%s"' \
|
al@707
|
1151 '%s available packages found for "%s"' $num \
|
al@707
|
1152 $num $PATTERN)"
|
pankso@54
|
1153 }
|
pankso@54
|
1154
|
al@694
|
1155
|
pascal@74
|
1156 # Install package-list from a flavor
|
al@694
|
1157
|
al@803
|
1158 install_flavor() {
|
al@603
|
1159 check_root $@
|
pankso@598
|
1160
|
gokhlayeh@386
|
1161 # Get repositories priority list.
|
gokhlayeh@386
|
1162 look_for_priority
|
pankso@598
|
1163
|
al@811
|
1164 FLAVOR="$1"
|
pascal@74
|
1165 mkdir -p $TMP_DIR
|
pascal@74
|
1166 [ -f $FLAVOR.flavor ] && cp $FLAVOR.flavor $TMP_DIR
|
pascal@74
|
1167 cd $TMP_DIR
|
pascal@74
|
1168 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
|
pascal@643
|
1169 zcat < $FLAVOR.flavor | cpio --quiet -i >/dev/null
|
al@694
|
1170
|
pascal@74
|
1171 while read file; do
|
pascal@74
|
1172 for pkg in $(ls -d $INSTALLED/${file%%-*}*); do
|
pascal@122
|
1173 [ -f $pkg/receipt ] || continue
|
al@811
|
1174 EXTRAVERSION=''
|
pascal@74
|
1175 . $pkg/receipt
|
al@805
|
1176 [ "$PACKAGE-$VERSION$EXTRAVERSION" == "$file" ] && break
|
pascal@74
|
1177 done
|
al@805
|
1178 [ "$PACKAGE-$VERSION$EXTRAVERSION" == "$file" ] && continue
|
pascal@74
|
1179 cd $CACHE_DIR
|
pascal@74
|
1180 download $file.tazpkg
|
pascal@74
|
1181 cd $TMP_DIR
|
al@694
|
1182 tazpkg install $CACHE_DIR/$file.tazpkg --forced
|
pascal@74
|
1183 done < $FLAVOR.pkglist
|
al@694
|
1184
|
pascal@75
|
1185 [ -f $FLAVOR.nonfree ] && while read pkg; do
|
pascal@75
|
1186 [ -d $INSTALLED/$pkg ] || continue
|
pascal@75
|
1187 [ -d $INSTALLED/get-$pkg ] && tazpkg get-install get-$pkg
|
pascal@75
|
1188 get-$pkg
|
pascal@75
|
1189 done < $FLAVOR.nonfree
|
al@694
|
1190
|
al@811
|
1191 # option "--purge"
|
al@811
|
1192 [ -n "$purge" ] && for pkg in $(ls $INSTALLED); do
|
pascal@122
|
1193 [ -f $INSTALLED/$pkg/receipt ] || continue
|
al@811
|
1194 EXTRAVERSION=''
|
pascal@74
|
1195 . $INSTALLED/$pkg/receipt
|
al@813
|
1196 grep -q "^$PACKAGE-$VERSION$EXTRAVERSION$" $FLAVOR.pkglist && continue
|
al@813
|
1197 grep -qs "^$PACKAGE$" $FLAVOR.nonfree && continue
|
al@813
|
1198 tazpkg remove "$PACKAGE"
|
pascal@74
|
1199 done
|
pascal@74
|
1200 else
|
al@702
|
1201 _ "Can't find flavor \"%s\". Abort." $FLAVOR
|
pascal@74
|
1202 fi
|
al@813
|
1203 cd "$TOP_DIR"
|
pascal@74
|
1204 rm -rf $TMP_DIR
|
pascal@74
|
1205 }
|
pascal@74
|
1206
|
al@694
|
1207
|
al@811
|
1208 # Update mirror URLs
|
al@694
|
1209
|
al@803
|
1210 setup_mirror() {
|
pascal@187
|
1211 # Backup old list.
|
pascal@187
|
1212 if [ -f "$1/mirror" ]; then
|
pascal@187
|
1213 cp -f $1/mirror $1/mirror.bak
|
pascal@187
|
1214 fi
|
al@603
|
1215 title 'Current mirror(s)'
|
al@811
|
1216 echo " $(cat $1/mirror 2> /dev/null)"
|
al@707
|
1217 longline "$(_ \
|
al@707
|
1218 "Please enter URL of the new mirror (http, ftp or local path). You must specify \
|
al@707
|
1219 the complete address to the directory of the packages and packages.list file.")"
|
pankso@600
|
1220 newline
|
al@811
|
1221
|
al@694
|
1222 _n 'New mirror(s) URL: '
|
al@811
|
1223 NEW_MIRROR_URL="$2"
|
pascal@187
|
1224 if [ -n "$NEW_MIRROR_URL" ]; then
|
pascal@187
|
1225 echo $NEW_MIRROR_URL
|
pascal@187
|
1226 else
|
pascal@187
|
1227 read NEW_MIRROR_URL
|
pascal@187
|
1228 fi
|
al@811
|
1229
|
al@805
|
1230 if [ -z "$NEW_MIRROR_URL" ]; then
|
al@694
|
1231 _ 'Nothing has been changed.'
|
pascal@187
|
1232 else
|
al@702
|
1233 _ 'Setting mirror(s) to: "%s"' $NEW_MIRROR_URL
|
pascal@187
|
1234 rm -f $1/mirror
|
pascal@187
|
1235 for i in $NEW_MIRROR_URL; do
|
pascal@685
|
1236 echo "${i%/}/" >> $1/mirror
|
pankso@279
|
1237 done
|
pascal@187
|
1238 fi
|
pankso@600
|
1239 newline
|
pascal@187
|
1240 }
|
pascal@187
|
1241
|
al@694
|
1242
|
paul@247
|
1243 # recursive dependencies scan
|
al@694
|
1244
|
al@803
|
1245 dep_scan() {
|
al@694
|
1246 for i in $1; do
|
al@694
|
1247 case " $ALL_DEPS " in
|
al@694
|
1248 *\ $i\ *) continue;;
|
al@694
|
1249 esac
|
al@694
|
1250 ALL_DEPS="$ALL_DEPS $i"
|
al@836
|
1251
|
al@836
|
1252 if [ -z "$mark" ]; then
|
al@836
|
1253 ii="$i"
|
al@836
|
1254 else
|
al@836
|
1255 ii="- $i"; grep -q ^$i$'\t' "$PKGS_DB/installed.info" && ii="+ $i"
|
al@836
|
1256 fi
|
al@836
|
1257 [ -n "$2" ] && echo "$2$ii ($(awk -F$'\t' -vp="$i" '
|
al@836
|
1258 $1==p{split($7,s," ");print s[2]}' "$PKGS_DB/packages.info"))"
|
al@836
|
1259
|
al@836
|
1260 DEPENDS="$(awk -F$'\t' -vp="$i" '$1==p{print $8 " "}' "$PKGS_DB/installed.info")"
|
al@836
|
1261 [ -z "$DEPENDS" ] && \
|
al@836
|
1262 DEPENDS="$(awk -F$'\t' -vp="$i" '$1==p{print $8 " "}' "$PKGS_DB/packages.info")"
|
al@694
|
1263 [ -n "$DEPENDS" ] && dep_scan "$DEPENDS" "$2 "
|
al@694
|
1264 done
|
pascal@205
|
1265 }
|
pascal@205
|
1266
|
al@694
|
1267
|
paul@247
|
1268 # recursive reverse dependencies scan
|
al@694
|
1269
|
al@803
|
1270 rdep_scan() {
|
al@811
|
1271 SEARCH="$1"
|
al@694
|
1272
|
al@836
|
1273 DB='installed'; [ -n "$all" ] && DB='packages'
|
al@836
|
1274
|
al@836
|
1275 awk -F$'\t' '$8 {print $1 " " $8}' "$PKGS_DB/$DB.info" | \
|
al@836
|
1276 busybox awk -F' ' -v search="$SEARCH" '
|
al@836
|
1277 function show_deps(pkg, space, i, n, mydeps) {
|
al@836
|
1278 if (processed[pkg]) return
|
al@836
|
1279 processed[pkg] = 1;
|
al@836
|
1280
|
al@836
|
1281 if (space) printf "%s %s\n", space, pkg;
|
al@836
|
1282
|
al@836
|
1283 n = split(deps[pkg], mydeps, " ");
|
al@836
|
1284 for (i = 1; i <= n; i++)
|
al@836
|
1285 show_deps(mydeps[i], "==" space);
|
al@836
|
1286 }
|
al@836
|
1287
|
pascal@260
|
1288 {
|
al@836
|
1289 for (i = 2; i <= NF; i++)
|
al@836
|
1290 deps[$i] = deps[$i] " " $1;
|
pascal@260
|
1291 }
|
pascal@260
|
1292
|
pascal@260
|
1293 END {
|
al@836
|
1294 show_deps(search, "")
|
pascal@260
|
1295 }
|
pascal@304
|
1296 ' | while read spc pkg; do
|
al@836
|
1297 if [ -z "$mark" ]; then
|
al@836
|
1298 pkgi="$pkg"
|
al@836
|
1299 else
|
al@836
|
1300 pkgi="- $pkg"; grep -q ^$pkg$'\t' "$PKGS_DB/installed.info" && pkgi="+ $pkg"
|
al@836
|
1301 fi
|
al@836
|
1302
|
al@694
|
1303 echo -n $spc | sed 's/=/ /g'
|
al@836
|
1304
|
al@836
|
1305 echo "$pkgi ($(awk -F$'\t' -vp="$pkg" '$1==p{split($7,s," ");print s[2]}' \
|
al@836
|
1306 "$PKGS_DB/$DB.info"))"
|
al@694
|
1307 done
|
pascal@205
|
1308 }
|
pascal@205
|
1309
|
al@694
|
1310
|
al@803
|
1311 update_desktop_database() {
|
al@811
|
1312 if [ -f "$1/usr/bin/update-desktop-database" ] && [ -n "$updatedesktopdb" ]; then
|
pascal@578
|
1313 chroot "$1/" /usr/bin/update-desktop-database /usr/share/applications 2>/dev/null
|
gokhlayeh@356
|
1314 fi
|
gokhlayeh@356
|
1315 }
|
gokhlayeh@356
|
1316
|
al@694
|
1317
|
al@803
|
1318 update_mime_database() {
|
al@811
|
1319 if [ -f "$1/usr/bin/update-mime-database" ] && [ -n "$updatemimedb" ]; then
|
pascal@578
|
1320 chroot "$1/" /usr/bin/update-mime-database /usr/share/mime
|
slaxemulator@369
|
1321 fi
|
slaxemulator@369
|
1322 }
|
slaxemulator@369
|
1323
|
al@694
|
1324
|
al@803
|
1325 update_icon_database() {
|
al@811
|
1326 if [ -f "$1/usr/bin/gtk-update-icon-cache" ] && [ -n "$updateicondb" ]; then
|
pascal@578
|
1327 chroot "$1/" /usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor
|
slaxemulator@567
|
1328 fi
|
slaxemulator@567
|
1329 }
|
slaxemulator@567
|
1330
|
al@694
|
1331
|
al@803
|
1332 compile_glib_schemas() {
|
al@811
|
1333 if [ -f "$1/usr/bin/glib-compile-schemas" ] && [ -n "$compile_schemas" ]; then
|
pascal@578
|
1334 chroot "$1/" /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas
|
slaxemulator@534
|
1335 fi
|
slaxemulator@534
|
1336 }
|
slaxemulator@534
|
1337
|
al@694
|
1338
|
al@803
|
1339 update_kernel_modules() {
|
al@811
|
1340 if [ -f "$1/sbin/depmod" ] && [ -n "$updatedepmod" ]; then
|
slaxemulator@588
|
1341 chroot "$1/" /sbin/depmod -a
|
slaxemulator@588
|
1342 fi
|
slaxemulator@588
|
1343 }
|
slaxemulator@588
|
1344
|
al@694
|
1345
|
al@811
|
1346 # Print package name if not printed yet
|
al@811
|
1347 print_pkgname() {
|
al@811
|
1348 if [ "$PACKAGE" != "$PACKAGE_PRINTED" ]; then
|
al@811
|
1349 [ -n "$PACKAGE_PRINTED" ] && footer
|
al@811
|
1350 title 'Package %s' "$PACKAGE-$VERSION$EXTRAVERSION"
|
al@811
|
1351 PACKAGE_PRINTED="$PACKAGE"
|
al@811
|
1352 fi
|
al@811
|
1353 }
|
al@811
|
1354
|
al@694
|
1355
|
al@694
|
1356
|
pankso@6
|
1357 ###################
|
al@803
|
1358 # TazPkg commands #
|
pankso@6
|
1359 ###################
|
pankso@6
|
1360
|
pankso@6
|
1361 case "$COMMAND" in
|
pankso@504
|
1362 list|-l)
|
al@828
|
1363 # Various lists
|
al@603
|
1364 shift
|
al@701
|
1365 case $1 in
|
al@828
|
1366 b|blocked) @@MODULES@@/list blocked ;;
|
al@828
|
1367 c|cat|categories) @@MODULES@@/list categories;;
|
al@828
|
1368 l|linked) @@MODULES@@/list linked ;;
|
al@828
|
1369 '') check_for_installed_info
|
al@828
|
1370 @@MODULES@@/list installed ;;
|
al@828
|
1371 *) check_for_installed_info
|
al@828
|
1372 @@MODULES@@/list installed_of_category "$@";;
|
pankso@53
|
1373 esac
|
al@603
|
1374 ;;
|
al@828
|
1375 -lb) @@MODULES@@/list blocked ;;
|
al@828
|
1376 -lc) @@MODULES@@/list categories;;
|
al@828
|
1377 -ll) @@MODULES@@/list linked ;;
|
al@828
|
1378
|
al@828
|
1379 -lm|list-mirror) @@MODULES@@/list mirrored ;;
|
al@828
|
1380 -lf|list-files) check_for_package_on_cmdline
|
al@828
|
1381 @@MODULES@@/list installed_files $PACKAGE;;
|
al@828
|
1382 -a|activity|log) @@MODULES@@/list activity ;;
|
al@828
|
1383 list-config) @@MODULES@@/list config_files $2;;
|
al@828
|
1384 list-suggested) @@MODULES@@/list suggested ;;
|
al@828
|
1385
|
al@828
|
1386
|
al@828
|
1387 info)
|
al@828
|
1388 # Information about package
|
pankso@6
|
1389 check_for_package_on_cmdline
|
al@828
|
1390 @@MODULES@@/info "$2"
|
al@717
|
1391 ;;
|
al@694
|
1392
|
al@694
|
1393
|
al@811
|
1394 desc|-d)
|
al@717
|
1395 # Display package description
|
al@819
|
1396 unset desc
|
al@819
|
1397
|
al@819
|
1398 # 1) Localized description
|
al@819
|
1399 for LC in $LANG ${LANG%_*}; do
|
al@819
|
1400 [ -e "$PKGS_DB/descriptions.$LC.txt" ] &&
|
al@819
|
1401 desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$PACKAGE" '
|
al@819
|
1402 $1 == p { $1 = ""; print $0; exit; }
|
al@819
|
1403 ' "$PKGS_DB/descriptions.$LC.txt" | sed '1d')"
|
al@819
|
1404 done
|
al@819
|
1405
|
al@819
|
1406 # 2) Installed description
|
al@819
|
1407 if [ -z "$desc" -a -s "$INSTALLED/$PACKAGE/description.txt" ]; then
|
al@819
|
1408 desc="$(cat "$INSTALLED/$PACKAGE/description.txt")"
|
al@819
|
1409 fi
|
al@819
|
1410
|
al@819
|
1411 # 3) Mirrored description
|
al@819
|
1412 if [ -z "$desc" -a -s "$PKGS_DB/descriptions.txt" ]; then
|
al@819
|
1413 desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$PACKAGE" '
|
al@819
|
1414 $1 == p { $1 = ""; print $0; exit; }
|
al@819
|
1415 ' "$PKGS_DB/descriptions.txt" | sed '1d')"
|
al@819
|
1416 fi
|
al@819
|
1417
|
al@819
|
1418 # 4) Short description only in terminal
|
al@819
|
1419 if [ -z "$desc" ] && im; then
|
al@819
|
1420 desc="$(print_short_description "$PACKAGE")"
|
al@819
|
1421 fi
|
al@819
|
1422
|
al@819
|
1423 if [ -n "$desc" ]; then
|
al@819
|
1424 # Title and footer only in terminal
|
al@813
|
1425 im && title 'Description of package "%s"' "$PACKAGE"
|
al@819
|
1426 echo "$desc"
|
al@717
|
1427 im && footer
|
pankso@6
|
1428 else
|
al@819
|
1429 im && _ 'Description absent.'
|
al@711
|
1430 fi
|
al@711
|
1431 ;;
|
al@694
|
1432
|
al@694
|
1433
|
pankso@504
|
1434 search|-s)
|
pankso@6
|
1435 # Search for a package by pattern or name.
|
pankso@54
|
1436 PATTERN="$2"
|
al@834
|
1437 if [ -z "$PATTERN" ]; then tazpkg -h search; exit 1; fi
|
al@834
|
1438
|
al@813
|
1439 title 'Search result for "%s"' "$PATTERN"
|
pankso@54
|
1440 # Default is to search in installed pkgs and the raw list.
|
pankso@654
|
1441 case "$3" in
|
al@834
|
1442 -i) installed='yes';;
|
al@834
|
1443 -l) list='yes';;
|
al@834
|
1444 -m) mirror='yes';;
|
al@834
|
1445 esac
|
al@834
|
1446
|
al@834
|
1447 [ -n "$installed" ] && search_in_installed_packages
|
al@834
|
1448 [ -n "$list" ] && search_in_packages_list
|
al@834
|
1449 [ -n "$mirror" ] && search_in_packages_txt
|
al@834
|
1450 if [ -z "$installed$list$mirror" ]; then
|
al@834
|
1451 search_in_installed_packages
|
al@834
|
1452 search_in_packages_list
|
al@834
|
1453 fi
|
al@834
|
1454 ;;
|
al@694
|
1455
|
al@694
|
1456
|
pankso@593
|
1457 search-file|-sf)
|
pankso@12
|
1458 # Search for a file by pattern or name in all files.list.
|
pankso@12
|
1459 if [ -z "$2" ]; then
|
pankso@600
|
1460 newline
|
al@694
|
1461 _ 'Please specify a pattern or file name to search for.'
|
al@694
|
1462 echo "$(_ 'Example:') 'tazpkg search-file libnss'"
|
pankso@600
|
1463 newline
|
pankso@12
|
1464 exit 0
|
pankso@12
|
1465 fi
|
al@813
|
1466 title 'Search result for file "%s"' "$2"
|
al@702
|
1467 TMPLIST=$(mktemp)
|
al@805
|
1468
|
al@805
|
1469 if [ -n "$mirror" ]; then
|
al@805
|
1470 TMPDIR=$(mktemp -d)
|
al@702
|
1471 for i in $PKGS_DB/files.list.lzma $PKGS_DB/undigest/*/files.list.lzma; do
|
al@694
|
1472 [ -f $i ] || continue
|
al@805
|
1473 lzcat $i | awk -F: -vtmp="$TMPLIST" -vdir="$TMPDIR" \
|
al@805
|
1474 -vfile="$2" -vcfile="$(colorize 32 $2)" '
|
al@805
|
1475 BEGIN { efile = gensub("\+", "\\\+", "g", file); }
|
al@805
|
1476 index($2, file) {
|
al@805
|
1477 gsub(efile, cfile, $2);
|
al@805
|
1478 print $2 >> dir"/"$1;
|
al@805
|
1479 printf "1" >> tmp;
|
al@704
|
1480 }'
|
pascal@187
|
1481 done
|
pascal@98
|
1482
|
al@805
|
1483 for pkg in $(cd $TMPDIR; ls); do
|
al@805
|
1484 newline
|
al@805
|
1485 emsg "<c 33>$(_ 'Package %s:' $pkg)</c>"
|
al@805
|
1486 cat $TMPDIR/$pkg
|
al@805
|
1487 done
|
al@805
|
1488
|
al@805
|
1489 rm -r $TMPDIR
|
al@805
|
1490
|
pascal@98
|
1491 else
|
pascal@98
|
1492
|
al@603
|
1493 # Check all pkg files.list in search match which specify the package
|
al@603
|
1494 # name and the full path to the file(s).
|
al@694
|
1495 for pkg in $INSTALLED/*; do
|
al@603
|
1496 if grep -qs "$2" $pkg/files.list; then
|
al@603
|
1497 . $pkg/receipt
|
al@603
|
1498 newline
|
al@813
|
1499 emsg "<c 33>$(_ 'Package %s:' "$PACKAGE")</c>"
|
al@805
|
1500 awk -vtmp="$TMPLIST" -vfile="$2" -vcfile="$(colorize 32 $2)" '
|
al@805
|
1501 BEGIN { efile = gensub("\+", "\\\+", "g", file); }
|
al@805
|
1502 index($0, file) {
|
al@805
|
1503 gsub(efile, cfile);
|
al@704
|
1504 print " "$0;
|
al@805
|
1505 printf "1" >> tmp;
|
al@702
|
1506 }
|
al@704
|
1507 ' $pkg/files.list
|
al@603
|
1508 fi
|
al@603
|
1509 done
|
pascal@98
|
1510
|
pascal@98
|
1511 fi
|
al@702
|
1512
|
al@805
|
1513 num=$(wc -m < $TMPLIST); rm $TMPLIST
|
al@805
|
1514 footer "$(_p '%s file' '%s files' "$num" \
|
al@805
|
1515 "$(colorize 32 $num)")"
|
al@603
|
1516 ;;
|
al@694
|
1517
|
al@694
|
1518
|
al@811
|
1519 search-pkgname|-sp)
|
pankso@344
|
1520 # Search for a package name
|
jozee@318
|
1521 if [ -z "$2" ]; then
|
pankso@600
|
1522 newline
|
al@694
|
1523 _ 'Please specify a pattern or file name to search for.'
|
al@694
|
1524 echo "$(_ 'Example:') 'tazpkg search-pkgname libnss'"
|
pankso@600
|
1525 newline
|
jozee@318
|
1526 exit 0
|
jozee@318
|
1527 fi
|
al@813
|
1528 title 'Search result for package "%s"' "$2"
|
pankso@598
|
1529
|
pankso@503
|
1530 # Search for a file on mirror and output only the package name
|
al@704
|
1531 TMPLIST=$(mktemp)
|
al@704
|
1532 for i in $PKGS_DB/files.list.lzma $PKGS_DB/undigest/*/files.list.lzma; do
|
al@805
|
1533 [ -f "$i" ] || continue
|
al@811
|
1534 lzcat $i | awk -F: -vT=$TMPLIST -vterm="$2" '
|
al@704
|
1535 BEGIN { P = "" }
|
al@811
|
1536 index($2, term) {
|
al@704
|
1537 if ($1 != P) {
|
al@704
|
1538 print $1;
|
al@811
|
1539 printf "1" >> T;
|
al@704
|
1540 P = $1
|
al@704
|
1541 }
|
al@704
|
1542 }'
|
jozee@318
|
1543 done
|
al@704
|
1544 match=$(wc -m < $TMPLIST)
|
al@704
|
1545 rm $TMPLIST
|
al@704
|
1546
|
al@707
|
1547 footer "$(emsg "$(_p \
|
al@707
|
1548 '%s package' '%s packages' $match \
|
al@707
|
1549 "<c 32>$match</c>")")"
|
jozee@318
|
1550 ;;
|
al@694
|
1551
|
al@694
|
1552
|
pankso@504
|
1553 install|-i)
|
pankso@6
|
1554 # Install .tazpkg packages.
|
al@603
|
1555 check_root $@
|
pankso@6
|
1556 check_for_package_on_cmdline
|
pankso@6
|
1557 check_for_package_file
|
al@701
|
1558 check_for_installed_info
|
pankso@598
|
1559
|
al@704
|
1560 if [ -n "$root" ]; then
|
al@704
|
1561 ROOT="$root";
|
al@704
|
1562 check_base_dir "$root"
|
al@704
|
1563 fi
|
al@811
|
1564
|
al@811
|
1565 [ -n "$list" ] && INSTALL_LIST="$list"
|
al@811
|
1566
|
al@811
|
1567 if [ -n "$rootconfig" ]; then # What about this parameter? Is it obsolete?
|
al@811
|
1568 if [ -n "$root" ]; then
|
al@811
|
1569 CACHE_DIR="$root/$CACHE_DIR"
|
al@811
|
1570 SAVE_CACHE_DIR="$CACHE_DIR"
|
al@811
|
1571 PKGS_DB="$root/$PKGS_DB"
|
slaxemulator@487
|
1572 else
|
slaxemulator@487
|
1573 echo "rootconfig needs --root= option used." >&2
|
slaxemulator@487
|
1574 exit 1
|
slaxemulator@487
|
1575 fi
|
slaxemulator@487
|
1576 fi
|
gokhlayeh@436
|
1577
|
gokhlayeh@386
|
1578 # Get repositories priority list.
|
gokhlayeh@386
|
1579 look_for_priority
|
gokhlayeh@436
|
1580
|
pankso@6
|
1581 # Check if forced install.
|
al@704
|
1582 if [ -z "$forced" ]; then
|
pascal@121
|
1583 check_for_installed_package $ROOT
|
pankso@6
|
1584 fi
|
gokhlayeh@356
|
1585 install_package $ROOT
|
slaxemulator@369
|
1586 update_desktop_database $ROOT
|
pankso@598
|
1587 update_mime_database $ROOT
|
pankso@598
|
1588 update_icon_database $ROOT
|
al@704
|
1589 compile_glib_schemas $ROOT
|
al@704
|
1590 ;;
|
al@694
|
1591
|
al@694
|
1592
|
erjo@59
|
1593 install-list|get-install-list)
|
pankso@6
|
1594 # Install a set of packages from a list.
|
al@603
|
1595 check_root $@
|
al@811
|
1596
|
pankso@6
|
1597 if [ -z "$2" ]; then
|
pankso@600
|
1598 newline
|
al@704
|
1599 longline "$(_ \
|
al@704
|
1600 "Please change directory (cd) to the packages repository and specify the \
|
al@704
|
1601 list of packages to install.")"
|
al@704
|
1602 echo "$(_ 'Example:') $(emsg '<b>tazpkg install-list</b> <c 33>packages.list</c>')"
|
al@694
|
1603 exit 0
|
pankso@6
|
1604 fi
|
al@704
|
1605
|
pankso@6
|
1606 # Check if the packages list exist.
|
al@704
|
1607 if [ ! -f "$2" ]; then
|
al@704
|
1608 _ 'Unable to find list "%s"' "$2"
|
pankso@6
|
1609 exit 0
|
pankso@6
|
1610 fi
|
pankso@279
|
1611
|
al@704
|
1612 LIST=$(cat $2)
|
al@704
|
1613
|
pascal@120
|
1614 # Remember processed list
|
pascal@121
|
1615 export INSTALL_LIST="$2"
|
pascal@120
|
1616
|
erjo@59
|
1617 # Set $COMMAND and install all packages.
|
al@704
|
1618 COMMAND=${1%-list}
|
al@704
|
1619
|
pascal@121
|
1620 touch $2-processed
|
pascal@314
|
1621
|
pascal@314
|
1622 # Upgrade tazpkg first. It may handle new features/formats...
|
pascal@340
|
1623 # then upgrade essential packages early
|
pascal@341
|
1624 for pkg in busybox-pam busybox gcc-lib-base glibc-base \
|
al@704
|
1625 slitaz-base-files tazpkg ; do
|
pascal@341
|
1626 pkg=$(egrep $pkg-[0-9] $INSTALL_LIST)
|
al@704
|
1627 [ -z "$pkg" ] && continue
|
al@704
|
1628 _ 'Adding implicit depends "%s"...' $pkg
|
al@811
|
1629 LIST="$pkg"$'\n'"$LIST"
|
pascal@340
|
1630 done
|
pascal@314
|
1631
|
al@694
|
1632 for pkg in $LIST; do
|
pascal@121
|
1633 grep -qs ^$pkg$ $2-processed && continue
|
mojo@735
|
1634 [ -d "$root/var/lib/tazpkg/installed" ] &&
|
pankso@660
|
1635 tazpkg $COMMAND $pkg --list="$2" "$3" "$4" "$5"
|
pankso@6
|
1636 done
|
pankso@309
|
1637 rm -f $2-processed ;;
|
al@694
|
1638
|
al@694
|
1639
|
pankso@76
|
1640 add-flavor)
|
pascal@74
|
1641 # Install a set of packages from a flavor.
|
pankso@309
|
1642 install_flavor $2 ;;
|
al@694
|
1643
|
al@694
|
1644
|
pankso@76
|
1645 install-flavor)
|
pascal@74
|
1646 # Install a set of packages from a flavor and purge other ones.
|
pankso@309
|
1647 install_flavor $2 --purge ;;
|
al@694
|
1648
|
al@694
|
1649
|
pankso@76
|
1650 set-release)
|
paul@662
|
1651 # Change current release and upgrade packages.
|
al@811
|
1652 RELEASE="$2"
|
pankso@76
|
1653 if [ -z "$RELEASE" ]; then
|
pankso@600
|
1654 newline
|
al@694
|
1655 _ 'Please specify the release you want on the command line.'
|
al@694
|
1656 echo "$(_ 'Example:') tazpkg set-release cooking"
|
pankso@600
|
1657 newline
|
pankso@76
|
1658 exit 0
|
pankso@76
|
1659 fi
|
al@700
|
1660 rm $PKGS_DB/mirror
|
pascal@74
|
1661 echo "$RELEASE" > /etc/slitaz-release
|
pascal@74
|
1662 tazpkg recharge && tazpkg upgrade
|
pascal@222
|
1663
|
pascal@222
|
1664 # Install missing depends
|
pascal@222
|
1665 cd $INSTALLED
|
pascal@222
|
1666 for i in * ; do
|
al@811
|
1667 DEPENDS=''
|
pascal@222
|
1668 . $i/receipt
|
pascal@222
|
1669 for j in $DEPENDS ; do
|
pascal@222
|
1670 [ -d $j ] || tazpkg get-install $j
|
pascal@222
|
1671 done
|
pankso@309
|
1672 done ;;
|
al@694
|
1673
|
al@694
|
1674
|
pankso@504
|
1675 remove|-r)
|
pankso@6
|
1676 # Remove packages.
|
al@603
|
1677 check_root $@
|
pankso@6
|
1678 check_for_package_on_cmdline
|
al@701
|
1679 check_for_installed_info
|
pankso@598
|
1680
|
al@694
|
1681 [ -n "$root" ] && ROOT="$root"
|
al@795
|
1682
|
slaxemulator@370
|
1683 if [ ! -f "$ROOT$INSTALLED/$PACKAGE/receipt" ]; then
|
al@813
|
1684 newline; _ 'Package "%s" is not installed.' "$PACKAGE"
|
pankso@6
|
1685 exit 0
|
pankso@6
|
1686 fi
|
al@795
|
1687
|
al@813
|
1688 . "$ROOT$INSTALLED/$PACKAGE/receipt"
|
al@795
|
1689
|
al@795
|
1690 # Info #1: dependent packages (to be processed later)
|
al@795
|
1691 ALTERED="$(awk -F$'\t' -vp=" $PACKAGE " '
|
al@795
|
1692 index(" " $8 " ", p) { printf " %s\n", $1 }
|
al@795
|
1693 ' $ROOT/$PKGS_DB/installed.info)"
|
al@795
|
1694
|
pascal@30
|
1695 if [ -n "$ALTERED" ]; then
|
al@813
|
1696 _ 'The following packages depend on package "%s":' "$PACKAGE"
|
al@795
|
1697 echo "$ALTERED"
|
pascal@30
|
1698 fi
|
al@795
|
1699
|
al@795
|
1700 # Info #2: changed packages (to be processed later)
|
al@813
|
1701 REFRESH=$(cd $ROOT$INSTALLED ; grep -sl "^$PACKAGE$" */modifiers)
|
al@795
|
1702
|
pascal@163
|
1703 if [ -n "$REFRESH" ]; then
|
al@813
|
1704 _ 'The following packages have been modified by package "%s":' "$PACKAGE"
|
pascal@163
|
1705 for i in $REFRESH; do
|
pascal@170
|
1706 echo " ${i%/modifiers}"
|
pascal@163
|
1707 done
|
pascal@163
|
1708 fi
|
al@795
|
1709
|
al@795
|
1710 # Confirmation
|
al@795
|
1711 if im && [ -z "$auto" ]; then
|
al@813
|
1712 confirm "$(_ 'Remove package "%s" (%s)? (y/N)' "$PACKAGE" "$VERSION$EXTRAVERSION")"
|
al@813
|
1713 if [ "$?" -ne 0 ]; then
|
al@813
|
1714 newline; _ 'Uninstallation of package "%s" cancelled.' "$PACKAGE"
|
al@795
|
1715 exit 0
|
al@795
|
1716 fi
|
al@795
|
1717 fi
|
al@795
|
1718 # We are here: non-interactive mode, or --auto, or answer 'y'
|
al@795
|
1719
|
al@795
|
1720 # Removing package
|
al@813
|
1721 title 'Removing package "%s"' "$PACKAGE"
|
al@795
|
1722
|
al@795
|
1723 # [1/4] Pre-remove commands
|
al@813
|
1724 if grep -q ^pre_remove "$ROOT$INSTALLED/$PACKAGE/receipt"; then
|
al@795
|
1725 action "Execution of pre-remove commands..."
|
al@795
|
1726 pre_remove $ROOT
|
al@795
|
1727 status
|
al@795
|
1728 fi
|
al@795
|
1729
|
al@795
|
1730 # [2/4] Removing files
|
al@795
|
1731 action "Removing all files installed..."
|
al@813
|
1732 if [ -f "$ROOT$INSTALLED/$PACKAGE/modifiers" ]; then
|
al@813
|
1733 for file in $(cat "$ROOT$INSTALLED/$PACKAGE/files.list"); do
|
al@813
|
1734 for mod in $(cat "$ROOT$INSTALLED/$PACKAGE/modifiers"); do
|
al@813
|
1735 [ -f "$ROOT$INSTALLED/$mod/files.list" ] && \
|
al@795
|
1736 [ $(grep "^$(echo $file | grepesc)$" $ROOT$INSTALLED/$mod/files.list | wc -l) -gt 1 ] && \
|
al@795
|
1737 continue 2
|
al@795
|
1738 done
|
al@795
|
1739 remove_with_path $ROOT$file
|
al@795
|
1740 done
|
gokhlayeh@423
|
1741 else
|
al@813
|
1742 for file in $(cat "$ROOT$INSTALLED/$PACKAGE/files.list"); do
|
al@795
|
1743 remove_with_path $ROOT$file
|
al@795
|
1744 done
|
gokhlayeh@423
|
1745 fi
|
al@795
|
1746 status
|
al@795
|
1747
|
al@795
|
1748 # [3/4] Post-remove commands
|
al@813
|
1749 if grep -q ^post_remove "$ROOT$INSTALLED/$PACKAGE/receipt"; then
|
al@813
|
1750 action 'Execution of post-remove commands...'
|
al@795
|
1751 post_remove $ROOT
|
al@795
|
1752 status
|
al@795
|
1753 fi
|
al@795
|
1754
|
al@795
|
1755 # [4/4] Remove package receipt and remove it from databases
|
al@813
|
1756 action 'Removing package receipt...'
|
al@813
|
1757 rm -rf "$ROOT$INSTALLED/$PACKAGE"
|
al@795
|
1758 sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION.tazpkg$/d" $PKGS_DB/installed.$SUM
|
al@795
|
1759 sed -i "/^$PACKAGE /d" $PKGS_DB/installed.info
|
al@795
|
1760 status
|
al@795
|
1761
|
al@813
|
1762 footer "$(_ 'Package "%s" (%s) removed.' "$PACKAGE" "$VERSION$EXTRAVERSION")"
|
al@795
|
1763
|
al@795
|
1764 # Log this activity
|
al@795
|
1765 log_pkg Removed
|
al@795
|
1766
|
al@795
|
1767 # Stop if non-interactive mode and no --auto option
|
al@795
|
1768 if ! im && [ -z "$auto" ]; then exit 0; fi
|
al@795
|
1769
|
al@795
|
1770 # Process dependent packages
|
al@795
|
1771 if [ -n "$ALTERED" ]; then
|
al@811
|
1772 if [ -n "$auto" ]; then
|
al@795
|
1773 answer=0
|
al@795
|
1774 else
|
al@813
|
1775 confirm "$(_ 'Remove packages depending on package "%s"? (y/N)' "$PACKAGE")"
|
al@795
|
1776 answer=$?
|
pankso@38
|
1777 fi
|
al@813
|
1778 if [ "$answer" -eq 0 ]; then
|
al@795
|
1779 for i in $ALTERED; do
|
al@795
|
1780 if [ -d "$ROOT$INSTALLED/$i" ]; then
|
al@795
|
1781 echo "tazpkg remove $i $ROOTOPTS"
|
al@795
|
1782 fi
|
pascal@255
|
1783 done
|
pascal@255
|
1784 fi
|
al@795
|
1785 fi
|
al@795
|
1786
|
al@795
|
1787 # Process changed packages
|
al@795
|
1788 if [ -n "$REFRESH" ]; then
|
al@811
|
1789 if [ -n "$auto" ]; then
|
al@795
|
1790 answer=0
|
al@795
|
1791 else
|
al@813
|
1792 confirm "$(_ 'Reinstall packages modified by package "%s"? (y/N)' "$PACKAGE")"
|
al@795
|
1793 answer=$?
|
pankso@51
|
1794 fi
|
al@813
|
1795 if [ "$answer" -eq 0 ]; then
|
al@795
|
1796 for i in $REFRESH; do
|
al@813
|
1797 if [ "$(wc -l < $ROOT$INSTALLED/$i)" -gt 1 ]; then
|
al@795
|
1798 _ 'Check %s for reinstallation' "$INSTALLED/$i"
|
al@795
|
1799 continue
|
al@795
|
1800 fi
|
mojo@810
|
1801 rm -r $ROOT$INSTALLED/$i
|
mojo@810
|
1802 tazpkg get-install ${i%/modifiers} $ROOTOPTS --forced
|
al@795
|
1803 done
|
pascal@30
|
1804 fi
|
pankso@6
|
1805 fi
|
al@795
|
1806
|
al@795
|
1807 ;;
|
al@694
|
1808
|
al@694
|
1809
|
pankso@600
|
1810 extract|-e)
|
pankso@6
|
1811 # Extract .tazpkg cpio archive into a directory.
|
pankso@6
|
1812 check_for_package_on_cmdline
|
pankso@6
|
1813 check_for_package_file
|
al@811
|
1814 title 'Extracting package "%s"' "$PACKAGE"
|
al@694
|
1815
|
MikeDSmith25@135
|
1816 # If no directory destination is found on the cmdline
|
MikeDSmith25@135
|
1817 # we create one in the current dir using the package name.
|
pankso@6
|
1818 if [ -n "$TARGET_DIR" ]; then
|
al@811
|
1819 DESTDIR="$TARGET_DIR/$PACKAGE"
|
pankso@6
|
1820 else
|
al@811
|
1821 DESTDIR="$PACKAGE"
|
pankso@6
|
1822 fi
|
pankso@6
|
1823 mkdir -p $DESTDIR
|
al@694
|
1824
|
al@813
|
1825 action 'Copying original package...'
|
al@813
|
1826 cp "$PACKAGE_FILE" $DESTDIR
|
pankso@6
|
1827 status
|
al@694
|
1828
|
pankso@6
|
1829 cd $DESTDIR
|
pankso@6
|
1830 extract_package
|
al@704
|
1831 [ -e "receipt" ] && \
|
al@813
|
1832 footer "$(_ 'Package "%s" is extracted to "%s"' "$PACKAGE" "$DESTDIR")"
|
al@603
|
1833 ;;
|
al@694
|
1834
|
al@694
|
1835
|
pascal@297
|
1836 recompress)
|
pascal@297
|
1837 # Recompress .tazpkg cpio archive with lzma.
|
pascal@297
|
1838 check_for_package_on_cmdline
|
pascal@297
|
1839 check_for_package_file
|
al@811
|
1840 title 'Recompressing package "%s"' "$PACKAGE"
|
pascal@297
|
1841 mkdir -p $TMP_DIR
|
al@694
|
1842
|
al@603
|
1843 action "Copying original package..."
|
al@813
|
1844 cp "$PACKAGE_FILE" $TMP_DIR
|
pascal@297
|
1845 status
|
al@694
|
1846
|
pascal@297
|
1847 cd $TMP_DIR
|
pascal@297
|
1848 extract_package
|
al@694
|
1849
|
al@707
|
1850 action "Recompressing the FS..."
|
pascal@809
|
1851 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
|
pascal@297
|
1852 rm -rf fs
|
pascal@297
|
1853 status
|
al@694
|
1854
|
al@603
|
1855 action "Creating new package..."
|
gokhlayeh@383
|
1856 find . -print | cpio -o -H newc --quiet > \
|
al@813
|
1857 "$TOP_DIR/$(basename "$PACKAGE_FILE").$$" && mv -f \
|
al@813
|
1858 "$TOP_DIR/$(basename "$PACKAGE_FILE").$$" \
|
al@813
|
1859 "$TOP_DIR/$(basename "$PACKAGE_FILE")"
|
pascal@297
|
1860 status
|
al@694
|
1861
|
al@813
|
1862 cd "$TOP_DIR"
|
al@603
|
1863 rm -rf $TMP_DIR
|
al@603
|
1864 separator; newline ;;
|
al@694
|
1865
|
al@694
|
1866
|
pascal@139
|
1867 repack-config)
|
al@811
|
1868 check_root $@
|
pascal@137
|
1869 # Create SliTaz package archive from configuration files.
|
al@707
|
1870 mkdir -p $TMP_DIR; cd $TMP_DIR
|
al@811
|
1871 CONFIG_VERSION='1.0'
|
pascal@137
|
1872 mkdir config-$CONFIG_VERSION
|
pascal@137
|
1873 cd config-$CONFIG_VERSION
|
pankso@279
|
1874 for i in $INSTALLED/*/volatile.cpio.gz; do
|
gokhlayeh@383
|
1875 zcat $i | cpio -t --quiet
|
pascal@137
|
1876 done > files.list
|
pascal@137
|
1877 mkdir fs
|
pascal@137
|
1878 cd fs
|
gokhlayeh@416
|
1879 ( cd / ; cpio -o -H newc --quiet ) < ../files.list | cpio -idm --quiet > /dev/null
|
pascal@137
|
1880 mkdir -p etc/tazlito
|
pankso@279
|
1881 for i in $INSTALLED/*/receipt; do
|
al@811
|
1882 EXTRAVERSION=''
|
pascal@137
|
1883 . $i
|
pascal@137
|
1884 echo "$PACKAGE-$VERSION$EXTRAVERSION"
|
pascal@137
|
1885 done > etc/tazlito/config-packages.list
|
pascal@137
|
1886 cd ..
|
pascal@137
|
1887 echo "etc/tazlito/config-packages.list" >> files.list
|
al@603
|
1888 pkg_date=$(date +"%x %X")
|
pascal@137
|
1889 cat > receipt <<EOT
|
pascal@137
|
1890 # SliTaz package receipt.
|
pascal@137
|
1891
|
pascal@137
|
1892 PACKAGE="config"
|
pascal@137
|
1893 VERSION="$CONFIG_VERSION"
|
pascal@137
|
1894 CATEGORY="base-system"
|
al@707
|
1895 SHORT_DESC="$(_n 'User configuration backup on date %s' $pkg_date)"
|
pascal@137
|
1896 DEPENDS="$(ls $INSTALLED)"
|
pascal@137
|
1897 EOT
|
pascal@137
|
1898 cd ..
|
pascal@137
|
1899 tazpkg pack config-$CONFIG_VERSION
|
al@813
|
1900 cp config-$CONFIG_VERSION.tazpkg "$TOP_DIR"
|
al@813
|
1901 cd "$TOP_DIR"
|
pascal@137
|
1902 rm -rf $TMP_DIR
|
pascal@137
|
1903 ;;
|
al@694
|
1904
|
al@694
|
1905
|
pascal@18
|
1906 repack)
|
MikeDSmith25@135
|
1907 # Create SliTaz package archive from an installed package.
|
pascal@18
|
1908 check_for_package_on_cmdline
|
pascal@18
|
1909 check_for_receipt
|
al@811
|
1910 EXTRAVERSION=''
|
al@813
|
1911 . "$INSTALLED/$PACKAGE/receipt"
|
al@707
|
1912 title 'Repacking "%s"' "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg"
|
al@707
|
1913
|
al@813
|
1914 if grep -qs ^NO_REPACK= "$INSTALLED/$PACKAGE/receipt"; then
|
al@813
|
1915 _ "Can't repack package \"%s\"" "$PACKAGE"
|
pascal@24
|
1916 exit 1
|
pascal@24
|
1917 fi
|
al@707
|
1918
|
al@813
|
1919 if [ -s "$INSTALLED/$PACKAGE/modifiers" ]; then
|
al@813
|
1920 _ "Can't repack, \"%s\" files have been modified by:" "$PACKAGE"
|
al@813
|
1921 for i in $(cat "$INSTALLED/$PACKAGE/modifiers"); do
|
pascal@21
|
1922 echo " $i"
|
pascal@21
|
1923 done
|
pascal@21
|
1924 exit 1
|
pascal@21
|
1925 fi
|
al@707
|
1926
|
al@811
|
1927 MISSING=''
|
pascal@63
|
1928 while read i; do
|
pascal@18
|
1929 [ -e "$i" ] && continue
|
pascal@63
|
1930 [ -L "$i" ] || MISSING="$MISSING\n $i"
|
al@813
|
1931 done < "$INSTALLED/$PACKAGE/files.list"
|
pascal@18
|
1932 if [ -n "$MISSING" ]; then
|
al@694
|
1933 _n "Can't repack, the following files are lost:"
|
pascal@63
|
1934 echo -e "$MISSING"
|
pascal@18
|
1935 exit 1
|
pascal@18
|
1936 fi
|
al@707
|
1937
|
al@707
|
1938 mkdir -p $TMP_DIR; cd $TMP_DIR
|
pascal@298
|
1939 FILES="fs.cpio.lzma\n"
|
al@813
|
1940 for i in $(ls "$INSTALLED/$PACKAGE"); do
|
al@707
|
1941 case $i in
|
al@707
|
1942 volatile.cpio.gz|modifiers) ;;
|
al@813
|
1943 *) cp "$INSTALLED/$PACKAGE/$i" .; FILES="$FILES$i\n" ;;
|
al@707
|
1944 esac
|
pascal@24
|
1945 done
|
al@707
|
1946
|
pascal@72
|
1947 ln -s / rootfs
|
pascal@72
|
1948 mkdir tmp
|
al@707
|
1949 sed 's/^/rootfs/' < files.list | cpio -o -H newc --quiet | \
|
al@707
|
1950 { cd tmp ; cpio -idm --quiet >/dev/null; cd ..; }
|
pascal@72
|
1951 mv tmp/rootfs fs
|
al@707
|
1952
|
al@813
|
1953 if [ -f "$INSTALLED/$PACKAGE/volatile.cpio.gz" ]; then
|
al@813
|
1954 zcat "$INSTALLED/$PACKAGE/volatile.cpio.gz" | \
|
gokhlayeh@416
|
1955 { cd fs; cpio -idm --quiet; cd ..; }
|
pascal@145
|
1956 fi
|
al@707
|
1957
|
al@813
|
1958 if fgrep -q repack_cleanup "$INSTALLED/$PACKAGE/receipt"; then
|
al@813
|
1959 . "$INSTALLED/$PACKAGE/receipt"
|
pascal@107
|
1960 repack_cleanup fs
|
pascal@107
|
1961 fi
|
al@707
|
1962
|
al@813
|
1963 if [ -f "$INSTALLED/$PACKAGE/$CHECKSUM" ]; then
|
al@813
|
1964 sed 's, , fs,' < "$INSTALLED/$PACKAGE/$CHECKSUM" | \
|
slaxemulator@588
|
1965 $CHECKSUM -s -c || {
|
al@811
|
1966 _ "Can't repack, %s error." "$CHECKSUM"
|
al@813
|
1967 cd "$TOP_DIR"
|
pascal@214
|
1968 rm -rf $TMP_DIR
|
pascal@107
|
1969 exit 1
|
pascal@214
|
1970 }
|
pascal@107
|
1971 fi
|
al@707
|
1972
|
gokhlayeh@383
|
1973 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
|
gokhlayeh@383
|
1974 echo -e "$FILES" | cpio -o -H newc --quiet > \
|
al@813
|
1975 "$TOP_DIR/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg"
|
al@813
|
1976 cd "$TOP_DIR"
|
pascal@18
|
1977 \rm -R $TMP_DIR
|
al@813
|
1978 _ 'Package "%s" repacked successfully.' "$PACKAGE"
|
al@813
|
1979 _ 'Size: %s' "$(du -sh "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg")"
|
al@813
|
1980 newline
|
al@813
|
1981 ;;
|
al@694
|
1982
|
al@694
|
1983
|
pankso@6
|
1984 pack)
|
pankso@600
|
1985 # Create SliTaz package archive using cpio and lzma.
|
pankso@600
|
1986 # TODO: Cook also pack packages, we should share code in libpkg.sh
|
pankso@6
|
1987 check_for_package_on_cmdline
|
al@813
|
1988 cd "$PACKAGE"
|
al@811
|
1989 if [ ! -f 'receipt' ]; then
|
al@694
|
1990 _ 'Receipt is missing. Please read the documentation.'
|
pankso@6
|
1991 exit 0
|
al@747
|
1992 fi
|
al@747
|
1993
|
al@813
|
1994 title 'Packing package "%s"' "$PACKAGE"
|
al@747
|
1995 # Create files.list with redirecting find outpout.
|
al@747
|
1996
|
al@811
|
1997 action 'Creating the list of files...'
|
al@747
|
1998 cd fs
|
al@747
|
1999 find . -type f -print > ../files.list
|
al@747
|
2000 find . -type l -print >> ../files.list
|
al@811
|
2001 cd ..; sed -i s/'^.'/''/ files.list
|
al@747
|
2002 status
|
al@747
|
2003
|
al@813
|
2004 action 'Creating %s of files...' "$CHECKSUM"
|
al@747
|
2005 while read file; do
|
al@747
|
2006 [ -L "fs$file" ] && continue
|
al@747
|
2007 [ -f "fs$file" ] || continue
|
al@747
|
2008 case "$file" in
|
al@747
|
2009 /lib/modules/*/modules.*|*.pyc) continue;;
|
al@747
|
2010 esac
|
al@747
|
2011 $CHECKSUM "fs$file" | sed 's/ fs/ /'
|
al@747
|
2012 done < files.list > $CHECKSUM
|
al@747
|
2013 status
|
al@747
|
2014
|
al@747
|
2015 UNPACKED_SIZE=$(du -chs fs receipt files.list $CHECKSUM \
|
al@811
|
2016 description.txt 2>/dev/null | awk 'END { print $1 }')
|
al@811
|
2017
|
al@747
|
2018 # Build cpio archives.
|
al@747
|
2019 action "Compressing the FS..."
|
pascal@809
|
2020 find fs | cpio -o -H newc --quiet | case "$TAZPKG_PACK" in
|
pascal@809
|
2021 gzip) gzip -9 > fs.cpio.gz ;;
|
pascal@809
|
2022 *) lzma e fs.cpio.lzma -si ;;
|
pascal@809
|
2023 esac
|
al@747
|
2024 rm -rf fs
|
al@747
|
2025 status
|
al@747
|
2026
|
al@747
|
2027 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
|
al@811
|
2028 $CHECKSUM description.txt 2>/dev/null | awk 'END { print $1 }')
|
al@747
|
2029
|
al@747
|
2030 action "Updating receipt sizes..."
|
al@747
|
2031 sed -i s/^PACKED_SIZE.*$// receipt
|
al@747
|
2032 sed -i s/^UNPACKED_SIZE.*$// receipt
|
al@747
|
2033 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
|
al@747
|
2034 status
|
al@747
|
2035
|
al@747
|
2036 action "Creating full cpio archive..."
|
al@813
|
2037 find . -print | cpio -o -H newc --quiet > "../$PACKAGE.tazpkg"
|
al@747
|
2038 status
|
al@747
|
2039
|
al@747
|
2040 action "Restoring original package tree..."
|
pascal@816
|
2041 unlzma < fs.cpio.lzma | cpio -idm --quiet
|
al@747
|
2042 status
|
al@747
|
2043
|
al@747
|
2044 rm fs.cpio.lzma && cd ..
|
al@813
|
2045 footer "$(_ 'Package "%s" compressed successfully.' "$PACKAGE")"
|
al@813
|
2046 _ 'Size: %s' "$(ls -lh "$PACKAGE.tazpkg" | awk '{print $5}')"
|
al@747
|
2047 ;;
|
al@694
|
2048
|
al@694
|
2049
|
pankso@6
|
2050 recharge)
|
al@803
|
2051 # Recharge packages databases from a mirror.
|
pankso@581
|
2052 #
|
al@694
|
2053 # WARNING: The 'mirrors' file has all SliTaz mirrors but 'mirror'
|
paul@607
|
2054 # must have only the chosen main mirror.
|
pankso@581
|
2055 #
|
al@603
|
2056 check_root $@
|
al@834
|
2057 @@MODULES@@/recharge $2
|
al@834
|
2058 ;;
|
al@694
|
2059
|
al@694
|
2060
|
al@603
|
2061 help-up)
|
al@603
|
2062 # Options available for the command: up
|
al@603
|
2063 newline; usage_up; newline
|
pankso@645
|
2064 exit 1 ;;
|
al@694
|
2065
|
al@694
|
2066
|
al@603
|
2067 up|upgrade)
|
al@836
|
2068 check_root $@
|
pankso@466
|
2069 #
|
paul@476
|
2070 # This is the new way to upgrade packages making 'upgrade' and
|
pankso@466
|
2071 # upgradeable out-of-date. This new way is much, much more faster!
|
paul@476
|
2072 # Look into installed packages and get data from receipt, it is fast
|
paul@476
|
2073 # and easy to handle vars after using only md5sum to compare packages
|
pankso@598
|
2074 #
|
al@691
|
2075 for opt in $@; do
|
pankso@466
|
2076 case "$opt" in
|
al@836
|
2077 -i) export install='yes';;
|
al@836
|
2078 -c) export check='yes';;
|
pankso@466
|
2079 esac
|
pankso@466
|
2080 done
|
al@834
|
2081
|
al@836
|
2082 @@MODULES@@/upgrade
|
al@834
|
2083 ;;
|
al@694
|
2084
|
al@694
|
2085
|
pascal@152
|
2086 bugs)
|
pascal@152
|
2087 # Show known bugs in package(s)
|
pascal@152
|
2088 cd $INSTALLED
|
pascal@159
|
2089 shift
|
pascal@159
|
2090 LIST=$@
|
al@804
|
2091 [ -z "$LIST" ] && LIST=$(ls)
|
al@694
|
2092 MSG=$(_n 'No known bugs.')
|
al@804
|
2093
|
al@804
|
2094 title 'Known bugs in packages'
|
pascal@152
|
2095 for PACKAGE in $LIST; do
|
al@804
|
2096 BUGS=''
|
al@804
|
2097 EXTRAVERSION=''
|
al@813
|
2098 . "$PACKAGE/receipt"
|
pascal@152
|
2099 if [ -n "$BUGS" ]; then
|
al@694
|
2100 MSG=$(_n 'Bug list completed')
|
pankso@600
|
2101 newline
|
al@813
|
2102 _ 'Bugs in package "%s" version %s:' "$PACKAGE" "$VERSION$EXTRAVERSION"
|
pascal@152
|
2103 cat <<EOT
|
pascal@152
|
2104 $BUGS
|
pascal@152
|
2105 EOT
|
pascal@152
|
2106 fi
|
pascal@152
|
2107 done
|
al@804
|
2108 footer "$MSG" ;;
|
al@694
|
2109
|
al@694
|
2110
|
pascal@25
|
2111 check)
|
MikeDSmith25@135
|
2112 # Check installed packages set.
|
al@811
|
2113 #check_root $@
|
pankso@598
|
2114
|
gokhlayeh@386
|
2115 # Get repositories priority list.
|
gokhlayeh@386
|
2116 look_for_priority
|
pankso@598
|
2117
|
pascal@25
|
2118 cd $INSTALLED
|
al@834
|
2119 if [ -z "$2" -o -n "$full" ]; then PACKAGES="$(ls)"; else PACKAGES="$2"; fi
|
al@811
|
2120 PACKAGE_PRINTED=''
|
al@811
|
2121
|
al@811
|
2122 for PACKAGE in $PACKAGES; do
|
al@811
|
2123
|
al@811
|
2124 if [ ! -f "$PACKAGE/receipt" ]; then
|
al@811
|
2125 print_pkgname
|
al@811
|
2126 _ 'The package installation has not completed'
|
pascal@122
|
2127 continue
|
pascal@122
|
2128 fi
|
al@707
|
2129
|
al@811
|
2130 DEPENDS=''
|
al@811
|
2131 EXTRAVERSION=''
|
al@813
|
2132 . "$PACKAGE/receipt"
|
al@813
|
2133 if [ -s "$PACKAGE/modifiers" ]; then
|
al@811
|
2134 print_pkgname
|
al@811
|
2135 _ 'The package has been modified by:'
|
al@813
|
2136 awk '{print " " $0}' "$PACKAGE/modifiers"
|
pascal@29
|
2137 fi
|
al@707
|
2138
|
al@811
|
2139 MSG="$(_n 'Files lost from package:')\n"
|
pascal@25
|
2140 while read file; do
|
pascal@25
|
2141 [ -e "$file" ] && continue
|
pascal@25
|
2142 if [ -L "$file" ]; then
|
al@694
|
2143 MSG="$MSG $(_n 'target of symlink')"
|
pascal@25
|
2144 fi
|
al@811
|
2145 print_pkgname
|
pascal@25
|
2146 echo -e "$MSG $file"
|
al@811
|
2147 MSG=''
|
al@813
|
2148 done < "$PACKAGE/files.list"
|
al@707
|
2149
|
al@811
|
2150 MSG="$(_n 'Missing dependencies for package:')\n"
|
pascal@25
|
2151 for i in $DEPENDS; do
|
pascal@25
|
2152 [ -d $i ] && continue
|
pascal@290
|
2153 [ -d $(equivalent_pkg $i) ] && continue
|
al@811
|
2154 print_pkgname
|
pascal@25
|
2155 echo -e "$MSG $i"
|
al@811
|
2156 MSG=''
|
pascal@25
|
2157 done
|
al@707
|
2158
|
al@811
|
2159 MSG="$(_n 'Dependencies loop between package and:')\n"
|
al@811
|
2160 ALL_DEPS=''
|
al@813
|
2161 check_for_deps_loop "$PACKAGE" "$DEPENDS"
|
pascal@25
|
2162 done
|
al@811
|
2163 [ -n "$PACKAGE_PRINTED" ] && footer
|
al@694
|
2164
|
al@694
|
2165 _ 'Looking for known bugs...'
|
al@834
|
2166 if [ -z "$2" -o -n "$full" ]; then tazpkg bugs; else tazpkg bugs "$2"; fi
|
al@811
|
2167
|
al@811
|
2168
|
al@811
|
2169 if [ -n "$full" ]; then
|
al@707
|
2170 separator
|
al@707
|
2171
|
al@811
|
2172 title 'Mismatch checksum of installed files:'
|
al@811
|
2173
|
al@811
|
2174 for PACKAGE in $PACKAGES; do
|
al@811
|
2175 file="$PACKAGE/$CHECKSUM"
|
al@811
|
2176 CONFIG_FILES=''
|
al@813
|
2177 . "$PACKAGE/receipt"
|
pascal@106
|
2178 [ -s "$file" ] || continue
|
pascal@177
|
2179 while read md5 f; do
|
pascal@177
|
2180 [ -f $f ] || continue
|
pascal@177
|
2181 for i in $CONFIG_FILES; do
|
pascal@177
|
2182 case "$f" in
|
al@694
|
2183 $i|$i/*) continue 2;;
|
pascal@177
|
2184 esac
|
pascal@177
|
2185 done
|
pascal@177
|
2186 echo "$md5 $f"
|
al@811
|
2187 done < "$file" | busybox $CHECKSUM -c - 2>/dev/null | \
|
al@811
|
2188 grep -v OK$ | sed "s/: FAILED$//"
|
pascal@106
|
2189 done
|
al@811
|
2190 footer
|
al@811
|
2191
|
al@811
|
2192 title 'Check file providers:'
|
al@811
|
2193 FILES=' '
|
al@811
|
2194 for PACKAGE in $PACKAGES; do
|
al@813
|
2195 for file in $(cat "$PACKAGE/files.list"); do
|
al@811
|
2196 [ -d "$file" ] && continue
|
al@811
|
2197 case "$FILES" in
|
al@811
|
2198 *\ $file\ *) continue;;
|
al@811
|
2199 esac
|
al@811
|
2200 [ $(grep "^$(echo $file | grepesc)$" */files.list 2> /dev/null | \
|
al@811
|
2201 wc -l) -gt 1 ] || continue
|
al@811
|
2202 FILES="$FILES$file "
|
pankso@600
|
2203 newline
|
al@811
|
2204 _ 'The following packages provide file "%s":' $file
|
al@811
|
2205 grep -l "^$(echo $file | grepesc)$" */files.list | \
|
al@811
|
2206 while read f; do
|
al@811
|
2207 pkg=${f%/files.list}
|
al@811
|
2208 if [ -f $pkg/modifiers ]; then
|
al@811
|
2209 overriders=$(_n '(overridden by %s)' "$(tr '\n' ' ' < $pkg/modifiers | sed 's| $||')")
|
al@811
|
2210 else
|
al@811
|
2211 overriders=''
|
al@811
|
2212 fi
|
al@811
|
2213 echo -n " * $pkg $overriders"
|
al@811
|
2214 newline
|
al@811
|
2215 done
|
pascal@60
|
2216 done
|
pascal@60
|
2217 done
|
al@811
|
2218 footer
|
al@811
|
2219
|
al@834
|
2220 if [ -n "$full" ]; then
|
al@811
|
2221 title 'Alien files:'
|
al@811
|
2222 MSG="$(_n 'No package has installed the following files:')\n"
|
al@811
|
2223 find /etc /bin /sbin /lib /usr /var/www -not -type d 2>/dev/null | \
|
al@811
|
2224 while read file; do
|
al@811
|
2225 case "$file" in *\[*) continue;; esac
|
al@811
|
2226 grep -q "^$(echo $file | grepesc)$" */files.list && continue
|
al@811
|
2227 echo -e "$MSG $file"
|
al@811
|
2228 MSG=''
|
al@811
|
2229 done
|
al@811
|
2230 footer
|
al@811
|
2231 fi
|
pascal@60
|
2232 fi
|
al@811
|
2233 _ 'Check completed.'; newline ;;
|
al@694
|
2234
|
al@694
|
2235
|
al@785
|
2236 block|-b)
|
pankso@10
|
2237 # Add a pkg name to the list of blocked packages.
|
al@603
|
2238 check_root $@
|
pankso@10
|
2239 check_for_package_on_cmdline
|
pankso@600
|
2240 newline
|
al@813
|
2241 if [ ! -d "$INSTALLED/$PACKAGE" ]; then
|
al@813
|
2242 _ 'Package "%s" is not installed.' "$PACKAGE"; exit
|
al@762
|
2243 fi
|
pascal@223
|
2244 if grep -qs "^$PACKAGE" $BLOCKED; then
|
al@813
|
2245 _ 'Package "%s" is already blocked.' "$PACKAGE"
|
pankso@10
|
2246 else
|
al@813
|
2247 echo "$PACKAGE" >> $BLOCKED
|
pascal@183
|
2248 # Log this activity
|
al@813
|
2249 . "$INSTALLED/$PACKAGE/receipt"; log_pkg Blocked
|
al@813
|
2250 _ 'Package "%s" blocked.' "$PACKAGE"
|
pankso@10
|
2251 fi
|
al@813
|
2252 newline
|
al@813
|
2253 ;;
|
al@694
|
2254
|
al@694
|
2255
|
al@785
|
2256 unblock|-u)
|
MikeDSmith25@135
|
2257 # Remove a pkg name from the list of blocked packages.
|
al@603
|
2258 check_root $@
|
pankso@10
|
2259 check_for_package_on_cmdline
|
pankso@600
|
2260 newline
|
al@813
|
2261 if [ ! -d "$INSTALLED/$PACKAGE" ]; then
|
al@813
|
2262 _ 'Package "%s" is not installed.' "$PACKAGE"; exit
|
al@762
|
2263 fi
|
pascal@223
|
2264 if grep -qs "^$PACKAGE" $BLOCKED; then
|
al@762
|
2265 sed -i "/^$PACKAGE\$/d" $BLOCKED
|
pascal@183
|
2266 # Log this activity
|
al@813
|
2267 . "$INSTALLED/$PACKAGE/receipt"; log_pkg Unblocked
|
al@813
|
2268 _ 'Package "%s" unblocked.' "$PACKAGE"
|
pankso@10
|
2269 else
|
al@813
|
2270 _ 'Package "%s" is not blocked.' "$PACKAGE"
|
al@762
|
2271 fi
|
al@813
|
2272 newline
|
al@813
|
2273 ;;
|
al@762
|
2274
|
al@762
|
2275
|
al@762
|
2276 chblock)
|
al@762
|
2277 # Change package's blocked status.
|
al@762
|
2278 check_root $@
|
al@762
|
2279 check_for_package_on_cmdline
|
al@762
|
2280 newline
|
al@813
|
2281 if [ ! -d "$INSTALLED/$PACKAGE" ]; then
|
al@813
|
2282 _ 'Package "%s" is not installed.' "$PACKAGE"; exit
|
al@762
|
2283 fi
|
al@762
|
2284 if grep -qs "^$PACKAGE" $BLOCKED; then
|
al@762
|
2285 sed -i "/^$PACKAGE\$/d" $BLOCKED
|
al@762
|
2286 # Log this activity
|
al@813
|
2287 . "$INSTALLED/$PACKAGE/receipt"; log_pkg Unblocked
|
al@813
|
2288 _ 'Package "%s" unblocked.' "$PACKAGE"
|
al@762
|
2289 else
|
al@813
|
2290 echo "$PACKAGE" >> $BLOCKED
|
al@762
|
2291 # Log this activity
|
al@813
|
2292 . "$INSTALLED/$PACKAGE/receipt"; log_pkg Blocked
|
al@813
|
2293 _ 'Package "%s" blocked.' "$PACKAGE"
|
pankso@10
|
2294 fi
|
al@813
|
2295 newline
|
al@813
|
2296 ;;
|
al@694
|
2297
|
al@694
|
2298
|
al@785
|
2299 get|-g)
|
al@603
|
2300 # Download a package with wget.
|
al@603
|
2301 check_root $@
|
pankso@6
|
2302 check_for_package_on_cmdline
|
pankso@6
|
2303 check_for_packages_list
|
pankso@598
|
2304
|
al@811
|
2305 [ -n "$root" ] && ROOT="$root" && check_base_dir "$root"
|
al@811
|
2306 if [ -n "$rootconfig" ]; then
|
al@811
|
2307 if [ -n "$root" ]; then
|
al@811
|
2308 CACHE_DIR="$root/$CACHE_DIR"
|
al@811
|
2309 SAVE_CACHE_DIR="$CACHE_DIR"
|
al@811
|
2310 PKGS_DB="$root/$PKGS_DB"
|
slaxemulator@478
|
2311 else
|
al@694
|
2312 _ 'rootconfig needs --root= option used.' >&2
|
slaxemulator@478
|
2313 exit 1
|
slaxemulator@478
|
2314 fi
|
slaxemulator@478
|
2315 fi
|
pankso@598
|
2316
|
gokhlayeh@386
|
2317 # Get repositories priority list.
|
gokhlayeh@386
|
2318 look_for_priority
|
pankso@598
|
2319
|
al@811
|
2320 CURRENT_DIR="$PWD"
|
al@812
|
2321 cd "$CACHE_DIR"
|
pascal@793
|
2322 if check_for_package_in_list check ; then
|
al@812
|
2323 cd "$CACHE_DIR"
|
pascal@793
|
2324 if [ -f "$PACKAGE.tazpkg" ]; then
|
al@812
|
2325 _ 'Package "%s" already in the cache' "$PACKAGE"
|
pascal@793
|
2326 # Check package download was finished
|
al@812
|
2327 tail -c 2k "$PACKAGE.tazpkg" | fgrep -q '00000000TRAILER' || {
|
al@812
|
2328 _ 'Continuing package "%s" download' "$PACKAGE"
|
al@812
|
2329 download "$PACKAGE.tazpkg"
|
pascal@793
|
2330 }
|
al@813
|
2331 if [ "$($CHECKSUM "$PACKAGE.tazpkg")" != \
|
al@812
|
2332 "$(fgrep " $PACKAGE.tazpkg" "$rep/packages.$SUM")" ]; then
|
al@812
|
2333 rm -f "$PACKAGE.tazpkg"
|
al@812
|
2334 download "$PACKAGE.tazpkg"
|
pascal@793
|
2335 fi
|
pascal@793
|
2336 else
|
al@812
|
2337 download "$PACKAGE.tazpkg"
|
slaxemulator@378
|
2338 fi
|
al@811
|
2339 PACKAGE_FILE="$CACHE_DIR/$PACKAGE.tazpkg"
|
al@812
|
2340 elif download_get_script "$PACKAGE" "/tmp/$PACKAGE.$$" ; then
|
al@812
|
2341 install_package_from_get_script "/tmp/$PACKAGE.$$" "$ROOT" --get
|
al@812
|
2342 PACKAGE_FILE="$(ls "$PWD/$PACKAGE-*.tazpkg")"
|
slaxemulator@378
|
2343 fi
|
pascal@793
|
2344 [ "$PWD" != "$CURRENT_DIR" ] &&
|
al@812
|
2345 cp -a "$PACKAGE_FILE" "$CURRENT_DIR"
|
al@811
|
2346 ;;
|
al@694
|
2347
|
al@694
|
2348
|
pankso@504
|
2349 get-install|-gi)
|
pankso@6
|
2350 # Download and install a package.
|
al@603
|
2351 check_root $@
|
pankso@6
|
2352 check_for_package_on_cmdline
|
pankso@6
|
2353 check_for_packages_list
|
pankso@598
|
2354
|
al@805
|
2355 DO_CHECK=''
|
al@811
|
2356 [ -n "$forced" ] && DO_CHECK='no'
|
al@805
|
2357 [ -n "$root" ] && ROOT="$root" && check_base_dir "$root"
|
al@811
|
2358 [ -n "$list" ] && INSTALL_LIST="$list" # internal option
|
al@811
|
2359
|
al@811
|
2360 if [ -n "$rootconfig" ]; then # outdated?
|
al@805
|
2361 if [ -n "$root" ]; then
|
al@805
|
2362 CACHE_DIR="$root/$CACHE_DIR"
|
al@805
|
2363 SAVE_CACHE_DIR="$CACHE_DIR"
|
al@805
|
2364 PKGS_DB="$root/$PKGS_DB"
|
gokhlayeh@429
|
2365 else
|
al@694
|
2366 _ 'rootconfig needs --root= option used.' >&2
|
gokhlayeh@429
|
2367 exit 1
|
gokhlayeh@429
|
2368 fi
|
gokhlayeh@429
|
2369 fi
|
gokhlayeh@436
|
2370
|
gokhlayeh@436
|
2371 # Get repositories priority list.
|
gokhlayeh@436
|
2372 look_for_priority
|
gokhlayeh@436
|
2373
|
al@805
|
2374 AUTOEXEC='no'
|
al@828
|
2375 # Magic :)
|
al@828
|
2376 # After testing this condition $PACKAGE become $PACKAGE-$VERSION$EXTRAVERSION
|
gokhlayeh@416
|
2377 if ! check_for_package_in_list check; then
|
pascal@648
|
2378 CACHE_DIR="${CACHE_DIR%/*}/get"
|
pascal@648
|
2379 [ -d "$CACHE_DIR" ] || mkdir -p $CACHE_DIR
|
al@813
|
2380 if download_get_script "$PACKAGE" "/tmp/$PACKAGE.$$" ; then
|
al@813
|
2381 install_package_from_get_script "/tmp/$PACKAGE.$$" $ROOT
|
pascal@202
|
2382 exit 0
|
pascal@648
|
2383 else
|
al@805
|
2384 PACKAGE="get-$PACKAGE"
|
al@805
|
2385 AUTOEXEC="$PACKAGE"
|
al@828
|
2386 # Here $PACKAGE become $PACKAGE-$VERSION$EXTRAVERSION
|
pascal@648
|
2387 check_for_package_in_list
|
al@813
|
2388 if [ -n "$(get_installed_package_pathname "$PACKAGE" "$ROOT")" ]; then
|
pascal@648
|
2389 $AUTOEXEC $ROOT
|
pascal@648
|
2390 exit 0
|
pascal@648
|
2391 fi
|
pascal@202
|
2392 fi
|
gokhlayeh@416
|
2393 fi
|
al@805
|
2394 # Check if no forced install.
|
al@805
|
2395 if [ -z "$forced" ]; then
|
pascal@121
|
2396 check_for_installed_package $ROOT
|
pankso@6
|
2397 fi
|
al@828
|
2398
|
pankso@6
|
2399 cd $CACHE_DIR
|
al@828
|
2400 # Here $PACKAGE is $PACKAGE-$VERSION$EXTRAVERSION
|
pankso@6
|
2401 if [ -f "$PACKAGE.tazpkg" ]; then
|
al@813
|
2402 _ 'Package "%s" already in the cache' "$PACKAGE"
|
MikeDSmith25@135
|
2403 # Check package download was finished
|
al@813
|
2404 tail -c 2k "$PACKAGE.tazpkg" | fgrep -q '00000000TRAILER' || {
|
al@813
|
2405 _ 'Continuing package "%s" download' "$PACKAGE"
|
al@813
|
2406 download "$PACKAGE.tazpkg"
|
pascal@108
|
2407 }
|
al@813
|
2408 if [ "$($CHECKSUM "$PACKAGE.tazpkg")" != "$(fgrep " $PACKAGE.tazpkg" $rep/packages.$SUM)" ]; then
|
al@813
|
2409 rm -f "$PACKAGE.tazpkg"
|
al@813
|
2410 download "$PACKAGE.tazpkg"
|
pascal@374
|
2411 fi
|
pankso@6
|
2412 else
|
pankso@600
|
2413 newline
|
al@813
|
2414 download "$PACKAGE.tazpkg"
|
pankso@6
|
2415 fi
|
al@805
|
2416 PACKAGE_FILE="$CACHE_DIR/$PACKAGE.tazpkg"
|
al@805
|
2417 [ -n "$rootconfig" ] && PKGS_DB="${PKGS_DB#$root}"
|
al@805
|
2418 install_package "$ROOT"
|
al@813
|
2419 [ "$AUTOEXEC" != 'no' ] && "$PACKAGE" $ROOT
|
pankso@598
|
2420 update_desktop_database $ROOT
|
al@805
|
2421 update_mime_database $ROOT ;;
|
al@694
|
2422
|
al@694
|
2423
|
pankso@504
|
2424 clean-cache|-cc)
|
pankso@6
|
2425 # Remove all downloaded packages.
|
al@603
|
2426 check_root $@
|
pankso@499
|
2427 files=$(find $CACHE_DIR -name *.tazpkg | wc -l)
|
al@813
|
2428 size=$(du -hs $CACHE_DIR | cut -f1 | sed 's|\.0||'); [ "$files" -eq 0 ] && size="0K"
|
al@813
|
2429
|
al@813
|
2430 title 'Cleaning cache directory...'
|
al@813
|
2431 action 'Path: %s' "$CACHE_DIR"
|
pankso@6
|
2432 rm -rf $CACHE_DIR/*
|
al@603
|
2433 status
|
al@707
|
2434
|
al@707
|
2435 footer "$(_p \
|
al@707
|
2436 '%s file removed from cache (%s).' \
|
al@707
|
2437 '%s files removed from cache (%s).' $files \
|
al@707
|
2438 "$(colorize 32 "$files")" $size)"
|
al@694
|
2439 ;;
|
al@694
|
2440
|
al@694
|
2441
|
pascal@187
|
2442 list-undigest)
|
pascal@187
|
2443 # list undigest URLs.
|
al@805
|
2444 if [ -n "$box" ]; then
|
al@700
|
2445 for i in $PKGS_DB/undigest/*/mirror; do
|
al@805
|
2446 [ -f "$i" ] || continue
|
al@813
|
2447 echo "$(basename "$(dirname "$i")")|$(cat "$i")"
|
pascal@187
|
2448 done
|
pascal@187
|
2449 else
|
al@603
|
2450 title 'Current undigest(s)'
|
al@700
|
2451 for i in $PKGS_DB/undigest/*/mirror; do
|
al@805
|
2452 if [ ! -f "$i" ]; then
|
al@694
|
2453 _ 'No undigest mirror found.'
|
pascal@187
|
2454 exit 1
|
pascal@187
|
2455 fi
|
al@813
|
2456 echo "$(basename "$(dirname "$i")")"$'\t'"$(cat "$i")"
|
pascal@187
|
2457 done
|
pankso@600
|
2458 newline
|
al@811
|
2459 fi
|
al@811
|
2460 ;;
|
al@694
|
2461
|
al@694
|
2462
|
pascal@187
|
2463 remove-undigest)
|
pascal@187
|
2464 # remove undigest URL.
|
al@603
|
2465 check_root $@
|
gokhlayeh@388
|
2466 undigest="$2"
|
al@805
|
2467 if [ -d "$PKGS_DB/undigest/$2" ]; then
|
al@707
|
2468 confirm "$(_ 'Remove "%s" undigest? (y/N)' $undigest)"
|
al@805
|
2469 if [ $? == 0 ]; then
|
al@707
|
2470 action 'Removing "%s" undigest...' $undigest
|
al@700
|
2471 rm -rf $PKGS_DB/undigest/$2
|
pascal@187
|
2472 status
|
al@805
|
2473 rmdir $PKGS_DB/undigest 2>/dev/null
|
pascal@187
|
2474 fi
|
pascal@187
|
2475 else
|
al@707
|
2476 _ 'Undigest "%s" not found' $undigest
|
al@811
|
2477 fi
|
al@811
|
2478 ;;
|
al@694
|
2479
|
al@694
|
2480
|
pascal@187
|
2481 add-undigest|setup-undigest)
|
pascal@187
|
2482 # Add undigest URL.
|
al@603
|
2483 check_root $@
|
al@811
|
2484
|
al@811
|
2485 [ ! -d "$PKGS_DB/undigest" ] && mkdir "$PKGS_DB/undigest"
|
al@811
|
2486
|
al@811
|
2487 undigest="$2"
|
pascal@187
|
2488 if [ -z "$undigest" ]; then
|
al@811
|
2489 i='1'
|
al@805
|
2490 while [ -d "$PKGS_DB/undigest/$i" ]; do
|
pascal@187
|
2491 i=$(($i+1))
|
pascal@187
|
2492 done
|
al@811
|
2493 undigest="$i"
|
pascal@187
|
2494 fi
|
al@805
|
2495 if [ ! -d "$PKGS_DB/undigest/$undigest" ]; then
|
al@811
|
2496 _ 'Creating new undigest "%s".' "$undigest"
|
al@811
|
2497 mkdir "$PKGS_DB/undigest/$undigest"
|
pascal@187
|
2498 fi
|
al@811
|
2499 setup_mirror "$PKGS_DB/undigest/$undigest" "$3"
|
al@811
|
2500 ;;
|
al@694
|
2501
|
al@694
|
2502
|
pankso@600
|
2503 setup-mirror|-sm)
|
pankso@6
|
2504 # Change mirror URL.
|
al@603
|
2505 check_root $@
|
al@700
|
2506 setup_mirror $PKGS_DB $2 ;;
|
al@694
|
2507
|
al@694
|
2508
|
erjo@56
|
2509 reconfigure)
|
erjo@56
|
2510 # Replay post_install from receipt
|
erjo@56
|
2511 check_for_package_on_cmdline
|
al@603
|
2512 check_root $@
|
al@811
|
2513
|
al@811
|
2514 ROOT="$root"
|
pascal@250
|
2515 if [ -d "$ROOT$INSTALLED/$PACKAGE" ]; then
|
pascal@250
|
2516 check_for_receipt $ROOT
|
erjo@56
|
2517 # Check for post_install
|
al@813
|
2518 if grep -q ^post_install "$ROOT$INSTALLED/$PACKAGE/receipt"; then
|
al@813
|
2519 . "$ROOT$INSTALLED/$PACKAGE/receipt"
|
pascal@250
|
2520 post_install $ROOT
|
pascal@183
|
2521 # Log this activity
|
al@811
|
2522 [ -z "$ROOT" ] && log_pkg Reconfigured
|
pankso@279
|
2523 else
|
pankso@600
|
2524 newline
|
al@813
|
2525 _ 'Nothing to do for package "%s".' "$PACKAGE"
|
erjo@56
|
2526 fi
|
erjo@56
|
2527 else
|
pankso@600
|
2528 newline
|
al@813
|
2529 _ 'Package "%s" is not installed.' "$PACKAGE"
|
al@707
|
2530 _ 'Install package with "%s" or "%s"' 'tazpkg install' 'tazpkg get-install'
|
pankso@600
|
2531 newline
|
al@813
|
2532 fi
|
al@813
|
2533 ;;
|
al@694
|
2534
|
al@694
|
2535
|
pankso@55
|
2536 shell)
|
al@811
|
2537 # TazPkg SHell
|
al@811
|
2538 if [ "$(id -u)" -eq 0 ]; then
|
pankso@55
|
2539 PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
|
pankso@55
|
2540 else
|
pankso@55
|
2541 PROMPT="\\033[1;33mtazpkg\\033[0;39m> "
|
pankso@55
|
2542 fi
|
al@834
|
2543 if [ -z "$noheader" ]; then
|
pankso@55
|
2544 clear
|
al@811
|
2545 title 'TazPkg SHell.'
|
al@694
|
2546 _ "Type 'usage' to list all available commands or 'quit' or 'q' to exit."
|
pankso@600
|
2547 newline
|
pankso@55
|
2548 fi
|
al@694
|
2549 while true; do
|
pankso@55
|
2550 echo -en "$PROMPT"; read cmd
|
pankso@55
|
2551 case $cmd in
|
pankso@55
|
2552 q|quit)
|
pankso@55
|
2553 break ;;
|
pankso@55
|
2554 shell)
|
al@811
|
2555 _ 'You are already running a TazPkg SHell.' ;;
|
pankso@55
|
2556 su)
|
pankso@55
|
2557 su -c 'exec tazpkg shell --noheader' && break ;;
|
pankso@55
|
2558 "")
|
pankso@55
|
2559 continue ;;
|
pankso@55
|
2560 *)
|
pankso@55
|
2561 tazpkg $cmd ;;
|
pankso@55
|
2562 esac
|
pankso@309
|
2563 done ;;
|
al@694
|
2564
|
al@694
|
2565
|
pascal@205
|
2566 depends)
|
paul@247
|
2567 # Display dependencies tree
|
al@836
|
2568 unset ALL_DEPS
|
al@836
|
2569 mkdir $TMP_DIR
|
al@836
|
2570 dep_scan $2 '' | tee "$TMP_DIR/depends"
|
al@836
|
2571 if [ -n "$total" ]; then
|
al@836
|
2572 separator
|
al@836
|
2573 NUM="$(wc -l < "$TMP_DIR/depends")"
|
al@836
|
2574 TOTAL="$(sed 's|.*(\([^)]*\))|\1|' "$TMP_DIR/depends" | hrsum)"
|
al@836
|
2575 _p 'Total: %s package (%s)' 'Total: %s packages (%s)' "$NUM" \
|
al@836
|
2576 "$NUM" "$TOTAL"
|
al@836
|
2577 newline
|
al@836
|
2578
|
al@836
|
2579 if [ -n "$mark" ]; then
|
al@836
|
2580 NUM="$(grep '^ *-' "$TMP_DIR/depends" | wc -l)"
|
al@836
|
2581 TOTAL="$(grep '^ *-' "$TMP_DIR/depends" | sed 's|.*(\([^)]*\))|\1|' | hrsum)"
|
al@836
|
2582 _p 'To install: %s package (%s)' 'To install: %s packages (%s)' "$NUM" \
|
al@836
|
2583 "$NUM" "$TOTAL"
|
al@836
|
2584 newline
|
al@836
|
2585 fi
|
al@836
|
2586 fi
|
al@836
|
2587 rm -rf "$TMP_DIR"
|
al@836
|
2588 ;;
|
al@694
|
2589
|
al@694
|
2590
|
pascal@205
|
2591 rdepends)
|
paul@247
|
2592 # Display reverse dependencies tree
|
pascal@205
|
2593 cd $INSTALLED
|
al@836
|
2594 unset ALL_DEPS
|
al@836
|
2595 rdep_scan "$2"
|
al@811
|
2596 ;;
|
al@694
|
2597
|
al@694
|
2598
|
pankso@504
|
2599 convert|-c)
|
pascal@262
|
2600 # convert misc package format to .tazpkg
|
pascal@263
|
2601 check_for_package_file
|
al@824
|
2602 shift; @@MODULES@@/convert $@
|
al@695
|
2603 ;;
|
al@694
|
2604
|
al@694
|
2605
|
pascal@263
|
2606 link)
|
pascal@263
|
2607 # link a package from another slitaz installation
|
al@813
|
2608 PACKAGE="$2"
|
pascal@263
|
2609 if [ ! -d "$TARGET_DIR" -o \
|
pascal@263
|
2610 ! -d "$TARGET_DIR$INSTALLED/$PACKAGE" ]; then
|
al@707
|
2611 _ 'Usage: tazpkg link package_name slitaz_root'
|
al@707
|
2612 longline "$(
|
al@707
|
2613 _n 'Example:'
|
al@707
|
2614 echo -n ' '
|
al@707
|
2615 _ '"%s" will use less than 100k in your running system RAM.' \
|
al@707
|
2616 'tazpkg link openoffice /mnt')"
|
pascal@263
|
2617 exit 1
|
pascal@263
|
2618 fi
|
pascal@263
|
2619 if [ -e "$INSTALLED/$PACKAGE" ]; then
|
al@813
|
2620 _ 'Package "%s" is already installed.' "$PACKAGE"
|
pascal@263
|
2621 exit 1
|
pascal@263
|
2622 fi
|
al@813
|
2623 ln -s "$TARGET_DIR$INSTALLED/$PACKAGE" $INSTALLED
|
al@813
|
2624 DEPENDS="$(. "$INSTALLED/$PACKAGE/receipt"; echo $DEPENDS)"
|
al@805
|
2625 MISSING=''
|
pascal@266
|
2626 for i in $DEPENDS; do
|
pascal@266
|
2627 [ -e $INSTALLED/$i ] && continue
|
pascal@266
|
2628 MISSING="$MISSING$i "
|
al@707
|
2629 _ 'Missing: %s' $i
|
pascal@266
|
2630 done
|
pascal@266
|
2631 if [ -n "$MISSING" ]; then
|
pankso@600
|
2632 newline
|
al@696
|
2633 confirm "$(_ 'Link all missing dependencies? (y/N)')"
|
al@603
|
2634 answer=$?
|
pankso@600
|
2635 newline
|
al@813
|
2636 if [ "$answer" -eq 0 ]; then
|
pascal@266
|
2637 for i in $MISSING; do
|
pascal@266
|
2638 tazpkg link $i $TARGET_DIR
|
pascal@266
|
2639 done
|
pascal@266
|
2640 else
|
pankso@600
|
2641 newline
|
al@813
|
2642 _ 'Leaving dependencies unresolved for package "%s"' "$PACKAGE"
|
al@694
|
2643 _ 'The package is installed but probably will not work.'
|
pankso@600
|
2644 newline
|
pascal@266
|
2645 fi
|
pascal@266
|
2646 fi
|
al@813
|
2647 . "$INSTALLED/$PACKAGE/receipt"
|
al@813
|
2648 if grep -q ^pre_install "$INSTALLED/$PACKAGE/receipt"; then
|
pascal@266
|
2649 pre_install
|
pascal@266
|
2650 fi
|
pascal@263
|
2651 while read path; do
|
al@805
|
2652 [ -e "$path" ] && continue
|
pascal@263
|
2653 while true; do
|
al@813
|
2654 dir="$(dirname "$path")"
|
al@805
|
2655 [ -e "$dir" ] && break
|
al@805
|
2656 path="$dir"
|
pascal@263
|
2657 done
|
al@805
|
2658 ln -s "$TARGET_DIR$path" "$dir"
|
al@813
|
2659 done < "$INSTALLED/$PACKAGE/files.list"
|
al@813
|
2660 if grep -q ^post_install "$INSTALLED/$PACKAGE/receipt"; then
|
pascal@266
|
2661 post_install
|
pankso@309
|
2662 fi ;;
|
al@694
|
2663
|
al@694
|
2664
|
al@811
|
2665 help|-h)
|
al@811
|
2666 # TazPkg help system
|
al@822
|
2667 shift; @@MODULES@@/help $@ ;;
|
al@811
|
2668
|
al@811
|
2669
|
al@824
|
2670 mkdb)
|
al@824
|
2671 # Make TazPkg database
|
al@824
|
2672 shift; @@MODULES@@/mkdb $@ ;;
|
al@824
|
2673
|
al@824
|
2674
|
al@820
|
2675 '')
|
al@820
|
2676 # Default to summary
|
al@820
|
2677 title "$(_ 'SliTaz package manager - Version: %s' $(colorize 34 $VERSION))"
|
al@820
|
2678
|
al@820
|
2679 optlist "\
|
al@820
|
2680 $(_ 'Installed packages:') $(wc -l < $PKGS_DB/installed.info)
|
al@820
|
2681 $(_ 'Installed files:') $(cat $INSTALLED/*/files.list | wc -l)
|
al@828
|
2682 $(_ 'Blocked packages:') $( (wc -l < $PKGS_DB/blocked-packages.list) 2>/dev/null || echo 0)
|
al@828
|
2683 $(_ 'Upgradeable packages:') $( (wc -l < $PKGS_DB/packages.up) 2>/dev/null || echo 0)
|
al@820
|
2684 $(
|
al@820
|
2685 # Per-repository stuff
|
al@820
|
2686
|
al@820
|
2687 if [ -h "$PKGS_DB/fslink" ]; then
|
al@820
|
2688 if [ -e "$PKGS_DB/fslink/etc/slitaz/slitaz.conf" ]; then
|
al@820
|
2689 PKGS_DB_LINK="$PKGS_DB/fslink/$(. "$PKGS_DB/fslink/etc/slitaz/slitaz.conf"; echo "$PKGS_DB")"
|
al@820
|
2690 fi
|
al@820
|
2691 fi
|
al@820
|
2692
|
al@820
|
2693 for path in $PKGS_DB $PKGS_DB/undigest/* $PKGS_DB_LINK; do
|
al@820
|
2694 [ ! -e "$path" ] && continue
|
al@820
|
2695 case "$path" in
|
al@820
|
2696 $PKGS_DB) repo_name='Main';;
|
al@820
|
2697 */fslink/*) repo_name=$(readlink $PKGS_DB/fslink);;
|
al@820
|
2698 *) repo_name="$(_n 'Undigest %s' "$(basename "$path")")";;
|
al@820
|
2699 esac
|
al@820
|
2700
|
al@820
|
2701 newline; colorize 33 "$(_n 'Repository:'; echo -e "\t$repo_name")"
|
al@820
|
2702
|
al@820
|
2703 _n 'Last recharge:'; echo -en '\t'
|
al@820
|
2704 IDs="$path/IDs"
|
al@820
|
2705 if [ -e "$IDs" ]; then
|
al@820
|
2706 # Timezone offset as string, ex. '+0200' for EET (+2 hours)
|
al@820
|
2707 ohhmm="$(date +%z)"
|
al@820
|
2708 # Timezone offset in the seconds
|
al@820
|
2709 offset=$(( 60 * (60 * ${ohhmm:0:3} + ${ohhmm:3:2}) ))
|
al@820
|
2710 daynow=$(( ($(date +%s) + $offset) / 86400 ))
|
al@820
|
2711 dayupd=$(( ($(date -r $IDs +%s) + $offset) / 86400 ))
|
al@820
|
2712 days=$(( $daynow - $dayupd ))
|
al@820
|
2713 time=$(date -r $IDs +%R)
|
al@820
|
2714 case $days in
|
al@820
|
2715 0) _ 'Today at %s.' $time;;
|
al@820
|
2716 1) _ 'Yesterday at %s.' $time;;
|
al@820
|
2717 *) _p '%d day ago.' '%d days ago.' $days $days; newline;;
|
al@820
|
2718 esac
|
al@820
|
2719
|
al@820
|
2720 _n 'Database timestamp:'; echo -en '\t'
|
al@820
|
2721 date -d "@$(awk '{print $2}' "$IDs")" "+%x %R"
|
al@820
|
2722 else
|
al@820
|
2723 _ 'never.'
|
al@820
|
2724 fi
|
al@820
|
2725
|
al@820
|
2726 if [ -e "$path/packages.info" ]; then
|
al@820
|
2727 _n 'Mirrored packages:'; echo -en '\t'; wc -l < "$path/packages.info"
|
al@820
|
2728 fi
|
al@820
|
2729
|
al@820
|
2730 if [ "${path/fslink/}" != "$path" ]; then
|
al@820
|
2731 _n 'Linked packages:'; echo -en '\t'
|
al@820
|
2732 find $INSTALLED -type l | wc -l
|
al@820
|
2733 fi
|
al@820
|
2734 done
|
al@820
|
2735 )"
|
al@820
|
2736 footer
|
al@820
|
2737 ;;
|
al@820
|
2738
|
al@820
|
2739
|
pankso@6
|
2740 usage|*)
|
pascal@119
|
2741 # Print a short help or give usage for an unknown or empty command.
|
pankso@279
|
2742 usage ;;
|
pankso@6
|
2743 esac
|
pankso@6
|
2744
|
pankso@6
|
2745 exit 0
|