Debian Codegraph @

build-recipe-helm

raw
1 ################################################################
2 #
3 # Copyright (c) 2020 SUSE Linux LLC
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 2 or 3 as
7 # published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program (see the file COPYING); if not, write to the
16 # Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18 #
19 ################################################################
20
21 recipe_setup_helm() {
22 TOPDIR="/usr/src/packages"
23 test "$DO_INIT_TOPDIR" != false && rm -Rf "$BUILD_ROOT/$TOPDIR"
24 mkdir -p "$BUILD_ROOT$TOPDIR/SOURCES"
25 if test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then
26 mv "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
27 else
28 if test -z "$LINKSOURCES" ; then
29 cp -dLR "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
30 else
31 cp -lR "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
32 fi
33 if test "$?" != 0 ; then
34 cleanup_and_exit 1 "source copy failed"
35 fi
36 fi
37 chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR"
38 }
39
40 recipe_prepare_helm() {
41 rm -rf "$BUILD_ROOT$TOPDIR/BUILD"
42 mkdir -p "$BUILD_ROOT$TOPDIR/BUILD"
43 cp -dLR "$BUILD_ROOT$TOPDIR/SOURCES/"* "$BUILD_ROOT$TOPDIR/BUILD"
44 chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR/BUILD"
45 cd "$BUILD_ROOT$TOPDIR/BUILD"
46 for i in *.tar *.tgz *.tar.gz *.tar.xz ; do
47 test -e "$i" || continue
48 echo "Unpacking $i ..."
49 echo "#!/bin/sh -e" > $BUILD_ROOT/.unpack.command
50 shellquote cd "$TOPDIR/BUILD" >> $BUILD_ROOT/.unpack.command
51 echo >> $BUILD_ROOT/.unpack.command
52 echo -n 'tar -x --owner="'$BUILD_USER'" -f ' >> $BUILD_ROOT/.unpack.command
53 shellquote "$i" >> $BUILD_ROOT/.unpack.command
54 echo >> $BUILD_ROOT/.unpack.command
55 shellquote rm -f "$i" >> $BUILD_ROOT/.unpack.command
56 echo >> $BUILD_ROOT/.unpack.command
57 chmod 0755 $BUILD_ROOT/.unpack.command
58 chroot $BUILD_ROOT su -c /.unpack.command - $BUILD_USER || cleanup_and_exit 1
59 rm -f $BUILD_ROOT/.unpack.command
60 rm -f "$i"
61 ls -l
62 done
63 }
64
65 recipe_build_helm() {
66 cd "$BUILD_ROOT$TOPDIR/BUILD"
67 mkdir -p "$BUILD_ROOT$TOPDIR/HELM"
68 chown "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR/HELM"
69 # extract data from chart file
70 args=()
71 test -n "$DISTURL" && args=("${args[@]}" --disturl "$DISTURL")
72 test -n "$RELEASE" && args=("${args[@]}" --release "$RELEASE")
73 local name=$(perl -I$BUILD_DIR -MBuild::Helm -e 'Build::Helm::show' -- "${args[@]}" "$BUILD_ROOT/$TOPDIR/SOURCES/$RECIPEFILE" name)
74 local version=$(perl -I$BUILD_DIR -MBuild::Helm -e 'Build::Helm::show' -- "${args[@]}" "$BUILD_ROOT/$TOPDIR/SOURCES/$RECIPEFILE" version)
75 local nameversion="$name-$version"
76 # avoid packaging sources services and changes files (also include content from _helmignore)
77 chroot $BUILD_ROOT su -c "(cd $TOPDIR/BUILD; [ -f _helmignore ] && mv -f _helmignore .helmignore; echo -e '/*.changes\n/_*\n' >> .helmignore; )" - $BUILD_USER || cleanup_and_exit 1
78 # create chart
79 chroot $BUILD_ROOT su -c "cd $TOPDIR/BUILD && helm package -d $TOPDIR/HELM ." - $BUILD_USER || cleanup_and_exit 1
80 test -f "$BUILD_ROOT$TOPDIR/HELM/$nameversion.tgz" || cleanup_and_exit 1 "helm package command did not create $nameversion.tgz"
81 # extract generated Chart.yaml file
82 tar -xOf "$BUILD_ROOT$TOPDIR/HELM/$nameversion.tgz" -- "$name/Chart.yaml" > "$BUILD_ROOT$TOPDIR/HELM/Chart.yaml"
83 test -s "$BUILD_ROOT$TOPDIR/HELM/Chart.yaml" || cleanup_and_exit 1 "helm chart does not contain $name/Chart.yaml"
84 # generate helminfo
85 perl -I$BUILD_DIR -MBuild::Helm -e 'Build::Helm::show' -- "${args[@]}" --origrecipe "$BUILD_ROOT/$TOPDIR/SOURCES/$RECIPEFILE" --chart "$BUILD_ROOT$TOPDIR/HELM/$nameversion.tgz" "$BUILD_ROOT$TOPDIR/HELM/Chart.yaml" helminfo > "$BUILD_ROOT$TOPDIR/HELM/$nameversion.helminfo" || cleanup_and_exit 1
86 rm -f "$BUILD_ROOT$TOPDIR/HELM/Chart.yaml"
87 BUILD_SUCCEEDED=true
88 }
89
90 recipe_resultdirs_helm() {
91 echo HELM
92 }
93
94 recipe_cleanup_helm() {
95 :
96 }
97