tazpkg view modules/mirror @ rev 846

Remove "busybox" "prefixes" (thanks llev)
We used "busybox wget", etc. to be sure we called Busybox's "wget", not any other "wget". Workaround already done in "getenv" module.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Oct 09 13:14:01 2015 +0300 (2015-10-09)
parents
children
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # mirror - TazPkg module
4 # Add/remove/list undigest mirrors, URLs
7 # Connect function libraries
8 . /lib/libtaz.sh
10 # Get TazPkg working environment
11 . @@MODULES@@/getenv
16 # Update mirror URLs
18 setup_mirror() {
19 # Backup old list.
20 if [ -f "$1/mirror" ]; then
21 cp -f $1/mirror $1/mirror.bak
22 fi
23 title 'Current mirror(s)'
24 echo " $(cat "$1/mirror" 2>/dev/null)"
25 longline "$(_ "Please enter URL of the new mirror (http, ftp or local \
26 path). You must specify the complete address to the directory of the packages \
27 and packages.list file.")"
28 newline
30 _n 'New mirror(s) URL: '
31 NEW_MIRROR_URL="$2"
32 if [ -n "$NEW_MIRROR_URL" ]; then
33 echo $NEW_MIRROR_URL
34 else
35 read NEW_MIRROR_URL
36 fi
38 if [ -z "$NEW_MIRROR_URL" ]; then
39 _ 'Nothing has been changed.'
40 else
41 _ 'Setting mirror(s) to: "%s"' "$NEW_MIRROR_URL"
42 rm -f "$1/mirror"
43 for i in $NEW_MIRROR_URL; do
44 echo "${i%/}/" >> "$1/mirror"
45 done
46 fi
47 newline
48 }
53 case $1 in
54 list)
55 # List undigest mirrors URLs
57 if [ -n "$box" ]; then
58 for i in $PKGS_DB/undigest/*/mirror; do
59 [ -f "$i" ] || continue
60 echo "$(basename "$(dirname "$i")")|$(cat "$i")"
61 done
62 else
63 title 'Current undigest(s)'
64 for i in $PKGS_DB/undigest/*/mirror; do
65 if [ ! -f "$i" ]; then
66 _ 'No undigest mirror found.'
67 exit 1
68 fi
69 echo "$(basename "$(dirname "$i")")"$'\t'"$(cat "$i")"
70 done
71 newline
72 fi
73 ;;
76 remove)
77 # Remove undigest mirror
79 undigest="$2"
80 if [ -d "$PKGS_DB/undigest/$2" ]; then
81 confirm "$(_ 'Remove "%s" undigest? (y/N)' "$undigest")"
82 if [ $? -eq 0 ]; then
83 action 'Removing "%s" undigest...' "$undigest"
84 rm -rf "$PKGS_DB/undigest/$2"
85 status
86 rmdir "$PKGS_DB/undigest" 2>/dev/null
87 fi
88 else
89 _ 'Undigest "%s" not found' "$undigest"
90 fi
91 ;;
94 add)
95 # Add undigest URL
97 [ ! -d "$PKGS_DB/undigest" ] && mkdir "$PKGS_DB/undigest"
99 undigest="$2"
100 if [ -z "$undigest" ]; then
101 i='1'
102 while [ -d "$PKGS_DB/undigest/$i" ]; do
103 i=$(($i+1))
104 done
105 undigest="$i"
106 fi
107 if [ ! -d "$PKGS_DB/undigest/$undigest" ]; then
108 _ 'Creating new undigest "%s".' "$undigest"
109 mkdir "$PKGS_DB/undigest/$undigest"
110 fi
111 setup_mirror "$PKGS_DB/undigest/$undigest" "$3"
112 ;;
114 setup)
115 # Change mirror URL
116 setup_mirror "$PKGS_DB" "$2"
117 ;;
119 esac