commit 419106e5d1be7162e0a404e40c6b4ad8759b0ce3f715ad60383d596933ff0882 Author: Adrian Schröter <adrian@suse.de> Date: Thu Feb 22 13:13:48 2024 +0100 Sync from SUSE:ALP:Source:Standard:1.0 elemental-post-build-extract-iso revision a48162d9a17389db293b8e3d5b8bf57c diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/elemental-post-build-extract-iso.changes b/elemental-post-build-extract-iso.changes new file mode 100644 index 0000000..6a5200f --- /dev/null +++ b/elemental-post-build-extract-iso.changes @@ -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 diff --git a/elemental-post-build-extract-iso.spec b/elemental-post-build-extract-iso.spec new file mode 100644 index 0000000..92d10c6 --- /dev/null +++ b/elemental-post-build-extract-iso.spec @@ -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 + diff --git a/extract-iso.sh b/extract-iso.sh new file mode 100644 index 0000000..8e3d1e0 --- /dev/null +++ b/extract-iso.sh @@ -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 +