package-mod 961 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. root="$(readlink -f $(dirname $BASH_SOURCE)/..)";
  3. . $root/etc/packages.conf
  4. this="";
  5. package(){
  6. for val in "${packages[@]}"; do
  7. unset p;
  8. declare -A p;
  9. eval "p=($val)";
  10. if [[ "${p[name]}" == "$1" ]];then
  11. echo $val;
  12. fi;
  13. done;
  14. }
  15. save(){
  16. local file="packages+=(\"";
  17. for i in "${!this[@]}"; do
  18. file="$file [$i]='${this[$i]}'";
  19. done;
  20. file="$file\")";
  21. echo $file>$root/etc/packages.d/${this[name]};
  22. exit 0;
  23. }
  24. case $1 in
  25. ignore)
  26. if [[ "$2" != "" ]];then
  27. unset this;
  28. declare -A this;
  29. p=$(package $2);
  30. eval "this=($p)";
  31. if [[ $p != "" ]];then
  32. this[ignore]="true";
  33. echo ${this};
  34. save;
  35. fi;
  36. fi;
  37. echo "Usage $0 ignore <package>";
  38. ;;
  39. unignore)
  40. if [[ "$2" != "" ]];then
  41. unset this;
  42. declare -A this;
  43. p=$(package $2);
  44. eval "this=($p)";
  45. if [[ $p != "" ]];then
  46. this[ignore]="";
  47. save;
  48. fi;
  49. fi;
  50. echo "Usage $0 unignore <package>";
  51. ;;
  52. *)
  53. echo "Usage: $0 <command>";
  54. ;;
  55. esac;