X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=build%2Flbuild;h=3f4e5cdd6d85b1bcb31cbdba54fae7149b1068cd;hp=f18a5a31b502510f0a377f9225332d0a2c008537;hb=534e706b61114bbb6a462c0b9c911d42a1498f23;hpb=9eccc6cc308e931d9c6040714caffdaef62a56f9 diff --git a/build/lbuild b/build/lbuild index f18a5a3..3f4e5cd 100755 --- a/build/lbuild +++ b/build/lbuild @@ -1103,45 +1103,60 @@ EOF } store_for_reuse() { - local articles="$1" - local module="$2" - local location="$3" - local signature="$4" - local use_links="$5" + local articles="$1" + local module="$2" + local location="$3" + local signature="$4" + local use_links="$5" - local linkflag="" - if $use_links; then - linkflag="l" - fi + local linkflag="" + if $use_links; then + linkflag="l" + fi - location="$location"/"$signature"/"$module" - mkdir -p "$location" - # the cleanup script removes any directory that doesn't have a - # .lastused, so let's try to prevent that as soon as we can - # this solution still slightly racy with the cleanup script - # but the race is a lot tighter now - touch -t 197001010000 "$location/.lastused" - ## use eval/echo here to make sure shell expansions are performed - #if ! cp -a${linkflag} $(eval echo $articles) "$location"; then - local article - for article in $(eval echo $articles); do - if ! cp -a${linkflag} "$article" "$location"; then - error "Failed to copy \"$article\" to \"$location\" in store_for_reuse()" - # rename the cache location so that it's not cached - # product, but is around for analysis - mv "$location"{,-bad-$(date +%s)} || - error "failed to clean up a failed cache attempt" \ - "in \"$location\" -- manual cleanup will be" \ - "necessary" - return 1 - fi - done + local default_iface=$(/sbin/ip route get 192.1.1.1 | sed -ne 's/.* dev \(.*\) * src .*/\1/p') + if [ -z "$default_iface" ]; then + fatal 1 "Failed to determine the default route interface" + fi + local unique_id=$(/sbin/ip addr show dev $default_iface | sed -ne '/ inet /s/ *inet \(.*\)\/.*/\1/p' | head -1) + if [ -z "$unique_id" ]; then + fatal 1 "Failed to determine a unique id from interface $default_interface" + fi - # flag the cache as complete (i.e. in case lbuild was previously - # interrupted while caching) - touch "$location/.lastused" + local finallocation="$location"/"$signature"/"$module" + location="$location"/"$signature-${unique_id}"/"$module" + mkdir -p "$location" + # the cleanup script removes any directory that doesn't have a + # .lastused, so let's try to prevent that as soon as we can + # this solution still slightly racy with the cleanup script + # but the race is a lot tighter now + touch -t 197001010000 "$location/.lastused" + ## use eval/echo here to make sure shell expansions are performed + #if ! cp -a${linkflag} $(eval echo $articles) "$location"; then + local article + for article in $(eval echo $articles); do + if ! cp -a${linkflag} "$article" "$location"; then + error "Failed to copy \"$article\" to \"$location\" in store_for_reuse()" + # rename the cache location so that it's not cached + # product, but is around for analysis + mv "$location"{,-bad-$(date +%s)} || + error "failed to clean up a failed cache attempt" \ + "in \"$location\" -- manual cleanup will be" \ + "necessary" + return 1 + fi + done - return 0 + # flag the cache as complete (i.e. in case lbuild was previously + # interrupted while caching) + touch "$location/.lastused" + + # put the temporary location into the final location + # (last one wins) + mkdir -p "${finallocation%/*}" + mv "$location" "$finallocation" + rmdir "${location%/*}" + return 0 }