1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- #!/bin/bash
- root="$(readlink -f $(dirname $BASH_SOURCE)/..)";
- if [[ "$1" != "" ]];then
- btype="";
- script="";
- if [[ "$2" != "" ]];then
- mkdir -p $root/src/$1;
- ln -s `readlink -f $2` $root/src/$1/source;
- echo "Linked source in $2";
- else
- mkdir -p $root/src/$1/source;
- fi;
- 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 $root/src/$1/PKGBUILD ]];then
- cp $root/etc/PKGBUILD.in $root/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 --tags --long | sed -E 's/([^-]*-g)/r\1/;s/-/./g';\n\telse\n\t\tdate +%Y%m%d;\n\tfi;}"|cat - $root/src/$1/PKGBUILD > /tmp/out && mv /tmp/out $root/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 - $root/src/$1/PKGBUILD > /tmp/out && mv /tmp/out $root/src/$1/PKGBUILD;
- ;;
- script)
- echo -e "pkgver=0.0.0\npkgver() {\n date +%Y%m%d\n}"|cat - $root/src/$1/PKGBUILD > /tmp/out && mv /tmp/out $root/src/$1/PKGBUILD;
- ;;
- esac;
- echo -e "pkgname=$1\n"|cat - $root/src/$1/PKGBUILD > /tmp/out && mv /tmp/out $root/src/$1/PKGBUILD;
- fi;
- file=$root/etc/packages.d/$1;
- touch $file;
- echo "packages+=(\"[name]='$1' [type]='$btype' [script]='$script'\")" > $file;
- echo "Created package $1";
- else
- echo "Usage: $0 <package> [<sourcedir>]";
- fi;
|