1 | #! /bin/sh |
---|
2 | # |
---|
3 | # RTEMS Tools Project (http://www.rtems.org/) |
---|
4 | # Copyright 2015-2016 Chris Johns (chrisj@rtems.org) |
---|
5 | # All rights reserved. |
---|
6 | # |
---|
7 | # This file is part of the RTEMS Tools package in 'rtems-tools'. |
---|
8 | # |
---|
9 | # Redistribution and use in source and binary forms, with or without |
---|
10 | # modification, are permitted provided that the following conditions are met: |
---|
11 | # |
---|
12 | # 1. Redistributions of source code must retain the above copyright notice, |
---|
13 | # this list of conditions and the following disclaimer. |
---|
14 | # |
---|
15 | # 2. Redistributions in binary form must reproduce the above copyright notice, |
---|
16 | # this list of conditions and the following disclaimer in the documentation |
---|
17 | # and/or other materials provided with the distribution. |
---|
18 | # |
---|
19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
22 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
---|
23 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
24 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
25 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
26 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
27 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
28 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
29 | # POSSIBILITY OF SUCH DAMAGE. |
---|
30 | # |
---|
31 | |
---|
32 | # |
---|
33 | # The script collects the sources for all the tools. |
---|
34 | # |
---|
35 | |
---|
36 | echo "RTEMS Release Sources, v0.1" |
---|
37 | |
---|
38 | # |
---|
39 | # Defaults. |
---|
40 | # |
---|
41 | . ${release_top}/rtems-release-defaults |
---|
42 | |
---|
43 | # |
---|
44 | # The version and revision. |
---|
45 | # |
---|
46 | if [ $# -ne 2 ]; then |
---|
47 | echo "error: must be 2 arguments, the version, and release." |
---|
48 | exit 1 |
---|
49 | fi |
---|
50 | version=$1 |
---|
51 | revision=$2 |
---|
52 | |
---|
53 | package=rtems-source-builder |
---|
54 | |
---|
55 | release=${version}.${revision} |
---|
56 | prefix=${package}-${release} |
---|
57 | |
---|
58 | checksum=sha512 |
---|
59 | |
---|
60 | workspace=ws-${package} |
---|
61 | |
---|
62 | # |
---|
63 | # Source the source packages to package (haha) |
---|
64 | # |
---|
65 | . rtems-source-packages |
---|
66 | |
---|
67 | echo "Package: ${package}" |
---|
68 | echo "Release: ${release}" |
---|
69 | |
---|
70 | if [ ! -e ${release} ]; then |
---|
71 | mkdir ${release} |
---|
72 | else |
---|
73 | if [ ! -d ${release} ]; then |
---|
74 | echo "error: ${release} exists and is not a directory." |
---|
75 | exit 1 |
---|
76 | fi |
---|
77 | fi |
---|
78 | |
---|
79 | # |
---|
80 | # Work in a package specific directory in the release directory. |
---|
81 | # |
---|
82 | cd ${release} |
---|
83 | rm -rf ${workspace} |
---|
84 | mkdir ${workspace} |
---|
85 | cd ${workspace} |
---|
86 | |
---|
87 | echo "tar ${comp_tar}xf ../${prefix}.tar.${comp_ext}" |
---|
88 | tar ${comp_tar}xf ../${prefix}.tar.${comp_ext} |
---|
89 | |
---|
90 | # |
---|
91 | # Get the RSB to download the source we need to release. This is 100% of the |
---|
92 | # actual sourced used. |
---|
93 | # |
---|
94 | cd ${prefix} |
---|
95 | cd rtems |
---|
96 | export_source=rtems |
---|
97 | mkdir sources patches |
---|
98 | # |
---|
99 | # Copy in any source not present on the server. If these are not copied in |
---|
100 | # the RSB does not find them. |
---|
101 | # |
---|
102 | for p in rtems-tools rtems |
---|
103 | do |
---|
104 | cp ${top}/${release}/${p}-${release}.tar.${comp_ext} sources/ |
---|
105 | done |
---|
106 | # |
---|
107 | # Fetch the source for RTEMS tools. |
---|
108 | # |
---|
109 | echo "../source-builder/sb-set-builder --dry-run --with-download " \ |
---|
110 | "--without-error-report --without-release-url " \ |
---|
111 | "${rtems_pkgs}" |
---|
112 | ../source-builder/sb-set-builder --dry-run --with-download \ |
---|
113 | --without-error-report \ |
---|
114 | --without-release-url \ |
---|
115 | ${rtems_pkgs} |
---|
116 | # |
---|
117 | # Remove the top level packages because they do not have a VERSION file. |
---|
118 | # |
---|
119 | # These packages may or will be referencing git so remove those as well. |
---|
120 | # |
---|
121 | for p in rtems-tools rtems |
---|
122 | do |
---|
123 | rm sources/${p}-${release}.tar.${comp_ext} |
---|
124 | rm -rf sources/git/${p}.git |
---|
125 | done |
---|
126 | # |
---|
127 | # Remove the git, svn or cvs directory if empty. |
---|
128 | # |
---|
129 | for d in git svn cvs |
---|
130 | do |
---|
131 | if [ -e sources/${d} ]; then |
---|
132 | find sources/${d} -type d -empty -delete |
---|
133 | fi |
---|
134 | done |
---|
135 | # |
---|
136 | # If git, svn or cvs exist the release fails. |
---|
137 | # |
---|
138 | if [ -d sources/git -o -d sources/svn -o -d sources/cvs ]; then |
---|
139 | echo "error: ${release} contains repositories and cannot be released." |
---|
140 | exit 1 |
---|
141 | fi |
---|
142 | cd .. # rtems |
---|
143 | |
---|
144 | # |
---|
145 | # Fetch the source for 3rd party packages tools. |
---|
146 | # |
---|
147 | if [ -n "${bare_pkgs}" -a "${bare_pkgs}" != "None" ]; then |
---|
148 | cd bare |
---|
149 | export_source="${export_source} bare" |
---|
150 | mkdir sources patches |
---|
151 | echo "../source-builder/sb-set-builder --dry-run --with-download " \ |
---|
152 | "--without-error-report --without-release-url " \ |
---|
153 | "${bare_pkgs}" |
---|
154 | ../source-builder/sb-set-builder --dry-run --with-download \ |
---|
155 | --without-error-report \ |
---|
156 | --without-release-url \ |
---|
157 | ${bare_pkgs} |
---|
158 | # |
---|
159 | # Remove the git, svn or cvs directory if empty. |
---|
160 | # |
---|
161 | for d in git svn cvs |
---|
162 | do |
---|
163 | if [ -e sources/${d} ]; then |
---|
164 | find sources/${d} -type d -empty -delete |
---|
165 | fi |
---|
166 | done |
---|
167 | # |
---|
168 | # If svn or cvs exist the release fails. Git is ok. |
---|
169 | # |
---|
170 | if [ -d sources/svn -o -d sources/cvs ]; then |
---|
171 | echo "error: ${release} contains repositories and cannot be released." |
---|
172 | exit 1 |
---|
173 | fi |
---|
174 | # |
---|
175 | # If there are git repos create packages of them as they are. |
---|
176 | # |
---|
177 | if [ -d sources/git ]; then |
---|
178 | cd sources |
---|
179 | cd git |
---|
180 | for g in $(ls) |
---|
181 | do |
---|
182 | cd ${g} |
---|
183 | hash=$(git status | grep '^HEAD detached at ' | sed 's/^HEAD detached at //') |
---|
184 | prefix=$(echo ${g}-${hash} | sed 's/\./\-/') |
---|
185 | echo "Packaging GIT repo: ${g} to ${prefix}" |
---|
186 | git archive --format=tar --prefix=${prefix}/ ${hash} | \ |
---|
187 | ${comp} > ../../${prefix}.tar.${comp_ext} |
---|
188 | cd .. # ${g} |
---|
189 | done |
---|
190 | cd .. # git |
---|
191 | rm -rf git |
---|
192 | cd .. # source |
---|
193 | fi |
---|
194 | cd .. # ${bare} |
---|
195 | fi |
---|
196 | # |
---|
197 | # Export the sources and patches. |
---|
198 | # |
---|
199 | rm -rf ${top}/${release}/sources |
---|
200 | mkdir ${top}/${release}/sources |
---|
201 | for p in ${export_source} |
---|
202 | do |
---|
203 | cp ${p}/sources/* ${top}/${release}/sources/ |
---|
204 | cp ${p}/patches/* ${top}/${release}/sources/ |
---|
205 | done |
---|
206 | cd .. # ${prefix} |
---|
207 | cd .. # ${workspace} |
---|
208 | |
---|
209 | rm -rf ${workspace} |
---|
210 | |
---|
211 | # |
---|
212 | # Copy the stamped packages from the top level release directory to the |
---|
213 | # sources directory. The RSB requires all source be in the `sources` |
---|
214 | # directory under the release URL. |
---|
215 | # |
---|
216 | for p in rtems-tools rtems |
---|
217 | do |
---|
218 | cp ${p}-${release}.tar.${comp_ext} sources/${p}-${release}.tar.${comp_ext} |
---|
219 | done |
---|
220 | |
---|
221 | cd sources |
---|
222 | rm -f ${checksum}sum.txt |
---|
223 | for f in $(ls -1) |
---|
224 | do |
---|
225 | if [ ! -d ${f} ]; then |
---|
226 | csum=$(${checksum} -q ${f}) |
---|
227 | echo "${csum} ${f}" >> ${checksum}sum.txt |
---|
228 | fi |
---|
229 | done |
---|
230 | cd .. # sources |
---|
231 | cd .. # ${release} |
---|
232 | |
---|
233 | echo "Created: ${release}/sources/${checksum}sum.txt" |
---|
234 | echo "Created: ${release}/sources" |
---|
235 | |
---|
236 | exit 0 |
---|