aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2014-08-13 23:52:29 +0100
committerJohannes Löthberg <johannes@kyriasis.com>2014-08-13 23:52:29 +0100
commit8e34420da93d005a36eaff4936f0f6c5652db726 (patch)
treebc6728710b3a7c27a7384619d5cc88826f81009c
downloadvcs-rebuild-8e34420da93d005a36eaff4936f0f6c5652db726.tar.xz
init commit
-rwxr-xr-xbuild-updated-packages.bash89
-rw-r--r--package-list.bash21
-rwxr-xr-xpull-vcs-repos.bash13
-rw-r--r--rebuild-vcs-packages.service7
-rw-r--r--rebuild-vcs-packages.timer12
5 files changed, 142 insertions, 0 deletions
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
diff --git a/package-list.bash b/package-list.bash
new file mode 100644
index 0000000..2267646
--- /dev/null
+++ b/package-list.bash
@@ -0,0 +1,21 @@
+declare -A packages=(
+ [cower-git]=cower
+ [elementary-xfce-icons-git]=elementary-xfce
+ [goobook-git]=goobook
+ [gvim-hg]=vim
+ [i3pystatus-git]=i3pystatus
+ [isync-sasl-git]=isync
+ [j4-dmenu-desktop-git]=j4-dmenu-desktop
+ [kittypack-git]=kittypack
+ [mpv-git]=mpv
+ [mutt-kz-git]=mutt-kz
+ [termite-git]=termite
+ [termite-terminfo-git]=termite
+ [vte3-select-text-git]=vte
+ [weechat-git]=weechat
+)
+
+declare -A branches=(
+ [vte3-select-text-git]="vte-0-36"
+ [isync-sasl-git]="sasl"
+)
diff --git a/pull-vcs-repos.bash b/pull-vcs-repos.bash
new file mode 100755
index 0000000..a9b121b
--- /dev/null
+++ b/pull-vcs-repos.bash
@@ -0,0 +1,13 @@
+source $(dirname $0)/package-list.bash
+
+for p in "${!packages[@]}"; do
+ if [[ -d "$p" ]]; then
+ cd "$p"
+ (makepkg --nobuild 2>/dev/null) &
+ cd - 2>/dev/null
+ fi
+done
+
+wait
+
+echo done
diff --git a/rebuild-vcs-packages.service b/rebuild-vcs-packages.service
new file mode 100644
index 0000000..6f1c571
--- /dev/null
+++ b/rebuild-vcs-packages.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Rebuild VCS packages
+
+[Service]
+User=kyrias
+Type=simple
+ExecStart=/home/kyrias/packaging/vcs-rebuild/build-updated-packages.bash
diff --git a/rebuild-vcs-packages.timer b/rebuild-vcs-packages.timer
new file mode 100644
index 0000000..9254394
--- /dev/null
+++ b/rebuild-vcs-packages.timer
@@ -0,0 +1,12 @@
+[Unit]
+Description=Rebuild VCS packages
+
+[Timer]
+# Time to wait after booting before we run first time
+OnBootSec=10min
+# Time between running each consecutive time
+OnUnitActiveSec=1d
+Unit=rebuild-vcs-packages.service
+
+[Install]
+WantedBy=multi-user.target