From 8e34420da93d005a36eaff4936f0f6c5652db726 Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Wed, 13 Aug 2014 23:52:29 +0100 Subject: init commit --- build-updated-packages.bash | 89 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100755 build-updated-packages.bash (limited to 'build-updated-packages.bash') diff --git a/build-updated-packages.bash b/build-updated-packages.bash new file mode 100755 index 0000000..3c0aae8 --- /dev/null +++ b/build-updated-packages.bash @@ -0,0 +1,89 @@ +#!/usr/bin/env bash + +. "$HOME"/.makepkg.conf + +cd "$HOME"/packaging/pkgbuilds + +source $(dirname $0)/package-list.bash + +need_rebuild=() + +#for package in "${!packages[@]}"; do +# if [[ -d "$package" ]]; then +# cd "$package" +# (makepkg -src --noconfirm) & +# cd - +#done + +## +# Buils the given package +# +# Arguments: +# $1: Directory that contains the PKGBUILD of the +# package to build. +build_package() { + if [[ -d "$1" ]]; then + (cd "$1" + makepkg -src --noconfirm 2>/dev/null) + fi +} + +## +# Get newest commit of VCS repo. +# +# Arguments: +# $1 Path to the directory of the VCS repo. +# $2 Name of the ref to get the newest commit of +get_new_commit() { + if [[ -d "$1" ]]; then + (cd "$1" + if [[ -d .hg ]]; then + hg update &>/dev/null + printf "%s" "$(hg log -r "." --template "{node|short}")" + elif [[ -n "$(git config --get core.bare)" ]]; then + if [[ -n "$2" ]]; then + local ref="$2" + else + local ref=HEAD + fi + printf "%s" "$(git rev-parse --short $ref)" + fi) + else + printf "%s\n" "Repository to get commit from not found" 1>&2 + fi +} + +## +# Get commit of the laste built package from pkgver of PKGBUILD +# +# Arguments: +# $1 Path to the directory of the PKGBUILD to get te old commit from. +get_old_commit() { + (source "$1"/PKGBUILD + printf "%s" "$(sed -r 's/.*\.r[0-9]*\.g?//' <<<$pkgver)") +} + +for package in "${!packages[@]}"; do + new_head=$(get_new_commit "$SRCDEST"/"${packages[$package]}" "${branches[$package]}") + + old_commit=$(get_old_commit $package) + +# printf "%-30s\t\t%s\t\t%s\n" $package $old_commit $new_head + if [[ "$old_commit" != "$new_head" ]]; then + need_rebuild+=("$package") + fi +done + +if [ ${#need_rebuild[@]} -eq 0 ]; then + printf "%s" "No VCS packages needing rebuilding." +else + printf "%s" "Packages needing rebuilding: " + for package in "${need_rebuild[@]}"; do + printf "%s" "$package" + build_package "$package" &>/dev/null & + done +fi +wait + +printf "\n" +"$HOME"/packaging/vodik-repose/repose kyriasis -r "$HOME"/packaging/repo -p "$HOME"/packaging/built_packages -v -- cgit v1.2.3-54-g00ecf