Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

125 lines (110 sloc) 3.507 kb
#!/bin/zsh
# Declare colours for easy access
GREEN='\e[1;32m'
RED='\e[1;31m'
YELLOW='\e[1;33m'
WHITE='\e[1;37m'
COLRESET='\e[0m'
# Set EDITOR to user default, falling back on vi
EDITOR=${EDITOR:-/usr/bin/vi}
# Unset problematic variables, and reset _built
unset _built
unset epoch
# cd to build directory, download PKGBUILD, show for editing, then automatically build package
function normalbuild () {
if [ -e PKGBUILD ]; then
"${EDITOR}" PKGBUILD && sudo extra-x86_64-build && _built=true
else
echo "${RED}==>${WHITE} No PKGBUILD found${COLRESET}"
return 1
fi
}
function multibuild {
if [ -e PKGBUILD ]; then
"${EDITOR}" PKGBUILD && sudo multilib-build && _built=true
else
echo "${RED}==>${WHITE} No PKGBUILD found${COLRESET}"
return 1
fi
}
function getsources {
cd ~/builds
if [[ ! $2 == "skip" ]]; then
echo "${YELLOW}==>${WHITE} Downloading sources${COLRESET}"
yaourt -G $1
fi
if [ -d $1 ]; then
cd $1
else
echo "${RED}==> ERROR:${WHITE} No such package${COLRESET}"
return 1
fi
}
# If build was successful
function postbuild {
# If DISPLAY is set and notify-send is installed, send an "urgent" notification
# that compilation has finished, either successfully or otherwise.
if [ $DISPLAY ]; then
if [ -x "$(where notify-send)" ]; then
STATUS="FAILED"
[ $_built ] && STATUS="SUCCESS"
notify-send -u critical -a xfce4-notifyd -i xfce4-notifyd "Compilation of package $1 is now complete. Compilation ${STATUS}!"
fi
fi
if [ $_built ]; then
unset all
# Load PKGBUILD variables
source PKGBUILD &> /dev/null
# Check for package archetecture
if [[ $arch != "any" ]]; then
arch=$(uname -m)
fi
# Create _ver
_ver=${pkgver}-${pkgrel}-${arch}.pkg.tar.xz
# Check for epoch var, and add to _ver if present
[ $epoch ] && _ver=${epoch}:${_ver}
# Check for multi-package
if [[ $(echo $pkgname | wc -w) -gt 1 ]]; then
# Add package names to array
x=1
foreach i in $pkgname; do
all[${x}]=${i}-${_ver}
x=$((x+1))
done
# Check first package exists, confirm completion, and prompt user to install
[ -f ${pkgname[1]}-${_ver} ] && echo "${GREEN}==>${WHITE} Compilation complete. Multiple packages detected. Names stored in \$all${COLRESET}"
return 0
fi
# Declare _pkg for easy installation/copying
_pkg=${pkgname}-${_ver}
# Check package exists, confirm completion, and prompt user to install
if [ -f ${_pkg} ]; then
echo "${GREEN}==>${WHITE} Compilation complete, installing...${COLRESET}"
term="/dev/$(ps -p$$ -o tty="")"
exec < $term
sudo pacman -U ${_pkg}
else
echo "${RED}==>${WHITE} Could not find '${_pkg}', install manually${COLRESET}"
return 1
fi
return 0
fi
}
function getfiles {
cd ~/builds
echo "${YELLOW}==>${WHITE} Downloading sources${COLRESET}"
_rawhtml=$(curl -s -f "https://projects.archlinux.org/svntogit/packages.git/plain/$1/trunk/" || curl -s -f "https://projects.archlinux.org/svntogit/community.git/plain/$1/trunk/")
if [ ! $_rawhtml ] && return 1
_filelist=$(echo $_rawhtml | grep "\<li\>" | sed 1d | cut -d "'" -f 2)
if [ -d $1 ]; then
cd $1
else
mkdir $1
cd $1
fi
for _file in $(echo $_filelist); do
_filename=$(echo $_file | cut -d "/" -f 6 | sed 's:\?.*::')
rm -f $_filename
curl -s -O "https://projects.archlinux.org/$_file" > $_filename
done
}
Jump to Line
Something went wrong with that request. Please try again.