aboutsummaryrefslogtreecommitdiffstats
path: root/build-updated-packages.bash
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2014-09-17 22:00:06 +0100
committerJohannes Löthberg <johannes@kyriasis.com>2014-09-17 22:00:06 +0100
commit4fa7ba7dfaec774f246a1b4caedcd65fc4e3cd6f (patch)
tree23965a4e8d2b947f135503eea448b2850bd2b78e /build-updated-packages.bash
parenta6a584551a53928abfb1e9211df1563a89f6d5ce (diff)
downloadvcs-rebuild-4fa7ba7dfaec774f246a1b4caedcd65fc4e3cd6f.tar.xz
Refactor rebuild script
* Use one get_pkgver_sha() function for getting the commit SHA from the pkgver variable of a PKGBUILD * `makepkg --nobuild` updates the pkgver too, so store the old commit sha in an associative array using get_pkgver_sha before running `makepkg --nobuild`. * After updating the repos use get_pkgver_sha again to check whether the new pkgver is the same as the previous one using get_pkgver_sha() instead of the old monstreous get_new_commit() function. If it is do nothing, if not add the package to the list of packages to rebuild. * Use config.bash for configuration variables instead of keeping them inside the script. * Drop the packages associate array since makepkg is now used to refresh repositories and make it a normal array just containing the names of vcs packages instead. * Since makepkg takes care of refreshing repos we don't need to keep track of the branches ourself, so drop the branches associative array from the package list file.
Diffstat (limited to 'build-updated-packages.bash')
-rwxr-xr-xbuild-updated-packages.bash57
1 files changed, 15 insertions, 42 deletions
diff --git a/build-updated-packages.bash b/build-updated-packages.bash
index 48edafb..4e03d3f 100755
--- a/build-updated-packages.bash
+++ b/build-updated-packages.bash
@@ -1,82 +1,55 @@
#!/usr/bin/env bash
-source "$HOME"/.makepkg.conf
-source $(dirname $0)/package-list.bash
+source $(dirname $0)/config.bash
-cd "$HOME"/packaging/pkgbuilds
+cd "$PKGBUILD_DIR"
##
-# Get commit of the laste built package from pkgver of PKGBUILD
+# Get commit sha from PKGVER of PKGBUILD
#
# Arguments:
-# $1 Path to the directory of the PKGBUILD to get te old commit from.
-get_old_commit() {
+# $1 Path to the directory containing the PKGBUILD
+# to get the sha from
+get_pkgver_sha() {
(source "$1"/PKGBUILD
printf "%s" "$(sed -r 's/.*\.r[0-9]*\.g?//' <<<$pkgver)")
}
##
-# 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
-}
-
+# Rebuild the repository using repose
build_repository() {
- REPOSE_BINARY="$HOME"/packaging/vodik-repose/repose
- DATABASE=kyriasis
- ROOT="$HOME"/packaging/repo
- POOL="$HOME"/packaging/built_packages
"$REPOSE_BINARY" "$DATABASE" --root "$ROOT" --pool "$POOL" -v
}
main() {
- for package in "${!packages[@]}"; do
+ for package in "${packages[@]}"; do
+ old_version[$package]=$(get_pkgver_sha "$package")
(cd "$package"
makepkg --nobuild &>/dev/null) &
done
wait
local needs_rebuild=()
- for package in "${!packages[@]}"; do
- old_commit=$(get_old_commit $package)
- new_head=$(get_new_commit "$SRCDEST"/"${packages[$package]}" "${branches[$package]}")
+ for package in "${packages[@]}"; do
+ new_head=$(get_pkgver_sha "$package")
- if [[ "$old_commit" != "$new_head" ]]; then
+ if [[ "${old_version[$package]}" != "$new_head" ]]; then
needs_rebuild+=("$package")
fi
done
if [[ ${#needs_rebuild[@]} -eq 0 ]]; then
- printf "%s\n" "No VCS packages found that needs rebuilding."
+ printf "%s\n" "No VCS packages found that needs to be rebuilt."
else
- print "Packages that needs rebuilding:"
+ printf "Packages that needs to be rebuilt:"
printf "%s\n" "${needs_rebuild[@]}"
for package in "${needs_rebuild[@]}"; do
(cd "$package"
makepkg -src --noconfirm 2>/dev/null) &
done
+ wait
fi
- wait
build_repository
}