Dash:
[t2.git] / package / base / stone / stone_mod_gas.sh
blob7f95907b60596f094d584df4d5bde255dd6bd5a6
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/.../stone/stone_mod_gas.sh
5 # Copyright (C) 2004 - 2005 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
7 #
8 # More information can be found in the files COPYING and README.
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
16 select_packages() {
17 local namever installed uninstalled
19 for (( ; ; )) ; do
20 cmd="gui_menu gastone 'Install/Remove packages: $5
22 Note: any (un)installations are done immediately'"
24 installed=""
25 uninstalled=""
26 for (( i=${#pkgs[@]} - 1; i >= 0; i-- )) ; do
27 if echo "${cats[$i]}" | grep -q -F "$5" ; then
28 namever="${pkgs[$i]}-${vers[$i]}"
29 if [ -f $2/var/adm/packages/${pkgs[$i]} ] ; then
30 cmd="$cmd '[*] $namever' '$packager -r -R $2 ${pkgs[$i]}'"
31 installed="$installed ${pkgs[$i]}"
32 elif [ -f "$4/$1/pkgs/$namever$ext" ] ; then
33 cmd="$cmd '[ ] $namever' '$packager -i -R $2 $4/$1/pkgs/$namever$ext'"
34 uninstalled="$uninstalled $namever$ext"
35 elif [ -f "$4/$1/pkgs/${pkgs[$i]}$ext" ] ; then
36 cmd="$cmd '[ ] $namever' '$packaher -i -R $2 $4/$1/pkgs/${pkgs[$i]}$ext'"
37 uninstalled="$uninstalled ${pkgs[$i]}$ext"
40 done
41 [ "$uninstalled$installed" ] && cmd="$cmd '' ''"
42 [ "$uninstalled" ] && \
43 cmd="$cmd 'Install all packages marked as [ ]' '(cd $4/$1/pkgs ; $packager -i -R $2 $uninstalled)'"
44 [ "$installed" ] && \
45 cmd="$cmd 'Uninstall all packages marked as [*]' '$packager -r -R $2 $installed'"
47 eval "$cmd" || break
48 done
51 main() {
52 if ! [ -f $4/$1/pkgs/packages.db ] ; then
53 gui_message "gas: package database not accessible."
54 return
57 if ! [ -d $2 ] ; then
58 gui_message "gas: target directory not accessible."
59 return
62 if [ $2 = "${2#/}" ] ; then
63 gui_message "gas: target directory not absolute."
64 return
67 local packager ext
69 if type -p bize > /dev/null && ! type -p mine > /dev/null ; then
70 packager=bize
71 ext=.tar.bz2
72 else
73 packager=mine
74 ext=.gem
77 declare -a pkgs vers cats
78 local a b category
79 unset package
81 while read a b ; do
82 if [ "$a" = "[C]" ] ; then cats[${#pkgs[@]}]="${cats[${#pkgs[@]}]} $b"
83 elif [ "$a" = "[V]" ] ; then vers[${#pkgs[@]}]="$b"
84 elif [ -z "$b" ] ; then
85 pkgs[${#pkgs[@]}]="$package"
86 vers[${#pkgs[@]}]="0.0"
87 cats[${#pkgs[@]}]="all/all"
88 package="$a"
89 else
90 gui_message "gas: invalid package database input '$a $b'."
91 return
93 done < <( gzip -d < $4/$1/pkgs/packages.db | grep "^[a-zA-Z0-9_+.-]\+$\|^\[[CV]\]")
94 [ "$package" ] && pkgs[${#pkgs[@]}]="$package"
96 category="gui_menu category 'Select category'"
97 for i in `echo ${cats[@]} | sed -e 's/ /\n/g' | sort -u` ; do
98 category="$category $i 'select_packages $1 $2 $3 $4 $i'"
99 done
100 while eval "$category" ; do : ; done