wok view tramys-client/stuff/tramys2 @ rev 25030

giblib: inserted configure parameters
author Hans-G?nter Theisgen
date Fri May 20 10:23:32 2022 +0100 (2022-05-20)
parents 709cff7a6bed
children
line source
1 #!/bin/sh
2 # tramys - TRAnslate MY Slitaz. Client solution
3 # Tool for managing translation files for SliTaz GNU/Linux
4 # Aleksej Bobylev <al.bobylev@gmail.com>, 2014
6 . /etc/slitaz/slitaz.conf
7 . /lib/libtaz.sh
9 # Ask for root access in order to install the files in the system.
10 if [ $(id -u) != 0 ]; then
11 exec tazbox su $0 $@; exit 0
12 fi
14 export TEXTDOMAIN='tramys' # i18n
15 WORKING=$(mktemp -d)
16 LOG="/tmp/tramys.log"
17 TGZ="/tmp/tramys.tgz"
18 URL="http://cook.slitaz.org/tramys2.cgi"
20 # Common Yad options.
21 YADCONF="--center --window-icon=config-language --image=config-language --image-on-top"
23 # First step. Describes the functions of the program.
24 # It is possible to set the language.
25 # Also here the user has the ability to stop the program.
26 yad $YADCONF --title="tramys (1/3)" --text="$(_ \
27 'Now translations for all installed programs will be found and downloaded.
28 You can change locale if you want, or proceed.
30 Your current locale: <b>$LANG</b>')" \
31 --button "gtk-edit:2" --button "gtk-cancel:1" --button "gtk-go-forward:0"
32 case $? in
33 2) tazbox locale; . /etc/locale.conf; tramys2; exit 0 ;;
34 1) exit 0 ;;
35 esac
37 # your locale -> HTTP_ACCEPT_LANGUAGE
38 # your SliTaz release -> HTTP_ACCEPT (different releases have different translations)
39 # your installed packages list -> HTTP_COOKIE (list=...)
40 # Note clean address "tramys2.cgi" in the server access logs.
41 #
42 # Server sending and Yad shows user useful info using log widget.
43 # We are temporarily stored this log in the $LOG file in order to get
44 # a download token (see below).
45 # Here the user can refuse to download the file.
46 busybox wget --header "Accept-Language: $LANG" \
47 --header "Accept: $(cat /etc/slitaz-release)" \
48 --header "Cookie: list=$(cd $INSTALLED; ls -1 | tr '\n' ' ')" \
49 $URL -O - | tee $LOG | \
50 yad $YADCONF --title="tramys (2/3)" --progress --width=320 --text="$(_ \
51 'The server processes the request.
52 Please wait.')" \
53 --enable-log --log-expanded \
54 --button "gtk-cancel:1" --button "gtk-go-forward:0"
55 ANSWER=$?
57 # In the last line of log server gives us a download token.
58 # We can download archive which the server has prepared for us.
59 # Get download token and remove log.
60 DLKEY=$(tail -n1 $LOG); rm -f $LOG
62 case $ANSWER in
63 1)
64 # We need to remove archive that the user has refused to download.
65 # This command passed in HTTP_COOKIE (rm=...)
66 busybox wget --header "Cookie: rm=$DLKEY" $URL -O /dev/null; exit 0 ;;
67 esac
69 # We want to download the file. Show pulsate progress bar.
70 # This command passed in HTTP_COOKIE (dl=...)
71 # Also here the user can terminate file downloading.
72 busybox wget --header "Cookie: dl=$DLKEY" $URL -O $TGZ 2>&1 | \
73 yad $YADCONF --title="tramys (3/3)" --progress --pulsate --width=320 \
74 --text="$(_ \
75 'Downloading in progress.
76 Please wait.')" \
77 --button "gtk-cancel:1" --button "gtk-ok:0"
78 case $? in
79 1) exit 0 ;;
80 esac | \
82 # Unpack archive content to a temporary folder.
83 busybox tar -xz -C $WORKING -f $TGZ
84 # All folders and files in the archive are owned by user www and group www.
85 # This is because the CGI script on the server is executed by the user www.
86 # If we had just unpacked the archive content into our file system, then there
87 # would be a big trouble. For example, all folders: /, /usr, /usr/share,
88 # /usr/share/locale, etc. would be owned by user www and become unavailable
89 # for a regular user. So force all folders and files to root own.
90 chown -R root:root $WORKING
92 # Create or recreate virtual package "tramys-data".
93 # It contains all translations.
94 # And you can remove it if you no longer need translations.
95 TD=$INSTALLED/tramys-data
96 mkdir -p $TD
97 cat <<EOT > $TD/receipt
98 # SliTaz package receipt.
100 PACKAGE="tramys-data"
101 VERSION="$(date +%y%m%d)"
102 CATEGORY="system-tools"
103 SHORT_DESC="This package contains translation files installed by tramys-client"
104 MAINTAINER="you@slitaz.org"
105 LICENSE="GPL"
106 WEB_SITE="http://www.slitaz.org/"
107 DEPENDS="tramys-client"
108 EOT
109 # Update files list.
110 cd $WORKING; find . -type f | sed 's|^./|/|g' >> $TD/files.list
111 sort -u $TD/files.list -o $TD/files.list
113 # copy all translation files to root file system.
114 cp -fpr $WORKING/* /
116 # Recreate md5sums.
117 md5sum $(cat $TD/files.list) > $TD/md5sum
119 # remove temporary folder and file, they are no longer needed.
120 rm -f $TGZ
121 rm -rf $WORKING
123 # Final message.
124 yad $YADCONF --title="tramys" --text="$(_ \
125 'Translation files have been installed in your system.')"