mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-26 04:12:17 +00:00
052d2d5fbe
Master added a workflow and several tests after this branch renamed xCAT-genesis-builder to xCAT-genesis-base. They still name files under xCAT-genesis-builder/, which no longer exists, so they fail or read nothing. The OpenEmbedded workflow, six bats files and four unit tests now use the new paths. Two of those unit tests could reach the code only as shell. genesis_ubuntu_build_root.t cut the package list out of builddeb-genesis-base and evaluated it through bash. genesis_payload_verification.t ran the bash verifier and parsed its stderr. XCAT::GenesisBuildRoot::required_packages() now returns the build-root package list, and builddeb-genesis-base calls it. XCAT::GenesisPayload holds the mandatory-command list and the payload check, and verify-genesis-payload runs its main() with the same arguments, exit codes and messages. stage_genesis_base_sources() stages the module beside the script. Both modules use core Perl only. The two tests now call these functions with chosen inputs and assert the exact results. genesis_base_sources_staged.t expects the module in the staged tarball. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
94 lines
3.1 KiB
Bash
94 lines
3.1 KiB
Bash
#!/usr/bin/env bats
|
|
#
|
|
# 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 rename also has to
|
|
# name the deb it supersedes, or an upgraded ppc node keeps xcat-genesis-base-ppc64 as well.
|
|
#
|
|
# The script is driven here with alien shadowed by a shell function.
|
|
|
|
load 'helpers/shell_source'
|
|
|
|
setup()
|
|
{
|
|
SCRIPT="$(repo_path 'xCAT-genesis-base/debuild-xcat-genesis-base')"
|
|
# Fail rather than skip: a checkout without the converter has no deb rename to measure,
|
|
# and a skip there covers nothing while reading green.
|
|
[ -r "$SCRIPT" ]
|
|
export SCRIPT
|
|
}
|
|
|
|
# alien names the deb after the rpm: lower case, and "_" written as "-".
|
|
shadow_alien()
|
|
{
|
|
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"
|
|
}
|
|
}
|
|
|
|
# Convert one rpm name. Sets SOURCE_DIR to the produced source directory and CONTROL to its
|
|
# control file.
|
|
convert()
|
|
{
|
|
local rpm="$1"
|
|
local work="${BATS_TEST_TMPDIR}/convert"
|
|
|
|
rm -rf "$work"
|
|
mkdir -p "$work"
|
|
(
|
|
shadow_alien
|
|
cd "$work" || exit 1
|
|
: >"$rpm"
|
|
source "$SCRIPT" "$rpm" >/dev/null 2>&1
|
|
)
|
|
|
|
SOURCE_DIR="$(find "$work" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | head -1)"
|
|
[ -n "$SOURCE_DIR" ] || return 1
|
|
CONTROL="$work/$SOURCE_DIR/debian/control"
|
|
[ -f "$CONTROL" ] || return 1
|
|
}
|
|
|
|
@test "the x86_64 rpm becomes the amd64 deb, and replaces the package it supersedes" {
|
|
convert 'xCAT-genesis-base-x86_64-2.13.10-snap202601010000.noarch.rpm'
|
|
|
|
[[ "$SOURCE_DIR" == *-amd64-* ]]
|
|
grep -qx 'Package: xcat-genesis-base-amd64' "$CONTROL"
|
|
grep -qE '^Breaks:.*\bxcat-genesis-scripts-amd64\b' "$CONTROL"
|
|
grep -qx 'Replaces: xcat-genesis-amd64' "$CONTROL"
|
|
grep -qE '^Breaks: xcat-genesis-amd64\b' "$CONTROL"
|
|
}
|
|
|
|
@test "the ppc64 rpm becomes the ppc64el deb, and replaces the deb the rename leaves behind" {
|
|
convert 'xCAT-genesis-base-ppc64-2.13.10-snap202601010000.noarch.rpm'
|
|
|
|
[[ "$SOURCE_DIR" == *-ppc64el-* ]]
|
|
grep -qx 'Package: xcat-genesis-base-ppc64el' "$CONTROL"
|
|
grep -qE '^Breaks:.*\bxcat-genesis-scripts-ppc64el\b' "$CONTROL"
|
|
grep -qx 'Replaces: xcat-genesis-ppc64, xcat-genesis-base-ppc64' "$CONTROL"
|
|
grep -qE '^Breaks: xcat-genesis-ppc64, xcat-genesis-base-ppc64\b' "$CONTROL"
|
|
}
|