2
0
mirror of https://github.com/xcat2/xcat-dep.git synced 2026-09-12 12:36:23 +00:00
Files
xcat-dep/ipmitool/sbuild.pl
T
Daniel Hilst b72139c18c refactor(xcat-dep): make each <dep>/sbuild.pl a true per-package builder
The per-package <dep>/sbuild.pl were generic wrappers that shelled out to each
package's make_deb.sh, so a package's build brain was split across two files and
package-specific fixes (e.g. goconserver's Go toolchain) landed in make_deb.sh
instead of the builder -- inconsistent with the EL side, where <dep>/mockbuild.pl
IS the per-package builder.

Make each <dep>/sbuild.pl own its build (mirroring <dep>/mockbuild.pl), absorbing
its make_deb.sh (source prep, patches, toolchain, dpkg-buildpackage), and remove
all seven make_deb.sh. The common chroot orchestration -- ephemeral schroot session,
apt update, build-dep install, out-of-tree copy, SOURCE_DATE_EPOCH, deb collection +
host-side verification -- moves into BuildUtils::build_deb_in_chroot; each builder
supplies only its package-specific recipe (passed base64-encoded to avoid quoting
interplay through schroot).

Also make the older Ubuntu codenames buildable:
- goconserver: install a pinned modern Go (1.25.12) in the build -- focal/jammy ship
  a Go too old to even auto-switch toolchains, and goconserver's pinned deps need
  Go >= 1.25 (it is a static CGO-free binary, so the pinned toolchain is portable and
  reproducible across codenames).
- ipmitool + goconserver: lower debian/compat 13 -> 12 and Build-Depends debhelper
  (>= 12), since Ubuntu 20.04 (focal) ships debhelper 12; compat 12 also builds cleanly
  on newer codenames.

Validated: all recipe shapes build green through the new path -- tarball
(ipmitool@focal), git-clone+pinned-Go (goconserver@focal), tarball+patches
(syslinux@noble), in-place (grub2-xcat), in-place+custom-rules (xnba); 80/80 unit
tests still pass.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-08-11 13:12:59 -03:00

50 lines
2.3 KiB
Perl
Executable File

#!/usr/bin/env perl
# ipmitool/sbuild.pl -- per-package Ubuntu/Debian builder for ipmitool-xcat; the apt/sbuild analogue
# of ipmitool/mockbuild.pl. Builds the package inside the matching <codename>-<arch>-sbuild chroot from
# its MAINTAINED debian/ packaging and collects the .deb(s) into --result-dir. Invoked by sbuild-all.pl
# per (codename,arch); also runnable standalone. Out-of-tree: the build runs on a COPY of the package
# tree (the checkout is never mutated). The common chroot orchestration lives in
# BuildUtils::build_deb_in_chroot; only ipmitool's source prep + dpkg-buildpackage is below.
use strict;
use warnings;
use Cwd qw(abs_path);
use File::Basename qw(basename);
use Getopt::Long qw(GetOptions);
use FindBin qw($RealBin);
use lib "$RealBin/..";
use BuildUtils qw(chroot_name build_deb_in_chroot);
my $pkg_dir = abs_path($RealBin);
my $pkg = basename($pkg_dir);
my ($codename, $arch, $chroot, $result_dir, $log_dir) = ('', '', '', '', '');
my ($build_timestamp, $build_number, $skip_install) = (undef, undef, 0);
GetOptions(
'codename=s' => \$codename, 'arch=s' => \$arch, 'chroot=s' => \$chroot,
'result-dir=s' => \$result_dir, 'log-dir=s' => \$log_dir,
'build-timestamp=i' => \$build_timestamp, 'build-number=i' => \$build_number,
'skip-install!' => \$skip_install,
) or die "bad options\n";
$arch ||= `dpkg --print-architecture 2>/dev/null`; chomp $arch; $arch ||= 'amd64';
die "FATAL: --codename required\n" unless $codename;
$chroot ||= chroot_name($codename, $arch);
$result_dir ||= "$pkg_dir/../build-output/sbuild/$codename/$arch";
$build_timestamp = time() unless defined $build_timestamp;
# ---- package-specific build (absorbed from the former make_deb.sh); CWD = the copied package dir ----
# ipmitool is a compiled C package (Architecture: amd64 ppc64el), so it is built per-codename against
# that release's libc/toolchain. Extract the upstream tarball, drop in the maintained debian/, build.
my $build = <<'BUILD';
set -e
VERSION=1.8.18
tar xvfz ipmitool-$VERSION.tar.gz
cd ipmitool-$VERSION
cp -rL ../debian .
HOST_ARCH=$(dpkg --print-architecture)
TARGET_ARCH=$HOST_ARCH dpkg-buildpackage -uc -us
BUILD
build_deb_in_chroot(
pkg => $pkg, chroot => $chroot, pkg_dir => $pkg_dir, result_dir => $result_dir,
build_timestamp => $build_timestamp, build => $build,
);