Skip to content
Browse files

Make metadata checking more robust, and add a switch to have the buil…

…d die if barclamp package metadata needs an update.
  • Loading branch information...
1 parent 3b2c9a2 commit 614be96b7eebf93d161e88693e6604e89c49309c @VictorLowther VictorLowther committed Jan 25, 2012
Showing with 24 additions and 5 deletions.
  1. +1 −1 barclamps/crowbar
  2. +1 −0 build_crowbar.sh
  3. +3 −4 build_lib.sh
  4. +10 −0 redhat-common/build_lib.sh
  5. +9 −0 ubuntu-common/build_lib.sh
2 barclamps/crowbar
@@ -1 +1 @@
-Subproject commit 0076e447843eb3dabe8f5dba1f1201920b478e42
+Subproject commit 39e70bb441b09611a12851f04a259d2baf26a108
View
1 build_crowbar.sh
@@ -326,6 +326,7 @@ BC_QUERY_STRINGS["os_build_cmd"]="$PKG_TYPE $OS_TOKEN build_cmd"
# can pull packages straight out of the build cache, allowing
# for fully offline builds.
--no-cache-update) shift; ALLOW_CACHE_UPDATE=false;;
+ --no-metadata-update) shift; ALLOW_CACHE_METADATA_UPDATE=false;;
# Go through all the motions, but do not actaully generate
# an ISO at the end. This is useful for generating barclamp
# tarballs.
View
7 build_lib.sh
@@ -415,16 +415,15 @@ cache_rm() {
make_barclamp_pkg_metadata() {
[[ -d $CACHE_DIR/barclamps/$1/$OS_TOKEN/pkgs ]] || return 0
- [[ $CACHE_DIR/barclamps/$1/$OS_TOKEN -nt \
- $CACHE_DIR/barclamps/$1/$OS_TOKEN/pkgs ]] && return 0
+ __barclamp_pkg_metadata_needs_update "$bc" || return 0
+ [[ $ALLOW_CACHE_METADATA_UPDATE = false ]] && \
+ die "Need to update cache metadata for $1, but --no-metadata-update passed."
local bc=$1
debug "Updating package cache metadata for $bc"
make_chroot
sudo mount --bind "$CACHE_DIR/barclamps/$bc/$OS_TOKEN/pkgs" "$CHROOT/mnt"
__make_barclamp_pkg_metadata
sudo umount "$CHROOT/mnt"
- sleep 1
- touch "$CACHE_DIR/barclamps/$bc/$OS_TOKEN"
}
install_build_packages() {
View
10 redhat-common/build_lib.sh
@@ -89,9 +89,19 @@ add_repos() {
# Check to see if something is a valid RPM package name.
is_pkg() { [[ $1 = *.rpm ]]; }
+__barclamp_pkg_metadata_needs_update() (
+ cd "$CACHE_DIR/barclamps/$1/$OS_TOKEN/pkgs"
+ [[ -d repodata ]] || return 0
+ while read fname; do
+ [[ $fname -nt repodata ]] && return 0
+ done < <(find . -name '*.rpm' -type f)
+ return 1
+)
+
__make_barclamp_pkg_metadata () {
in_chroot /bin/bash -c "cd /mnt; createrepo -d -q ."
sudo chown -R "$(whoami)" "$CACHE_DIR/barclamps/$bc/$OS_TOKEN/pkgs"
+ touch "$CACHE_DIR/barclamps/$bc/$OS_TOKEN/pkgs/repodata"
if [[ $CURRENT_CACHE_BRANCH ]]; then
CACHE_NEEDS_COMMIT=true
in_cache git add "barclamps/$bc/$OS_TOKEN/pkgs/repodata"
View
9 ubuntu-common/build_lib.sh
@@ -99,6 +99,15 @@ pkg_name() {
echo "${n%% *}"
}
+__barclamp_pkg_metadata_needs_update() (
+ cd "$CACHE_DIR/barclamps/$1/$OS_TOKEN/pkgs"
+ [[ -f Packages.gz ]] || return 0
+ while read fname; do
+ [[ $fname -nt . ]] && return 0
+ done < <(find . -name '*.deb' -type f)
+ return 1
+)
+
__make_barclamp_pkg_metadata() {
in_chroot /bin/bash -c 'cd /mnt; dpkg-scanpackages . 2>/dev/null |gzip -9 >Packages.gz'
sudo chown -R "$(whoami)" "$CACHE_DIR/barclamps/$bc/$OS_TOKEN/pkgs"

0 comments on commit 614be96

Please sign in to comment.
Something went wrong with that request. Please try again.