Sync from SUSE:ALP:Source:Standard:1.0 elemental-post-build-extract-iso revision a48162d9a17389db293b8e3d5b8bf57c

This commit is contained in:
Adrian Schröter 2024-02-22 13:13:48 +01:00
commit 89b4f36cb5
4 changed files with 127 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

View File

@ -0,0 +1,15 @@
-------------------------------------------------------------------
Fri May 26 15:56:20 UTC 2023 - David Cassany <dcassany@suse.com>
- Update ISO path to current containerized ISOs
-------------------------------------------------------------------
Mon Apr 24 15:40:03 UTC 2023 - David Cassany <dcassany@suse.com>
- Do not exit 1 if docker images are not found, just exit 0
-------------------------------------------------------------------
Fri Apr 21 12:54:42 UTC 2023 - David Cassany <dcassany@suse.com>
- Version 0.0.2:
* Only extract containers including "iso" in its name

View File

@ -0,0 +1,49 @@
#
# spec file for package elemental-post-build-extract-iso
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: elemental-post-build-extract-iso
Summary: Post build script to extract Elemental ISO from a container
License: GPL-2.0-or-later
Group: Development/Tools/Building
Version: 0.4
Release: 0
Requires: buildah
Source0: extract-iso.sh
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Am OBS post build hook that extracts the Elemental ISO from a container. The
ISO is exected to be found at "/iso/*.iso".
%prep
cp %{S:0} .
%build
%install
install -D -m 755 extract-iso.sh $RPM_BUILD_ROOT/usr/lib/build/post-build-checks/50-elemental-extract-iso
%files
%defattr(-, root, root)
%dir /usr/lib/build
%dir /usr/lib/build/post-build-checks
/usr/lib/build/post-build-checks/50-elemental-extract-iso
%changelog

40
extract-iso.sh Normal file
View File

@ -0,0 +1,40 @@
#!/bin/bash -x
: ${TOPDIR:=/usr/src/packages}
container="buildcont"
function cleanup_and_exit {
buildah umount "${container}"
buildah rm "${container}"
exit 0
}
set -e
img=$(ls ${TOPDIR}/DOCKER/*.tar) || true
# Only consider images with 'iso' as part of the name
[ -f "${img}" ] || exit 0
echo "${img}" | grep -q iso || exit 0
echo "Extracting ISO from container image"
buildah from --name "${container}" "docker-archive:${img}"
mnt=$(buildah mount "${container}")
ls "${mnt}"
iso=$(ls "${mnt}"/elemental-iso/*.iso) || true
[ -f "${iso}" ] || cleanup_and_exit
mkdir -p "${TOPDIR}/OTHER"
cp "${iso}" "${TOPDIR}/OTHER"
cp "${iso}.sha256" "${TOPDIR}/OTHER"
cleanup_and_exit