mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-21 16:39:30 +00:00
fix(xcat-core): the alien Genesis base deb keeps the rpm architecture
debuild-xcat-genesis-base maps only x86_64 to amd64. For the ppc64 rpm it leaves every name at ppc64, so it builds xcat-genesis-base-ppc64 and writes "Breaks: xcat-genesis-scripts-ppc64". The Debian architecture is ppc64el, and the packages xCAT-genesis-scripts builds for it are named ppc64el, so the Breaks names a package no repository publishes. This change replaces the single x86_64 test with an architecture map: x86_64 to amd64, ppc64 and ppc64le to ppc64el. The map now drives the source tree rename, the control and changelog rewrite, and the Breaks field. PACKAGE_ARCH keeps the rpm value, because the preinst removes the Genesis tree under that name. genesis_base_deb_arch.t drives the script with alien shadowed. It fails the three ppc64el assertions without this change. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -30,17 +30,28 @@ alien -d -g -c -k "${RPM_PACKAGE}" || exit 1
|
||||
PACKAGE_ARCH="${EXTRACT_DIR%-*}"
|
||||
PACKAGE_ARCH="${PACKAGE_ARCH##*-}"
|
||||
|
||||
if [[ ${EXTRACT_DIR} =~ -x86_64- ]]
|
||||
then
|
||||
rm -rf "${EXTRACT_DIR//x86_64/amd64}"
|
||||
mv "${EXTRACT_DIR}" "${EXTRACT_DIR//x86_64/amd64}"
|
||||
EXTRACT_DIR="${EXTRACT_DIR//x86_64/amd64}"
|
||||
# The rpm carries the Genesis target architecture, the deb must carry the Debian architecture.
|
||||
# alien copies the rpm name into the deb and writes "_" as "-", so x86_64 arrives as x86-64.
|
||||
case "${PACKAGE_ARCH}" in
|
||||
x86_64)
|
||||
ALIEN_ARCH="x86-64" ; DEB_ARCH="amd64" ;;
|
||||
ppc64|ppc64le)
|
||||
ALIEN_ARCH="${PACKAGE_ARCH}" ; DEB_ARCH="ppc64el" ;;
|
||||
*)
|
||||
ALIEN_ARCH="${PACKAGE_ARCH}" ; DEB_ARCH="${PACKAGE_ARCH}" ;;
|
||||
esac
|
||||
|
||||
sed -i -e 's/x86-64/amd64/g' "${EXTRACT_DIR}/debian/control"
|
||||
sed -i -e 's/x86-64/amd64/g' "${EXTRACT_DIR}/debian/changelog"
|
||||
if [[ "${DEB_ARCH}" != "${PACKAGE_ARCH}" ]]
|
||||
then
|
||||
rm -rf "${EXTRACT_DIR//${PACKAGE_ARCH}/${DEB_ARCH}}"
|
||||
mv "${EXTRACT_DIR}" "${EXTRACT_DIR//${PACKAGE_ARCH}/${DEB_ARCH}}"
|
||||
EXTRACT_DIR="${EXTRACT_DIR//${PACKAGE_ARCH}/${DEB_ARCH}}"
|
||||
|
||||
sed -i -e "s/${ALIEN_ARCH}/${DEB_ARCH}/g" "${EXTRACT_DIR}/debian/control"
|
||||
sed -i -e "s/${ALIEN_ARCH}/${DEB_ARCH}/g" "${EXTRACT_DIR}/debian/changelog"
|
||||
fi
|
||||
|
||||
sed -i -e "/^Description:/i Breaks: xcat-genesis-scripts-${PACKAGE_ARCH//x86_64/amd64} (<< 2.13.10)" "${EXTRACT_DIR}/debian/control"
|
||||
sed -i -e "/^Description:/i Breaks: xcat-genesis-scripts-${DEB_ARCH} (<< 2.13.10)" "${EXTRACT_DIR}/debian/control"
|
||||
|
||||
cat >"${EXTRACT_DIR}/debian/preinst" <<EOF
|
||||
#!/bin/bash
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env perl
|
||||
# debuild-xcat-genesis-base converts the EL Genesis base rpm to a deb. The rpm name carries the
|
||||
# Genesis target architecture, and the deb must carry the Debian architecture: ppc64 becomes
|
||||
# ppc64el, x86_64 becomes amd64. An unmapped architecture leaves the deb named after the rpm and
|
||||
# makes it break a genesis-scripts package that no repository publishes.
|
||||
#
|
||||
# The script is driven here with alien and dpkg-buildpackage shadowed by shell functions.
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Temp qw(tempdir);
|
||||
use FindBin;
|
||||
use Test::More;
|
||||
|
||||
my $root = "$FindBin::Bin/../..";
|
||||
my $script = "$root/xCAT-genesis-builder/debuild-xcat-genesis-base";
|
||||
BAIL_OUT("debuild-xcat-genesis-base not found at $script") unless -f $script;
|
||||
|
||||
my $tmpdir = tempdir(CLEANUP => 1);
|
||||
my $driver = "$tmpdir/driver.sh";
|
||||
open(my $driver_fh, '>', $driver) or die "open $driver: $!";
|
||||
print {$driver_fh} <<'DRIVER';
|
||||
#!/bin/bash
|
||||
|
||||
# alien names the deb after the rpm: lower case, and "_" written as "-".
|
||||
alien() {
|
||||
local rpm="${!#}"
|
||||
local name="${rpm##*/}"
|
||||
name="${name%.rpm}"
|
||||
local dir="${name%%-snap*}"
|
||||
local package="${dir%-*}"
|
||||
package="${package,,}"
|
||||
package="${package//_/-}"
|
||||
|
||||
mkdir -p "${dir}/debian"
|
||||
cat >"${dir}/debian/control" <<CONTROL
|
||||
Source: ${package}
|
||||
Section: alien
|
||||
Priority: extra
|
||||
Maintainer: xCAT <xcat-user@lists.sourceforge.net>
|
||||
|
||||
Package: ${package}
|
||||
Architecture: all
|
||||
Description: xCAT genesis base
|
||||
CONTROL
|
||||
printf '%s (%s) unstable; urgency=low\n' "${package}" "1.0" \
|
||||
>"${dir}/debian/changelog"
|
||||
printf '#!/usr/bin/make -f\nbinary:\n\t@true\n' >"${dir}/debian/rules"
|
||||
chmod 0755 "${dir}/debian/rules"
|
||||
}
|
||||
|
||||
cd "${WORK_DIR}" || exit 1
|
||||
: >"${RPM_NAME}"
|
||||
source "${SCRIPT}" "${RPM_NAME}" >/dev/null 2>&1
|
||||
DRIVER
|
||||
close($driver_fh) or die "close $driver: $!";
|
||||
|
||||
# Convert one rpm name and return the produced source directory and its control file.
|
||||
sub convert {
|
||||
my ($name, $rpm) = @_;
|
||||
my $work = "$tmpdir/$name";
|
||||
mkdir $work or die "mkdir $work: $!";
|
||||
local %ENV = (%ENV, SCRIPT => $script, WORK_DIR => $work, RPM_NAME => $rpm);
|
||||
system('bash', $driver) == 0 or return (undef, '');
|
||||
my ($dir) = grep { -d $_ } glob("$work/*");
|
||||
return (undef, '') unless defined $dir && -f "$dir/debian/control";
|
||||
open(my $fh, '<', "$dir/debian/control") or die "read $dir/debian/control: $!";
|
||||
local $/; my $control = <$fh>; close $fh;
|
||||
$dir =~ s{^\Q$work\E/}{};
|
||||
return ($dir, $control);
|
||||
}
|
||||
|
||||
my %expected = (
|
||||
'xCAT-genesis-base-x86_64-2.13.10-snap202601010000.noarch.rpm' => 'amd64',
|
||||
'xCAT-genesis-base-ppc64-2.13.10-snap202601010000.noarch.rpm' => 'ppc64el',
|
||||
);
|
||||
|
||||
for my $rpm (sort keys %expected) {
|
||||
my $arch = $expected{$rpm};
|
||||
my ($dir, $control) = convert($arch, $rpm);
|
||||
BAIL_OUT("debuild-xcat-genesis-base produced no source tree for $rpm")
|
||||
unless defined $dir;
|
||||
|
||||
like($dir, qr/\Q-$arch-\E/, "$rpm builds in a $arch source tree");
|
||||
like($control, qr/^Package:\s*xcat-genesis-base-\Q$arch\E$/m,
|
||||
"$rpm builds the package xcat-genesis-base-$arch");
|
||||
like($control, qr/^Breaks:\s*xcat-genesis-scripts-\Q$arch\E\b/m,
|
||||
"xcat-genesis-base-$arch breaks the genesis scripts of its own architecture");
|
||||
}
|
||||
|
||||
done_testing();
|
||||
Reference in New Issue
Block a user