-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrtems-release-package
More file actions
executable file
·198 lines (182 loc) · 6.23 KB
/
Copy pathrtems-release-package
File metadata and controls
executable file
·198 lines (182 loc) · 6.23 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#! /bin/sh
#
# RTEMS Tools Project (http://www.rtems.org/)
# Copyright 2015,2016,2019 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
set -e
#
# This script packages a package in a tar file.
#
#
# Defaults.
#
. ${release_top}/rtems-release-defaults
#
# Common package start.
#
title="RTEMS Release Package"
. ./rtems-release-package-start
#
# Work in a package specific directory in the release directory.
#
# Clone the repo and then check if there are any submodules.
#
echo "git clone ${git_remote} ${git_local}"
git clone ${git_remote} ${git_local}
stamped_tar=${prefix}-unstamped
#
# If there are submodules, exclude the ones we do not wish to package, eg the
# whole of the FreeBSD source tree. For the ones to package get the commit
# (treeish) for the branch we releasing and then create an archive. The
# submodule archives are merged into the main archive once we have collected
# them all.
#
# A package may have one or more branches that need to be package.
# If not defined there is only one the version based branch
#
# Get the package's branches and package names
#
cd ${git_local}
var_pkg_main=${package_prefix}_pkg_main
eval "pkg_main=\${$var_pkg_main}"
# If there is no package main use main
if [ -z "${pkg_main}" ]; then
pkg_main="main"
fi
var_pkg_branches=${package_prefix}_pkg_branches
eval "pkg_branches=\${$var_pkg_branches}"
var_pkg_names=${package_prefix}_pkg_names
eval "pkg_names=\${$var_pkg_names}"
# If there are no package branches use the default mapping
if [ -z "${pkg_branches}" ]; then
# See rtems-release-package-start for the map branch macro
pkg_branches=$(rtems_map_branch ${package} ${version})
pkg_names=""
fi
echo "git fetch origin"
git fetch origin
cd .. # ${git_local}
echo "] Package ${package} ${version}: remote-branches='${pkg_branches}' pkg-names='${pkg_names}'"
for remote_branch in ${pkg_branches}
do
cd ${git_local}
if [ -n "${pkg_names}" ]; then
pkg_name=$(echo ${pkg_names} | cut -f1 -d ' ')
if [ "${pkg_name}" = "none" ]; then
pkg_name=""
else
pkg_name="-${pkg_name}"
fi
pkg_names=$(echo ${pkg_names} | cut -f2- -d ' ')
pkg_prefix=${package}${pkg_name}-${release}
else
pkg_name=""
pkg_prefix=${prefix}
fi
echo "] Package ${package} ${version}: remote-branch=${remote_branch} pkg-name=${pkg_name}"
git_submodules=$(git submodule | awk '{print $2}')
if [ -n "${git_submodules}" ]; then
echo "] git submodules found ...."
echo "git submodules init"
git submodule init
echo "git checkout ${remote_branch}"
git checkout ${remote_branch}
for s in ${git_submodules}
do
ok=$(echo ${git_submodules_excludes} | sed -e "s/.*${s}.*/no/g")
if [ "${ok}" != "no" ]; then
echo "git submodule update ${s}"
git submodule update ${s}
treeish=$(git ls-tree HEAD ${s} | awk '{print $3}')
cd ${s}
echo "git archive --format=tar --prefix=${pkg_prefix}/${s}/ ${treeish}"
git archive --format=tar --prefix=${pkg_prefix}/${s}/ ${treeish} > \
../../${stamped_tar}-${s}.tar
cd .. # ${s}
else
echo "git submodule ${s} excluded"
fi
done
echo "git checkout ${pkg_main}"
git checkout ${pkg_main}
fi
echo "git archive --format=tar --prefix=${pkg_prefix}/ ${remote_branch}"
git archive --format=tar --prefix=${pkg_prefix}/ ${remote_branch} > \
../${stamped_tar}.tar
cd .. # ${git_local}
if [ ! -f ${stamped_tar}.tar ]; then
echo "error: git archive failed, no tar file"
exit 1
fi
echo "tar xf ${stamped_tar}.tar"
tar xf ${stamped_tar}.tar
if [ -n "${git_submodules}" ]; then
for s in ${git_submodules}
do
ok=$(echo ${git_submodules_excludes} | sed -e "s/.*${s}.*/no/g")
if [ "${ok}" != "no" ]; then
echo "tar xf ${stamped_tar}-${s}.tar"
tar xf ${stamped_tar}-${s}.tar
fi
done
fi
cd ${pkg_prefix}
echo "] Creating VERSION: ${release}"
echo "[version]" > VERSION
echo "revision = ${release}" >> VERSION
cd .. # ${pkg_prefix}
#
# Run the worker script if provided. It can perform any package
# specific set up functions. This is done before we finally
# package the release.
#
if [ -n "${worker}" ]; then
wk_name=$(basename ${worker})
echo "] Worker: ${wk_name}"
${worker} ${package} ${version} ${revision} ${release_url} ${top}
fi
#
# The '..' is the release directory.
#
echo "tar cf - ${pkg_prefix}"
tar cf - ${pkg_prefix} | ${comp} > ../${pkg_prefix}.tar.${comp_ext}
echo "] Created: ${release}/${pkg_prefix}.tar.${comp_ext}"
#
# Update the global exported variables
#
echo "# Package ${package} ${version}: remote-branches=\"${pkg_branches}\" pkg-names=\"${pkg_names}\"" >> ${pkg_list}
echo "rtems_packages=\"\${rtems_packages} ${pkg_prefix}\"" >> ${pkg_list}
if [ ${add_rsb_hash} = yes ]; then
echo "rtems_rsb_hash_pkgs=\"\${rtems_rsb_hash_pkgs} ${pkg_prefix}\"" >> ${pkg_list}
fi
done
#
# Comman package end.
#
. ${top}/rtems-release-package-end
exit 0