tazpkg view modules/link @ rev 955

modules/search: allow search file with dash at start: tazpkg -sf "-spi"
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Dec 22 00:02:54 2017 +0200 (2017-12-22)
parents
children
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # link - TazPkg module
4 # Link a package from another SliTaz installation
7 # Connect function libraries
8 . /lib/libtaz.sh
10 # Get TazPkg working environment
11 . @@MODULES@@/getenv
16 PACKAGE="$2"
17 TARGET_DIR="$3"
19 if [ -e "$INSTALLED/$PACKAGE" ]; then
20 _ 'Package "%s" is already installed.' "$PACKAGE"
21 exit 1
22 fi
24 ln -s "$TARGET_DIR$INSTALLED/$PACKAGE" $INSTALLED
25 DEPENDS="$(. "$INSTALLED/$PACKAGE/receipt"; echo $DEPENDS)"
26 MISSING=''
28 for i in $DEPENDS; do
29 [ -e $INSTALLED/$i ] && continue
30 MISSING="$MISSING$i "
31 _ 'Missing: %s' $i
32 done
34 if [ -n "$MISSING" ]; then
35 newline
36 confirm "$(_ 'Link all missing dependencies? (y/N)')"
37 answer=$?
38 newline
39 if [ "$answer" -eq 0 ]; then
40 for i in $MISSING; do
41 tazpkg link $i $TARGET_DIR
42 done
43 else
44 newline
45 _ 'Leaving dependencies unresolved for package "%s"' "$PACKAGE"
46 _ 'The package is installed but probably will not work.'
47 newline
48 fi
49 fi
51 . "$INSTALLED/$PACKAGE/receipt"
52 if grep -q ^pre_install "$INSTALLED/$PACKAGE/receipt"; then
53 pre_install
54 fi
56 while read path; do
57 [ -e "$path" ] && continue
58 while true; do
59 dir="$(dirname "$path")"
60 [ -e "$dir" ] && break
61 path="$dir"
62 done
63 ln -s "$TARGET_DIR$path" "$dir"
64 done < "$INSTALLED/$PACKAGE/files.list"
66 if grep -q ^post_install "$INSTALLED/$PACKAGE/receipt"; then
67 post_install
68 fi