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