package-add 1000 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. if [[ "$1" != "" ]];then
  3. btype="";
  4. script="";
  5. if [[ "$2" != "" ]];then
  6. mkdir -p src/$1;
  7. ln -s `readlink -f $2` src/$1/source;
  8. echo "Linked source in $2";
  9. else
  10. mkdir -p src/$1/source;
  11. fi;
  12. mkdir -p src/$1/pkg
  13. mkdir -p src/$1/src
  14. if [[ ! -f src/$1/PKGBUILD ]];then
  15. cp etc/PKGBUILD.in src/$1/PKGBUILD;
  16. echo -e "pkgname=$1\n"|cat - src/$1/PKGBUILD > /tmp/out && mv /tmp/out src/$1/PKGBUILD;
  17. fi;
  18. if [[ ! -f src/$1/build.sh ]];then
  19. cp etc/build.sh.in src/$1/build.sh
  20. fi;
  21. chmod +x src/$1/build.sh
  22. echo -e "Type:\n (1) script\n (2) git\n (3) svn";
  23. while [[ ! $btype =~ ^1|2|3$ ]]; do
  24. read btype;
  25. done;
  26. case $btype in
  27. 2)
  28. btype="git";
  29. ;;
  30. 3)
  31. btype="svn";
  32. ;;
  33. *)
  34. btype="script";
  35. read -p "Script path: " script;
  36. ;;
  37. esac;
  38. file=`dirname $BASH_SOURCE`/../etc/packages.d/$1;
  39. touch $file;
  40. echo "packages+=(\"[name]='$1' [type]='$btype' [script]='$script'\")" > $file;
  41. echo "Created project $1";
  42. else
  43. echo "Usage: $0 <package> [<sourcedir>]";
  44. fi;