-
-
Save Gen2ly/2974884 to your computer and use it in GitHub Desktop.
Common makepkg building tasks
This file contains hidden or 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 | |
# Common makepkg building tasks | |
mntr_info="Gen2ly <[email protected]>" | |
usage () { | |
echo " ${0##*/} <option> - common makepkg building tasks | |
b - build package (install dependencies if required) | |
m - update md5sums | |
r - remove previous build directories | |
s - create source files for upload | |
t - create PKGBUILD template | |
--- | |
a - AUR submit" | |
} | |
pkgbldtst () { | |
[ ! -f PKGBUILD ] && echo " No PKGBUILD in directory." && exit | |
} | |
md5add () { | |
# Delete previous md5sum entries | |
sed -i "/^.*'[a-z0-9]\{32\}'.*$/d" PKGBUILD | |
sed -i "/^md5sums/,/$/d" PKGBUILD | |
# Save then delete the build section | |
sed -e '/^build().*$/,$!d' PKGBUILD > /tmp/PKGBUILD.tmp | |
sed -i '/^build().*$/,$d' PKGBUILD | |
# Remove trailing blank lines so md5sums line follows last line | |
while [ "$(tail -n 1 PKGBUILD)" == "" ]; do | |
sed -i '$d' PKGBUILD | |
done | |
# Add md5sums | |
makepkg -g >> PKGBUILD | |
# Add blank line to seperate variable and build section | |
echo >> PKGBUILD | |
# Re-append build section | |
cat /tmp/PKGBUILD.tmp >> PKGBUILD | |
# Remove trailing blank lines to clean up | |
while [ "$(tail -n 1 PKGBUILD)" == "" ]; do | |
sed -i '$d' PKGBUILD | |
done | |
echo " Added md5sums" | |
} | |
bldsource () { | |
makepkg -f --source | |
} | |
bldsubmit () { | |
while true; do | |
read -p " Upload source to the AUR? (y/n): " yn | |
case $yn in | |
[Yy]* ) ctgrs=$(burp -c help | sed '1d' | sed '$d' | sed 's/^\t//g') | |
printf " Select category:\n" | |
select ctgr in $ctgrs; do | |
test -n $ctgr && break | |
echo " Select 1, 2, ..." | |
done | |
burp -c $ctgr $(ls -tr | tail -1) | |
break ;; | |
[Nn]* ) break ;; | |
* ) echo " Answer 'y' for yes, 'n' for no." | |
esac | |
done | |
} | |
bldtmpl () { | |
[ ! -f /usr/share/pacman/PKGBUILD.proto ] && \ | |
echo " /usr/share/pacman/PKGBUILD.proto does not exist" && exit | |
cp /usr/share/pacman/PKGBUILD.proto PKGBUILD | |
# Delete description | |
sed -i '1,5d' PKGBUILD | |
# Change 'Maintainer' name and email | |
sed -i "s/^# Maintainer\: .*$/# Maintainer: $mntr_info\n/" PKGBUILD | |
# Use directory name as pkgname | |
sed -i "s/^pkgname=.*$/pkgname=$(basename $(pwd))/" PKGBUILD | |
# Delete md5sums comment | |
sed -i "s/^md5sums=.*$/md5sums=()/" PKGBUILD | |
echo " Created PKGBUILD template" | |
} | |
aurreq () { | |
req_progs=(burp) | |
for p in ${req_progs[@]}; do | |
hash "$p" 2>&- || \ | |
{ echo >&2 " Required program \"$p\" not installed."; exit 1; } | |
done | |
} | |
case $1 in | |
b ) pkgbldtst | |
makepkg -sf ;; | |
m ) pkgbldtst | |
md5add ;; | |
r ) if [ -d src ]; then rm -rf src/ && echo " Removed src/ dir"; fi | |
if [ -d pkg ]; then rm -rf pkg/ && echo " Removed pkg/ dir"; fi ;; | |
s ) pkgbldtst | |
bldsource ;; | |
t ) bldtmpl ;; | |
# --- | |
a ) aurreq | |
bldsubmit ;; | |
* ) usage | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment