Accepting request 663685 from SUSE:SLE-15:Update
New package - needed for using labels in openSUSE containers. OBS-URL: https://build.opensuse.org/request/show/663685 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-kiwi_label_helper?expand=0&rev=1
This commit is contained in:
commit
37d8180d36
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal 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
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.osc
|
29
README
Normal file
29
README
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
obs-service-kiwi_label_helper
|
||||||
|
=============================
|
||||||
|
|
||||||
|
This service can be enabled to run during buildtime, when it will edit the
|
||||||
|
kiwi image descriptions to expand the <suse_label_helper:add_prefix/\>
|
||||||
|
element.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
<image [...] xmlns:suse_label_helper="com.suse.label_helper">
|
||||||
|
[...]
|
||||||
|
<containerconfig [...]>
|
||||||
|
<labels>
|
||||||
|
<suse_label_helper:add_prefix prefix="com.suse.sle.base">
|
||||||
|
<label name="org.opencontainers.title" value="SUSE Linux Enterprise Server 12 SP3 Base Container"/>
|
||||||
|
</suse_label_helper:add_prefix>
|
||||||
|
```
|
||||||
|
|
||||||
|
expands to
|
||||||
|
|
||||||
|
```
|
||||||
|
<image [...] xmlns:suse_label_helper="com.suse.label_helper">
|
||||||
|
[...]
|
||||||
|
<containerconfig [...]>
|
||||||
|
<labels>
|
||||||
|
<label name="org.opencontainers.title" value="SUSE Linux Enterprise Server 12 SP3 Base Container"/>
|
||||||
|
<label name="com.suse.sle.base.title" value="SUSE Linux Enterprise Server 12 SP3 Base Container"/>
|
||||||
|
```
|
24
kiwi_label_helper
Normal file
24
kiwi_label_helper
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
if [ "${BUILD_DIST+x}" != "x" ]; then
|
||||||
|
echo "Not running in an OBS build container"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
BUILD_DATA="${BUILD_DIST/.dist/.data}"
|
||||||
|
. "${BUILD_DATA}"
|
||||||
|
|
||||||
|
if [ "${RECIPEFILE##*.}" != "kiwi" ]; then
|
||||||
|
echo "Recipe is not a kiwi file - exiting"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
tmp=$(mktemp)
|
||||||
|
if ! xsltproc /usr/lib/kiwi_label_helper/label_helper.xsl "${RECIPEFILE}" >> "${tmp}"; then
|
||||||
|
rm "${tmp}"
|
||||||
|
echo "xsltproc failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv -f "${tmp}" "${RECIPEFILE}"
|
4
kiwi_label_helper.service
Normal file
4
kiwi_label_helper.service
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<service name="kiwi_label_helper">
|
||||||
|
<summary>Allows automatic duplication of labels with a custom prefix.</summary>
|
||||||
|
<description>Implements the suse_label_helper:add_prefix element useful for building containers.</description>
|
||||||
|
</service>
|
45
label_helper.xsl
Normal file
45
label_helper.xsl
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<xsl:stylesheet version="1.0"
|
||||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
|
xmlns:suse_label_helper="com.suse.label_helper">
|
||||||
|
<xsl:template match="node()|@*">
|
||||||
|
<xsl:copy>
|
||||||
|
<xsl:apply-templates select="node()|@*"/>
|
||||||
|
</xsl:copy>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="suse_label_helper:add_prefix">
|
||||||
|
<xsl:apply-templates select="label"/>
|
||||||
|
<xsl:apply-templates select="label" mode="add_prefix"/>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="label" mode="add_prefix">
|
||||||
|
<label>
|
||||||
|
<xsl:attribute name="name">
|
||||||
|
<xsl:value-of select="../@prefix" />
|
||||||
|
<xsl:text>.</xsl:text>
|
||||||
|
<xsl:call-template name="last-domain-part">
|
||||||
|
<xsl:with-param name="string" select="@name" />
|
||||||
|
</xsl:call-template>
|
||||||
|
</xsl:attribute>
|
||||||
|
<xsl:attribute name="value">
|
||||||
|
<xsl:value-of select="@value" />
|
||||||
|
</xsl:attribute>
|
||||||
|
</label>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template name="last-domain-part">
|
||||||
|
<xsl:param name="string" />
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="contains($string, '.')">
|
||||||
|
<xsl:call-template name="last-domain-part">
|
||||||
|
<xsl:with-param name="string"
|
||||||
|
select="substring-after($string, '.')" />
|
||||||
|
</xsl:call-template>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="$string" />
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>
|
5
obs-service-kiwi_label_helper.changes
Normal file
5
obs-service-kiwi_label_helper.changes
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Oct 30 10:40:41 UTC 2018 - Fabian Vogt <fvogt@suse.com>
|
||||||
|
|
||||||
|
- Initial commit (fate#326856, bsc#1118103)
|
||||||
|
|
57
obs-service-kiwi_label_helper.spec
Normal file
57
obs-service-kiwi_label_helper.spec
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#
|
||||||
|
# spec file for package obs-service-kiwi_label_helper
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||||
|
#
|
||||||
|
# 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 http://bugs.opensuse.org/
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
Name: obs-service-kiwi_label_helper
|
||||||
|
Version: 0.0
|
||||||
|
Release: 0
|
||||||
|
Summary: Service to duplicate labels with a custom prefix
|
||||||
|
License: GPL-2.0+
|
||||||
|
Group: Development/Tools/Building
|
||||||
|
Url: https://build.opensuse.org
|
||||||
|
Source0: kiwi_label_helper.service
|
||||||
|
Source1: kiwi_label_helper
|
||||||
|
Source2: README
|
||||||
|
Source3: label_helper.xsl
|
||||||
|
Requires: libxslt-tools
|
||||||
|
BuildArch: noarch
|
||||||
|
|
||||||
|
%description
|
||||||
|
This service can be used during buildtime to implement the
|
||||||
|
suse_label_helper:add_prefix element useful for building containers.
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q -D -T 0 -n .
|
||||||
|
cp %{SOURCE2} .
|
||||||
|
|
||||||
|
%build
|
||||||
|
|
||||||
|
%install
|
||||||
|
|
||||||
|
mkdir -p %{buildroot}%{_prefix}/lib/obs/service %{buildroot}%{_prefix}/lib/kiwi_label_helper
|
||||||
|
install -m 0644 %{SOURCE0} %{buildroot}%{_prefix}/lib/obs/service
|
||||||
|
install -m 0755 %{SOURCE1} %{buildroot}%{_prefix}/lib/obs/service
|
||||||
|
install -m 0644 %{SOURCE3} %{buildroot}%{_prefix}/lib/kiwi_label_helper
|
||||||
|
|
||||||
|
%files
|
||||||
|
%doc README
|
||||||
|
%dir %{_prefix}/lib/obs
|
||||||
|
%{_prefix}/lib/obs/service
|
||||||
|
%dir %{_prefix}/lib/kiwi_label_helper
|
||||||
|
%{_prefix}/lib/kiwi_label_helper/label_helper.xsl
|
||||||
|
|
||||||
|
%changelog
|
Loading…
Reference in New Issue
Block a user