forked from delphix/linux-pkg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-package.sh
executable file
·89 lines (73 loc) · 2.65 KB
/
build-package.sh
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash -e
#
# Copyright 2018, 2019 Delphix
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# shellcheck disable=SC2016
#
# This script is responsible of building the build-info package after a list
# of packages have been built. Each package may generate a build_info file
# containing custom metadata related to the build (e.g. see the store_git_info
# function in common.sh). This script concatenates the build_info files
# generated by each package into a single file that will be provided by this
# package: /lib/delphix-buildinfo/{pkg_list}.info.
#
# The name of the build-info package is "delphix-buildinfo-{pkg_list}"
#
TOP="$(git rev-parse --show-toplevel)"
source "$TOP/lib/common.sh"
SCRIPT_DIR="$TOP/build-info-pkg"
[[ $# -eq 1 ]] || die "Must provide package list as argument."
pkg_list="$1"
logmust get_package_list_file "build" "$pkg_list"
pkg_list_file="$_RET"
logmust "$SCRIPT_DIR/clean.sh"
logmust read_package_list "$pkg_list_file"
PACKAGES=("${_RET_LIST[@]}")
INFO_FILE="$SCRIPT_DIR/lib/delphix-buildinfo/${pkg_list}.info"
logmust mkdir -p "$(dirname "$INFO_FILE")"
LINUX_PKG_HASH="$(git rev-parse HEAD)" || die "git rev-parse HEAD failed"
#
# LINUX_PKG_GIT_URL & LINUX_PKG_GIT_BRANCH are passed by Jenkins
#
cat <<-EOF >"$INFO_FILE"
Linux-pkg Package Framework:
Git hash: $LINUX_PKG_HASH
Git repo: ${LINUX_PKG_GIT_URL:-unknown}
Git branch: ${LINUX_PKG_GIT_BRANCH:-unknown}
EOF
echo "" >>"$INFO_FILE"
logmust cd "$TOP/packages"
for pkg in "${PACKAGES[@]}"; do
echo "Package $pkg:"
if [[ -f "${pkg}/tmp/build_info" ]]; then
cat "${pkg}/tmp/build_info"
else
echo "NO INFO"
fi
echo ""
done >>"$INFO_FILE"
package_name="delphix-buildinfo-${pkg_list}"
logmust cd "$SCRIPT_DIR"
logmust bash -c "sed 's/@@PACKAGE@@/$package_name/g' \
debian/control.in >debian/control"
export DEBEMAIL="Delphix Engineering <[email protected]>"
export PACKAGE_VERSION=1.0.0
export PACKAGE_REVISION=${DEFAULT_REVISION:-0}
logmust set_changelog "$package_name"
logmust dpkg-buildpackage -uc -us -b
logmust mkdir -p artifacts
logmust mv ../"$package_name"*.deb artifacts/
logmust rm -f ../"$package_name"*.buildinfo ../"$package_name"*.changes
logmust cp "$INFO_FILE" artifacts/build-info