OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.0 KiB

  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 - 2006 The T2 SDE Project
  6. # Copyright (C) 1998 - 2003 Clifford Wolf
  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 ---
  15. select_packages() {
  16. local namever installed uninstalled
  17. for (( ; ; )) ; do
  18. cmd="gui_menu gastone 'Install/Remove packages: $5
  19. Note: any (un)installations are done immediately'"
  20. installed=""
  21. uninstalled=""
  22. for (( i=${#pkgs[@]} - 1; i >= 0; i-- )) ; do
  23. if echo "${cats[$i]}" | grep -q -F "$5" ; then
  24. namever="${pkgs[$i]}-${vers[$i]}"
  25. if [ -f $2/var/adm/packages/${pkgs[$i]} ] ; then
  26. cmd="$cmd '[*] $namever' '$packager -r -R $2 ${pkgs[$i]}'"
  27. installed="$installed ${pkgs[$i]}"
  28. elif [ -f "$4/$1/pkgs/$namever$ext" ] ; then
  29. cmd="$cmd '[ ] $namever' '$packager -i -R $2 $4/$1/pkgs/$namever$ext'"
  30. uninstalled="$uninstalled $namever$ext"
  31. elif [ -f "$4/$1/pkgs/${pkgs[$i]}$ext" ] ; then
  32. cmd="$cmd '[ ] $namever' '$packaher -i -R $2 $4/$1/pkgs/${pkgs[$i]}$ext'"
  33. uninstalled="$uninstalled ${pkgs[$i]}$ext"
  34. fi
  35. fi
  36. done
  37. [ "$uninstalled$installed" ] && cmd="$cmd '' ''"
  38. [ "$uninstalled" ] && \
  39. cmd="$cmd 'Install all packages marked as [ ]' '(cd $4/$1/pkgs ; $packager -i -R $2 $uninstalled)'"
  40. [ "$installed" ] && \
  41. cmd="$cmd 'Uninstall all packages marked as [*]' '$packager -r -R $2 $installed'"
  42. eval "$cmd" || break
  43. done
  44. }
  45. main() {
  46. if ! [ -f $4/$1/pkgs/packages.db ] ; then
  47. gui_message "gas: package database not accessible."
  48. return
  49. fi
  50. if ! [ -d $2 ] ; then
  51. gui_message "gas: target directory not accessible."
  52. return
  53. fi
  54. if [ $2 = "${2#/}" ] ; then
  55. gui_message "gas: target directory not absolute."
  56. return
  57. fi
  58. local packager ext
  59. if type -p bize > /dev/null && ! type -p mine > /dev/null ; then
  60. packager=bize
  61. ext=.tar.bz2
  62. else
  63. packager=mine
  64. ext=.gem
  65. fi
  66. declare -a pkgs vers cats
  67. local a b category
  68. unset package
  69. while read a b ; do
  70. if [ "$a" = "[C]" ] ; then cats[${#pkgs[@]}]="${cats[${#pkgs[@]}]} $b"
  71. elif [ "$a" = "[V]" ] ; then vers[${#pkgs[@]}]="$b"
  72. elif [ -z "$b" ] ; then
  73. pkgs[${#pkgs[@]}]="$package"
  74. vers[${#pkgs[@]}]="0.0"
  75. cats[${#pkgs[@]}]="all/all"
  76. package="$a"
  77. else
  78. gui_message "gas: invalid package database input '$a $b'."
  79. return
  80. fi
  81. done < <( gzip -d < $4/$1/pkgs/packages.db | grep "^[a-zA-Z0-9_+.-]\+$\|^\[[CV]\]")
  82. [ "$package" ] && pkgs[${#pkgs[@]}]="$package"
  83. category="gui_menu category 'Select category'"
  84. for i in `echo ${cats[@]} | sed -e 's/ /\n/g' | sort -u` ; do
  85. category="$category $i 'select_packages $1 $2 $3 $4 $i'"
  86. done
  87. while eval "$category" ; do : ; done
  88. }