Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] unifying containment-rpm approaches #2

Open
wants to merge 87 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
b121331
import r4 of Devel:StudioOnline:containment_common_packages/containme…
aspiers Oct 5, 2014
d613bce
import r5 of Devel:StudioOnline:containment_common_packages/containme…
aspiers Oct 5, 2014
1686f46
import r6 of Devel:StudioOnline:containment_common_packages/containme…
aspiers Oct 5, 2014
cb1e1b5
import r7 of Devel:StudioOnline:containment_common_packages/containme…
aspiers Oct 5, 2014
53fc21c
import r8 of Devel:StudioOnline:containment_common_packages/containme…
aspiers Oct 5, 2014
c066800
import r9 of Devel:StudioOnline:containment_common_packages/containme…
aspiers Oct 5, 2014
485b248
import r10 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
4f5df8a
import r15 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
65250aa
import r16 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
d6bfaf7
import r17 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
698f4d6
import r18 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
a6713c4
import r19 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
e76678d
import r20 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
3d4d1c8
import r21 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
bb91125
import r22 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
b138b47
import r23 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
1780c3b
import r24 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
e959fb4
import r25 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
e8ac737
import r26 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
82dc9b3
import r27 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
519b1ea
import r28 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
08d9fde
import r29 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
6678bb3
import r30 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
6d903c1
import r31 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
e41dd97
import r32 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
775c62f
import r33 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
ea55be0
import r34 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
4939a70
import r36 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
fe534ed
import r37 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
9e2ed87
import r38 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
0b85022
import r39 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
6a61b83
import r40 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
fa65629
import r41 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
1d23541
import r42 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
858cb09
import r43 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
7bfd876
import r44 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
6276c43
import r46 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
ca80dcb
import r48 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
77838b6
import r50 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
adf645e
import r54 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
9c91409
import r55 of Devel:StudioOnline:containment_common_packages/containm…
aspiers Oct 5, 2014
991db1f
remove update-package (fixes #1)
aspiers Oct 5, 2014
43cb4b1
remove create_metadata.rb
aspiers Oct 5, 2014
5eb7f04
align containment-rpm.spec with version in IBS package
aspiers Oct 5, 2014
95079dc
containment-rpm tarball will be bzipped by tar_scm
aspiers Oct 5, 2014
d39a9d6
remove Studio-specific Requires:
aspiers Oct 5, 2014
d148aef
containment-rpm.spec: improve Summary and Description
aspiers Oct 5, 2014
c3d6f4d
fix kiwi_post_run and image.spec.in for Devel:Cloud:4 requirements
aspiers Oct 5, 2014
8f7ab5d
do a hard-link of the .iso instead of a move
aspiers Oct 6, 2014
8b9f3b7
take name/extension of image to contain from rpm macros
aspiers Oct 6, 2014
97f7b1e
take dest dir of image to contain from rpm macros
aspiers Oct 6, 2014
11af56e
fix %description
aspiers Oct 6, 2014
435b847
depend on new containment-rpm-config approach
aspiers Oct 6, 2014
14cc9ca
eliminate superfluous attempt to untar an .iso
aspiers Oct 6, 2014
aa997d6
handle OBS builds
aspiers Oct 6, 2014
773f94e
introduce prefix/suffix scheme
aspiers Oct 7, 2014
8f817fc
fix setup of fstab
aspiers Oct 7, 2014
ea6aa00
add caution that %post doesn't actually work
aspiers Oct 8, 2014
5e62534
remove needless echo
aspiers Oct 8, 2014
a0570ff
append to fstab, don't truncate it!!
aspiers Oct 8, 2014
fd5ec4b
remove erroneous trailing quote
aspiers Oct 8, 2014
5f9cdce
add link to kiwi .iso naming bug (bnc#900109)
aspiers Oct 8, 2014
ad6c14a
use %containment_image_description macro
aspiers Oct 8, 2014
b87bbb0
switch to making the rpm contain the unpacked .iso contents
aspiers Oct 8, 2014
0d30fe0
add a fake product key
aspiers Oct 8, 2014
0f40d96
fix incorrect link to Devel:StudioOnline:containment_common_packages
aspiers Sep 6, 2014
2dcf8ab
improve README
aspiers Oct 5, 2014
041ab13
fix typo
aspiers Dec 17, 2014
6661a6b
fix media builds for which containment rpms aren't required
aspiers Dec 17, 2014
b4c5dd5
Add an ability to add extra files to the containment rpms
dirkmueller May 6, 2015
08ce544
Revert weird content.key hack
dirkmueller May 6, 2015
769da52
Don't do harmful things in the %prep section
dirkmueller May 6, 2015
9fa368c
Rework containment rpm to use followup.spec methodology
dirkmueller May 6, 2015
8a2fdd7
Merge pull request #1 from dirkmueller/master
aspiers May 13, 2015
a8636e3
Merge remote-tracking branch 'refs/remotes/origin/master'
aspiers May 13, 2015
fe8a83d
unpack .iso via bsdtar rather than mounting it
aspiers May 13, 2015
1f31273
remove content.key which is no longer needed
aspiers May 14, 2015
1fbd517
Make files writable by the user
vuntz Apr 5, 2016
f822c47
Add %changelog tag to spec file
vuntz Apr 5, 2016
4aeb754
Fix license to use SPDX format
vuntz Apr 5, 2016
15a58dc
Use fdupes
vuntz Apr 5, 2016
058290c
Fix style of spec file
vuntz Apr 5, 2016
3296be5
Use package name for filename of followup spec file
vuntz Apr 6, 2016
54c6a0a
Append a valid changelog entry for the build
vuntz Apr 6, 2016
49abe99
Merge pull request #2 from vuntz/sle12
vuntz Apr 19, 2016
26dec71
Update spec file to have Requires for packages needed by generated spec
vuntz Apr 19, 2016
3f72c0c
Merge pull request #3 from vuntz/spec-update
vuntz May 3, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 43 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,50 @@
openSUSE/containment-rpm
=====================================================================

`openSUSE/containment-rpm`_ is the authoritative source for
`Devel:StudioOnline:containment_common_packages/containment-rpm`_.
``image.spec.in``, ``kiwi_post_run`` and ``containment-rpm.spec.in`` are
the actual sources and metasources, and ``update-package`` takes care of
updating the Build Service package from Github.
This repository provides files which facilitate the building (via the
`Open Build Service`_) of *containment rpms*. A containment rpm is an
rpm package which contains one or more files generated as the result
of another package build within the same Build Service. `.iso` files,
`.qcow2` images, and Vagrant `.box` files are all typical examples of
files contained within a containment rpm.

.. _`Open Build Service`: http://openbuildservice.org/



"Customers"
===========

Users of a version of this repository include:

- SUSE Studio, via the `Devel:StudioOnline:containment_common_packages/containment-rpm`_
project. For more information, see
https://github.com/SUSE/studio/wiki/Containment-guidelines
and https://github.com/SUSE/studio/tree/master/containment-rpm.

- SUSE Cloud, via the `Devel:Cloud:Shared:11-SP3:Update`_ project.

However the code is not yet being properly shared and co-maintained.

.. _openSUSE/containment: https://github.com/openSUSE/containment-rpm
.. _Devel:StudioOnline:containment_common_packages/containment-rpm:
https://build.suse.de/package/show?package=containment-rpm&project=Devel:StudioOnline:containment_common_packages
.. _Devel:Cloud:Shared:11-SP3:Update:
https://build.suse.de/package/show/home:aspiers:branches:Devel:Cloud:Shared:11-SP3:Update/containment-rpm


Contents
========

* ``containment-rpm.spec.in`` is the template for the spec file which
enables kiwi build environments to build containment rpms.
* ``kiwi_post_run`` is the hook which gets executed at the end of the
kiwi image building process. This script will wrap the image
newly built by kiwi inside a containment rpm, and move it to the
right location so that the Build Service will consider it a build
artefact which can be published or used in other builds.
* ``image.spec.in`` is the spec file used by ``kiwi_post_run`` to build
the containment rpm.


Hacking
=======
Expand All @@ -20,8 +55,9 @@ Hacking
* ``update-package`` can be used with different BS projects;
see ``update-package -h``.


Example
=======
-------

::

Expand Down
24 changes: 19 additions & 5 deletions containment-rpm.spec.in → containment-rpm.spec
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# spec file for package containment-rpm
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
Expand All @@ -15,20 +18,31 @@
# norootforbuild

Name: containment-rpm
Version: __VERSION__
Version: 0
Release: 0
License: MIT
Summary: Wraps OBS/kiwi-built images in rpms.
Summary: Wraps OBS/kiwi-built images in rpms
Url: https://github.com/openSUSE/%{name}
Group: System/Management
Source: %{name}-%{version}.tar.gz
Source: %{name}-%{version}.tar.bz2
BuildRequires: filesystem
# BuildRequires from the generated spec file, that need to be installed
Requires: bsdtar
Requires: containment-rpm-config
Requires: fdupes
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch

%description
OBS kiwi_post_run hook to wrap a kiwi-produced image in an rpm package.

This package should be required by the Build Service project's meta
prjconf, so that the kiwi_post_run hook is present in the kiwi image
and gets executed at the end of the image build. It will then build
an rpm which contains the newly-produced image from kiwi (using
image.spec.in), and place the rpm in the correct location that it
becomes an additional build artefact.

%prep
%setup -q

Expand All @@ -38,11 +52,11 @@ OBS kiwi_post_run hook to wrap a kiwi-produced image in an rpm package.
mkdir -p %{buildroot}/usr/lib/build/
install -m 644 image.spec.in %{buildroot}/usr/lib/build/
install -m 755 kiwi_post_run %{buildroot}/usr/lib/build/
install -d %{buildroot}%{_sourcedir}

%files
%defattr(-,root,root)
/usr/lib/build/kiwi_post_run
/usr/lib/build/image.spec.in

%changelog

39 changes: 20 additions & 19 deletions image.spec.in
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
Url: http://www.susestudio.com
Name: __NAME__
Summary: Studio Build System
Summary: %{containment_image_description} product .iso
Version: __VERSION__
Release: __RELEASE__
Url: http://www.suse.com/cloud
Group: System/Management
License: GPLv2
Source: %{name}-%{version}-%{release}-vmx.tar.bz2
License: GPL-2.0
Source0: __SOURCE__
BuildRequires: containment-rpm-config
BuildRequires: bsdtar
BuildRequires: fdupes
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch

%description
Containment appliance to build studio images secured by a VM layer
This package installs the unpacked %{containment_image_description} product .iso into:

Authors:
--------
Marcus Schaefer <[email protected]>
Jordi Massaguer Pla <[email protected]>
%{containment_image_dest_dir}

It is intended to be installed on the SUSE Cloud admin server.

%prep
%setup -c -n %name

%build
# empty no compile job
bsdtar xf %{SOURCE0}
chmod -R u+w *

%install
install -d -m 755 %{buildroot}%{containment_image_dest_dir}
cp -pr * %{buildroot}%{containment_image_dest_dir}
%fdupes %{buildroot}%{containment_image_dest_dir}

install -d -m 755 $RPM_BUILD_ROOT/usr/share/studio/image
mv *.qcow2 $RPM_BUILD_ROOT/usr/share/studio/image

%clean
rm -rf $RPM_BUILD_ROOT
install -d -m 755 %{_rpmdir}/OTHER
cp -pr %{S:0} %{_rpmdir}/OTHER

%files
%defattr(-, root, root)
%dir /usr/share/studio
/usr/share/studio/image

%{containment_extra_files}
%{containment_image_dest_dir}
77 changes: 56 additions & 21 deletions kiwi_post_run
Original file line number Diff line number Diff line change
@@ -1,38 +1,73 @@
#!/bin/sh -eu
#!/bin/bash

set -e
set -u

: ${TOPDIR:=/usr/src/packages}

TARGET_DIR=$TOPDIR/KIWI-vmx/
RPM_SOURCE_DIR=$TOPDIR/SOURCES
FILES_DIR=/usr/lib/build
IMAGE_DIR=$TOPDIR/KIWI
BUILD_DIR=/usr/lib/build

cd $IMAGE_DIR

NAME=$(rpm --eval '%containment_image_name')
EXT=$( rpm --eval '%containment_image_extension')
PREFIX=$(rpm --eval '%containment_image_prefix')
SUFFIX=$( rpm --eval '%containment_image_suffix')
MAIL=$( rpm --eval '%containment_image_mail')

shopt -s nullglob
IMAGE=$(echo ${PREFIX}*${SUFFIX})

cd $TARGET_DIR
if [ -z "$IMAGE" ]; then
echo "Couldn't find anything in $IMAGE_DIR matching ${PREFIX}*${SUFFIX}."
echo "Will skip containment rpm wrapping steps."
exit 0
fi

STEM=Containment-Studio
EXT=.qcow2
SOURCE=$(echo $STEM-*$EXT)
echo "Attempting to wrap $IMAGE in a containment rpm ..."

# extract os/platform, version, release from the source tarball
set -- $(echo $SOURCE | sed -r "s/(.*)-(.*)$EXT/\1 \2/")
NAME=$(echo $1 | sed -r "s/.x86_64//g")
VERSION=$2
NAME="${NAME}-${EXT}"
RELEASE=$(date +%Y%m%d%H%M%S)

# Extracting the version is a bit more complicated.
# For some reason, .isos from local builds look something like this:
#
# SUSE-CLOUD-4-x86_64{1,2,3}.iso
#
# whereas .isos from OBS builds look something like this:
#
# SUSE-CLOUD-4-x86_64-Build0007-Media{1,2,3}.iso
# SUSE-CLOUD-SLE11-SP3-DEPS-x86_64-Build0003-Media.iso
#
# This discrepancy is filed as https://bugzilla.suse.com/show_bug.cgi?id=900109
#
# $IMAGE should contain the filename of the first of these 3 .isos.
VERSION="${IMAGE#$PREFIX}"
VERSION="${VERSION%$SUFFIX}"
if [ -z "$VERSION" ]; then
echo "Local build detected"
# Just arbitrarily assign the version since we have nothing else
# to go on.
VERSION=1
fi

echo "name $NAME"
echo "version $VERSION"
echo "release $RELEASE"

mkdir -p $TOPDIR/OTHER

sed -e "s/__NAME__/$NAME/g" \
-e "s/__VERSION__/$VERSION/g" \
-e "s/__RELEASE__/$RELEASE/g" \
-e "s/__SOURCE__/$SOURCE/g" \
< $FILES_DIR/image.spec.in \
> $FILES_DIR/image.spec
-e "s/__SOURCE__/$IMAGE/g" \
< $BUILD_DIR/image.spec.in \
> "$TOPDIR/OTHER/$NAME.followup.spec"

tar -cjf $RPM_SOURCE_DIR/$NAME-$VERSION-$RELEASE-vmx.tar.bz2 $SOURCE
rpmbuild -ba $FILES_DIR/image.spec
cat <<EOF >> "$TOPDIR/OTHER/$NAME.followup.spec"

# required for the BS to find the rpm, because it is
# a "non-standard result file for KIWI"
mkdir -p $TOPDIR/OTHER
mv $TOPDIR/RPMS/noarch/$NAME-$VERSION-$RELEASE.noarch.rpm $TOPDIR/OTHER/
%changelog
* $(date +"%a %b %d %Y") $MAIL
- Automatic build.
EOF
114 changes: 0 additions & 114 deletions update-package

This file was deleted.