Last active
August 29, 2015 14:01
-
-
Save bvaudour/a50c9ed372033f914680 to your computer and use it in GitHub Desktop.
Bash script to get and build an app from KCP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
prefix="https://github.com/KaOS-Community-Packages/" | |
gitapi='Accept: application/vnd.github.v3.text-match+json' | |
if [ $# -eq 1 ]; then | |
name=$1 | |
args="" | |
else | |
name=${@:$#} | |
args=${@:1:$#-1} | |
fi | |
function get() { | |
address="${prefix}${name}.git" | |
git clone $address | |
} | |
function jsonval() { | |
temp=`echo $json | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w $prop | cut -d":" -f2| sed -e 's/^ *//g' -e 's/ *$//g'` | |
echo ${temp##*|} | |
} | |
function search() { | |
json=`curl -H ${gitapi} "https://api.github.com/search/repositories?q=${name}+user:KaOS-Community-Packages"` | |
prop="name:" | |
jsonval $json $prop | |
prop="description:" | |
jsonval $json $prop | |
prop="stargazers_count:" | |
jsonval $json $prop | |
} | |
function install() { | |
cd ${name} | |
echo -e '\033[1;33mDo you want to edit PKGBUILD? [Y/n] \033[m' | |
read reponse | |
case ${reponse} in | |
'Y'|'y') $EDITOR PKGBUILD ;; | |
*) ;; | |
esac | |
makepkg -i | |
cd .. | |
rm -rf ${name} | |
} | |
get | |
cd $name | |
makepkg ${args} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment