Skip to content

Commit 40140be

Browse files
committed
create-anaconda-paylod: provide an RPM instead of tarball
The RPM is better usable by anaconda CI as it will install the payload through interactive defaults file.
1 parent 07afad1 commit 40140be

File tree

1 file changed

+56
-4
lines changed

1 file changed

+56
-4
lines changed

create-anaconda-payload

+56-4
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,50 @@ lvm2
5555

5656
KICKSTART_PATH = "/tmp/payload.ks"
5757

58+
WEBUI_PAYLOAD_SPEC = """
59+
Name: webui_payload
60+
Version: 1
61+
Release: 1
62+
Summary: Inject what's needed to Web UI image.
63+
License: FIXME
5864
59-
def build_payload(image: str, output: str) -> None:
65+
%description
66+
Inject what's needed to Web UI image.
67+
68+
%source0 webui-payload.tar.gz
69+
70+
%prep
71+
72+
# we have no source, so nothing here
73+
ls -lah
74+
cp /root/webui-payload.tar.gz .
75+
76+
%build
77+
cat > custom_interactive-defaults.ks <<EOF
78+
79+
use local live payload tarball for the Web UI
80+
liveimg --url="file://live.tar.xz"
81+
EOF
82+
83+
%install
84+
mkdir -p %{buildroot}/usr/bin/
85+
mkdir -p %{buildroot}/usr/share/anaconda/
86+
87+
install -m 755 webui-payload.tar.gz %{buildroot}/live.tar.xz
88+
install -m 755 custom_interactive-defaults.ks %{buildroot}/usr/share/anaconda/custom_interactive-defaults.ks
89+
90+
%files
91+
/live.tar.xz
92+
/usr/share/anaconda/custom_interactive-defaults.ks
93+
94+
%posttrans
95+
cp /usr/share/anaconda/custom_interactive-defaults.ks /usr/share/anaconda/interactive-defaults.ks
96+
97+
%changelog
98+
"""
99+
100+
101+
def build_payload_rpm(image: str, output: str) -> None:
60102
subprocess.check_call([os.path.join(BOTS_DIR, "image-download"), image])
61103
machine = testvm.VirtMachine(image=image, memory_mb=4096)
62104
try:
@@ -72,9 +114,19 @@ def build_payload(image: str, output: str) -> None:
72114
)
73115

74116
# Change directory to /mnt/sysimage/ and create archive
75-
machine.execute("cd /mnt/sysimage && tar --selinux --acls --xattrs -zcvf /root/payload.tar.gz *", timeout=100)
117+
machine.execute(
118+
"cd /mnt/sysimage && tar --selinux --acls --xattrs -zcvf /root/webui-payload.tar.gz *",
119+
timeout=100
120+
)
121+
122+
# Create the payload RPM Spec file
123+
machine.execute(f"echo \"{WEBUI_PAYLOAD_SPEC}\" > /root/webui-payload.spec")
124+
125+
# Build the RPM
126+
machine.execute("rpmbuild -bb /root/webui-payload.spec", timeout=300)
76127

77-
machine.download("/root/payload.tar.gz", output)
128+
# Download the RPM
129+
machine.download("/root/rpmbuild/RPMS/x86_64/webui_payload-1-1.x86_64.rpm", output)
78130
finally:
79131
machine.stop()
80132

@@ -88,7 +140,7 @@ def main() -> None:
88140
if not args.output:
89141
raise RuntimeError("Output path not specified")
90142

91-
build_payload(args.image, args.output)
143+
build_payload_rpm(args.image, args.output)
92144

93145

94146
main()

0 commit comments

Comments
 (0)