Commit e28ab20c authored by jan.koester's avatar jan.koester
Browse files

build-chroot: update git sources, rebuild packages when their commit changed

fetch_git kept an existing checkout forever and step_packages skipped every
package whose Version-Release RPM existed, so the 20261107 image shipped the
old libnetplus without crypto/dtls.h. Branch checkouts are now fetched and
checked out (fixed tags stay; local changes stop the build instead of being
overwritten), and the commit each git package was built from is recorded.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent ecb13d7d
Loading
Loading
Loading
Loading
+26 −2
Changes for build-chroot.sh: 26 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -502,10 +502,20 @@ step_fresh() {
    run fresh cmake --build "$BUILD/fresh" -j "$JOBS"
}

# fetch_git <dest> <url> [ref] -- shallow clone once; an existing checkout is kept.
# fetch_git <dest> <url> [ref] -- shallow clone; an existing checkout is
# brought up to date (the 20261107 image got a stale libnetplus without
# crypto/dtls.h because the old clone was simply kept). A tag ref is fixed,
# so that checkout stays as it is. Checkout refuses to overwrite local
# changes, so those are never lost -- the build stops instead.
fetch_git() {
    local dest="$1" url="$2" ref="${3:-}"
    [[ -d $dest/.git ]] && return
    if [[ -d $dest/.git ]]; then
        [[ -n $ref ]] && git -C "$dest" rev-parse -q --verify "refs/tags/$ref" >/dev/null && return
        msg "updating $url${ref:+ ($ref)}"
        run fetch git -C "$dest" fetch --depth 1 origin ${ref:+"$ref"}
        run fetch git -C "$dest" -c advice.detachedHead=false checkout -q --detach FETCH_HEAD
        return
    fi
    msg "fetching $url${ref:+ ($ref)}"
    run fetch git -c advice.detachedHead=false clone --depth 1 ${ref:+--branch "$ref"} "$url" "$dest"
}
@@ -1241,6 +1251,9 @@ stage_sources() {
            repo="${url##*/}"; repo="${repo%.git}"
            fetch_git "$WORK/src/$repo" "$url" "$ref"
            tar_tree "$WORK/src/$repo" "$srcdir/$f" "$name-$version"
            # the commit packed now; step_packages rebuilds when it differs
            # from the one the existing RPM was built from
            git -C "$WORK/src/$repo" rev-parse HEAD >"$CHROOT/build/rpmbuild/.src-rev-$pkg"
            continue
        fi
        if [[ $n == Source0 || $n == Source ]]; then
@@ -1415,6 +1428,15 @@ step_packages() {
        existing_rpms="$(cd "$CHROOT" && find build/rpmbuild/RPMS -name "$pkg-$ver-$rel.*.rpm" 2>/dev/null |
                         sed 's|^|/|' | tr '\n' ' ' || true)"
        
        # git-Quellen: gleiche Version-Release, aber neuer Commit -> neu bauen
        local rev_src="" rev_built=""
        [[ -f $CHROOT/build/rpmbuild/.src-rev-$pkg ]] && rev_src="$(<"$CHROOT/build/rpmbuild/.src-rev-$pkg")"
        [[ -f $CHROOT/build/rpmbuild/.built-rev-$pkg ]] && rev_built="$(<"$CHROOT/build/rpmbuild/.built-rev-$pkg")"
        if [[ -n "$existing_rpms" && $rev_src != "$rev_built" ]]; then
            msg "packages: $pkg neu (Quelle ${rev_built:0:12} -> ${rev_src:0:12})"
            existing_rpms=""
        fi

        if [[ -n "$existing_rpms" ]]; then
            msg "packages: überspringe $pkg (bereits gebaut)"
            skipped+=("$pkg")
@@ -1432,6 +1454,8 @@ step_packages() {
        touch "$CHROOT/build/rpmbuild/.built-$pkg"
        if in_chroot rpmbuild -bb --nodeps "/build/rpmbuild/SPECS/$pkg.spec" >"$log" 2>&1; then
            ok+=("$pkg")
            [[ -f $CHROOT/build/rpmbuild/.src-rev-$pkg ]] &&
                cp "$CHROOT/build/rpmbuild/.src-rev-$pkg" "$CHROOT/build/rpmbuild/.built-rev-$pkg"
            
            local rpms
            rpms="$(cd "$CHROOT" && find build/rpmbuild/RPMS -name '*.rpm' -newer "build/rpmbuild/.built-$pkg" |