-
Notifications
You must be signed in to change notification settings - Fork 7
/
kiwi_post_run
65 lines (52 loc) · 1.62 KB
/
kiwi_post_run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -e
set -u
: ${TOPDIR:=/usr/src/packages}
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')
shopt -s nullglob
IMAGE=$(echo ${PREFIX}*${SUFFIX})
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
echo "Attempting to wrap $IMAGE in a containment rpm ..."
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__/$IMAGE/g" \
< $BUILD_DIR/image.spec.in \
> $TOPDIR/OTHER/image.followup.spec