12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #!/bin/bash
- if [[ "$1" != "" ]];then
- btype="";
- script="";
- if [[ "$2" != "" ]];then
- mkdir -p src/$1;
- ln -s `readlink -f $2` src/$1/source;
- echo "Linked source in $2";
- else
- mkdir -p src/$1/source;
- fi;
- mkdir -p src/$1/pkg
- mkdir -p src/$1/src
- if [[ ! -f src/$1/build.sh ]];then
- cp etc/build.sh.in src/$1/build.sh
- fi;
- chmod +x src/$1/build.sh
- echo -e "Type:\n (1) script\n (2) git\n (3) svn";
- while [[ ! $btype =~ ^1|2|3$ ]]; do
- read btype;
- done;
- case $btype in
- 2)
- btype="git";
- ;;
- 3)
- btype="svn";
- ;;
- *)
- btype="script";
- read -p "Script path: " script;
- ;;
- esac;
- if [[ ! -f src/$1/PKGBUILD ]];then
- cp etc/PKGBUILD.in src/$1/PKGBUILD;
- case $btype in
- git)
- echo -e "pkgver=0.0.0\npkgver() {\n\tcd \"$srcdir/../source\"\n\tif git describe --tags > /dev/null 2>&1;then\n\t\tgit describe --long | sed -E 's/([^-]*-g)/r\1/;s/-/./g';\n\telse\n\t\tdate +%Y%m%d;\n\tfi;}"|cat - src/$1/PKGBUILD > /tmp/out && mv /tmp/out src/$1/PKGBUILD;
- ;;
- svn)
- echo -e "pkgver=0.0.0\npkgver() {\n\tcd \"$srcdir/../source\"\n\tlocal ver="$(svnversion)"\n\tprintf \"r%s\" \"${ver//[[:alpha:]]}\"\n}"|cat - src/$1/PKGBUILD > /tmp/out && mv /tmp/out src/$1/PKGBUILD;
- ;;
- script)
- echo -e "pkgver=0.0.0\npkgver() {\n date +%Y%m%d\n}"|cat - src/$1/PKGBUILD > /tmp/out && mv /tmp/out src/$1/PKGBUILD;
- ;;
- esac;
- echo -e "pkgname=$1\n"|cat - src/$1/PKGBUILD > /tmp/out && mv /tmp/out src/$1/PKGBUILD;
- fi;
- file=`dirname $BASH_SOURCE`/../etc/packages.d/$1;
- touch $file;
- echo "packages+=(\"[name]='$1' [type]='$btype' [script]='$script'\")" > $file;
- echo "Created project $1";
- else
- echo "Usage: $0 <package> [<sourcedir>]";
- fi;
|