mirror of the now-defunct rocklinux.org
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.

93 lines
3.1 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/base/sysfiles/stone_mod_gas.sh
  9. # ROCK Linux is Copyright (C) 1998 - 2003 Clifford Wolf
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version. A copy of the GNU General Public
  15. # License can be found at Documentation/COPYING.
  16. #
  17. # Many people helped and are helping developing ROCK Linux. Please
  18. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  19. # file for details.
  20. #
  21. # --- ROCK-COPYRIGHT-NOTE-END ---
  22. select_packages() {
  23. local namever installed uninstalled
  24. for (( ; ; )) ; do
  25. cmd="gui_menu gastone 'Install/Remove packages: $5
  26. Note: any (un)installations are done immediately'"
  27. installed=""
  28. uninstalled=""
  29. time for (( i=${#pkgs[@]} - 1; i >= 0; i-- )) ; do
  30. if echo "${cats[$i]}" | grep -q -F "$5" ; then
  31. namever="${pkgs[$i]}-${vers[$i]}"
  32. if [ -f $2/var/adm/packages/${pkgs[$i]} ] ; then
  33. cmd="$cmd '[*] $namever' 'mine -r -R $2 ${pkgs[$i]}'"
  34. installed="$installed ${pkgs[$i]}"
  35. elif [ -f "$4/$1/pkgs/$namever.gem" ] ; then
  36. cmd="$cmd '[ ] $namever' 'mine -i -R $2 $4/$1/pkgs/$namever.gem'"
  37. uninstalled="$uninstalled $4/$1/pkgs/$namever.gem"
  38. elif [ -f "$4/$1/pkgs/${pkgs[$i]}.gem" ] ; then
  39. cmd="$cmd '[ ] $namever' 'mine -i -R $2 $4/$1/pkgs/${pkgs[$i]}.gem'"
  40. uninstalled="$uninstalled $4/$1/pkgs/${pkgs[$i]}.gem"
  41. fi
  42. fi
  43. done
  44. [ "$uninstalled$installed" ] && cmd="$cmd '' ''"
  45. [ "$uninstalled" ] && \
  46. cmd="$cmd 'Install all packages marked as [ ]' 'mine -i -R $2 $uninstalled'"
  47. [ "$installed" ] && \
  48. cmd="$cmd 'Uninstall all packages marked as [*]' 'mine -r -R $2 $installed'"
  49. eval "$cmd" || break
  50. done
  51. }
  52. main() {
  53. if ! [ -f $4/$1/packages.db ] ; then
  54. gui_message "gas: package database not accessible."
  55. return
  56. fi
  57. if ! [ -d $2 ] ; then
  58. gui_message "gas: target directory not accessible."
  59. return
  60. fi
  61. declare -a pkgs vers cats
  62. local a b category
  63. unset package
  64. while read a b ; do
  65. if [ "$a" = "[C]" ] ; then cats[${#pkgs[@]}]="${cats[${#pkgs[@]}]} $b"
  66. elif [ "$a" = "[V]" ] ; then vers[${#pkgs[@]}]="$b"
  67. elif [ -z "$b" ] ; then
  68. pkgs[${#pkgs[@]}]="$package"
  69. vers[${#pkgs[@]}]="0.0"
  70. cats[${#pkgs[@]}]="all/all"
  71. package="$a"
  72. else
  73. gui_message "gas: invalid package database input '$a $b'."
  74. return
  75. fi
  76. done < <( gzip -d < $4/$1/packages.db | grep "^[a-zA-Z0-9_+.-]\+$\|^\[[CV]\]")
  77. [ "$package" ] && pkgs[${#pkgs[@]}]="$package"
  78. category="gui_menu category 'Select category'"
  79. for i in `echo ${cats[@]} | sed -e 's/ /\n/g' | sort -u` ; do
  80. category="$category $i 'select_packages $1 $2 $3 $4 $i'"
  81. done
  82. while eval "$category" ; do : ; done
  83. }