#!/usr/bin/env bash cd "${0%/*}" . ./rebuild_pkgs.sh pkg_ver() { sed '/^pkgver\=/!d;s/pkgver\=\(.*\)/\1/' PKGBUILD } exit_on_err() { local res=$? echo "error in rebuild, aborting" exit "$res" } higan_make() { make -j12 -C $@ uninstall make -j12 -C $@ clean || exit_on_err make -j12 -C $@ all || exit_on_err make -j12 -C $@ install || exit_on_err } build_package() { cd ~/bin || exit_on_err local pkg=$1 shift local special_handling="None" local makepkg_args="-isrLcCf --noconfirm" local pull_url="https://aur.archlinux.org/$pkg.git" local branch while (( $# )) do case $1 in --handle) special_handling=$2 shift 2 ;; --url) pull_url=$2 shift 2 ;; --branch) branch=-b "$2" shift 2 ;; --asdeps|--skipinteg|-f) makepkg_args+=" $1" shift ;; *) echo "error in rebuild configuration ($1), aborting" exit 1 ;; esac done if [[ ! -d ~/bin/$pkg ]] then git clone $branch "$pull_url" || exit_on_err fi cd "$pkg" || exit_on_err git pull || exit_on_err local new_tag case $special_handling in None) ;; Higan) new_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)") git fetch --tags git checkout "$new_tag" higan_make higan target=higan higan_make icarus make -j12 -C shaders install || exit_on_err return ;; *) echo "incorrect handler ($special_handling), aborting" exit 1 ;; esac makepkg $makepkg_args || exit_on_err } resume_from() { local resume for pkg in ${all_pkgs[*]} do [[ $pkg = "$1" ]] && resume=1 [[ $resume ]] && echo "$pkg" done } main() { local pkg local pkgs while (( $# )) do case $1 in --resume-from) pkgs+=" $(resume_from "$2")" shift 2 ;; *) pkgs+=" $1" shift ;; esac done if [[ ! $pkgs ]] then pkgs=${all_pkgs[*]} fi for pkg in $pkgs do build_package "$pkg" ${options[$pkg]} done } main $@ ## EOF