tazpkg view modules/block @ 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 0560ba4306a1
children
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # block - TazPkg module
4 # Change package's blocked status
7 # Connect function libraries
8 . /lib/libtaz.sh
10 # Get TazPkg working environment
11 . @@MODULES@@/getenv
16 newline
17 if [ ! -d "$INSTALLED/$2" ]; then
18 _ 'Package "%s" is not installed.' "$2"
19 exit 1
20 fi
22 case $1 in
24 block|-b)
25 # Block package
26 if grep -qs "^$2" "$BLOCKED"; then
27 _ 'Package "%s" is already blocked.' "$2"
28 else
29 echo "$2" >> "$BLOCKED"
30 # Log this activity
31 . "$INSTALLED/$2/receipt"; tazpkg call log_pkg Blocked
32 _ 'Package "%s" blocked.' "$2"
33 fi
34 ;;
37 unblock|-u)
38 # Unblock package
39 if grep -qs "^$2" "$BLOCKED"; then
40 sed -i "/^$2\$/d" "$BLOCKED"
41 # Log this activity
42 . "$INSTALLED/$2/receipt"; tazpkg call log_pkg Unblocked
43 _ 'Package "%s" unblocked.' "$2"
44 else
45 [ -z "$nowarning" ] && _ 'Package "%s" is not blocked.' "$2"
46 fi
47 ;;
50 chblock)
51 # Block/unblock package
52 if grep -qs "^$2" "$BLOCKED"; then
53 sed -i "/^$2\$/d" "$BLOCKED"
54 # Log this activity
55 . "$INSTALLED/$2/receipt"; tazpkg call log_pkg Unblocked
56 _ 'Package "%s" unblocked.' "$2"
57 else
58 echo "$2" >> "$BLOCKED"
59 # Log this activity
60 . "$INSTALLED/$2/receipt"; tazpkg call log_pkg Blocked
61 _ 'Package "%s" blocked.' "$2"
62 fi
63 ;;
65 esac
66 newline