* added python-argocomplete (3.5.0) - Easy, extensible command line tab completion...
[t2sde.git] / package / base / stone / stone_mod_gas.sh
blobafbbea66d1d8a48a818ba3c7d82aa96eb2fbfdf1
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/stone/stone_mod_gas.sh
3 # Copyright (C) 2004 - 2022 The T2 SDE Project
4 # Copyright (C) 1998 - 2003 ROCK Linux Project
5 #
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2.
11 # --- T2-COPYRIGHT-NOTE-END ---
13 select_packages() {
14 local namever installed uninstalled
16 for (( ; ; )) ; do
17 cmd="gui_menu gastone 'Install/Remove packages: $5
19 Note: any (un)installations are done immediately'"
21 installed=""
22 uninstalled=""
23 for (( i=${#pkgs[@]} - 1; i >= 0; i-- )) ; do
24 if echo "${cats[$i]}" | grep -q -F "$5"; then
25 namever="${pkgs[$i]}-${vers[$i]}"
26 if [ -f $2/var/adm/packages/${pkgs[$i]} ]; then
27 cmd="$cmd '[*] $namever' '$packager -r -R $2 ${pkgs[$i]}'"
28 installed="$installed ${pkgs[$i]}"
29 elif [ -f "$4/$1/pkgs/$namever$ext" ]; then
30 cmd="$cmd '[ ] $namever' '$packager -i -R $2 $4/$1/pkgs/$namever$ext'"
31 uninstalled="$uninstalled $namever$ext"
32 elif [ -f "$4/$1/pkgs/${pkgs[$i]}$ext" ]; then
33 cmd="$cmd '[ ] $namever' '$packaher -i -R $2 $4/$1/pkgs/${pkgs[$i]}$ext'"
34 uninstalled="$uninstalled ${pkgs[$i]}$ext"
37 done
38 [ "$uninstalled$installed" ] && cmd="$cmd '' ''"
39 [ "$uninstalled" ] && \
40 cmd="$cmd 'Install all packages marked as [ ]' '(cd $4/$1/pkgs ; $packager -i -R $2 $uninstalled)'"
41 [ "$installed" ] && \
42 cmd="$cmd 'Uninstall all packages marked as [*]' '$packager -r -R $2 $installed'"
44 eval "$cmd" || break
45 done
48 main() {
49 if ! [ -f $4/$1/pkgs/packages.db ]; then
50 gui_message "gas: package database not accessible."
51 return
54 if ! [ -d $2 ]; then
55 gui_message "gas: target directory not accessible."
56 return
59 if [ $2 = "${2#/}" ]; then
60 gui_message "gas: target directory not absolute."
61 return
64 local packager ext
66 if type -p bize > /dev/null && ! type -p mine > /dev/null; then
67 packager=bize
68 ext=.tar.bz2
69 else
70 packager=mine
71 ext=.gem
74 declare -a pkgs vers cats
75 local a b category
76 unset package
78 while read a b ; do
79 if [ "$a" = "[C]" ]; then cats[${#pkgs[@]}]="${cats[${#pkgs[@]}]} $b"
80 elif [ "$a" = "[V]" ]; then vers[${#pkgs[@]}]="$b"
81 elif [ -z "$b" ]; then
82 pkgs[${#pkgs[@]}]="$package"
83 vers[${#pkgs[@]}]="0.0"
84 cats[${#pkgs[@]}]="all/all"
85 package="$a"
86 else
87 gui_message "gas: invalid package database input '$a $b'."
88 return
90 done < <( gzip -d < $4/$1/pkgs/packages.db | grep "^[a-zA-Z0-9_+.-]\+$\|^\[[CV]\]")
91 [ "$package" ] && pkgs[${#pkgs[@]}]="$package"
93 category="gui_menu category 'Select category'"
94 for i in `echo ${cats[@]} | sed -e 's/ /\n/g' | sort -u` ; do
95 category="$category $i 'select_packages $1 $2 $3 $4 $i'"
96 done
97 while eval "$category" ; do : ; done