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 | # Stop on any error |
---|
40 | # |
---|
41 | set -e |
---|
42 | |
---|
43 | # |
---|
44 | # Keep the top where we start. |
---|
45 | # |
---|
46 | top=${PWD} |
---|
47 | |
---|
48 | # |
---|
49 | # The version and revision. |
---|
50 | # |
---|
51 | if [ $# -ne 2 ]; then |
---|
52 | echo "error: must be 2 arguments, the version, and release." |
---|
53 | exit 1 |
---|
54 | fi |
---|
55 | version=$1 |
---|
56 | revision=$2 |
---|
57 | |
---|
58 | package=rtems-source-builder |
---|
59 | |
---|
60 | release=${version}.${revision} |
---|
61 | prefix=${package}-${release} |
---|
62 | |
---|
63 | checksum=sha512 |
---|
64 | |
---|
65 | workspace=ws-${package} |
---|
66 | |
---|
67 | # |
---|
68 | # Source the source packages to package (haha) |
---|
69 | # |
---|
70 | . rtems-source-packages |
---|
71 | |
---|
72 | echo "Package: ${package}" |
---|
73 | echo "Release: ${release}" |
---|
74 | |
---|
75 | if [ ! -e ${release} ]; then |
---|
76 | mkdir ${release} |
---|
77 | else |
---|
78 | if [ ! -d ${release} ]; then |
---|
79 | echo "error: ${release} exists and is not a directory." |
---|
80 | exit 1 |
---|
81 | fi |
---|
82 | fi |
---|
83 | |
---|
84 | # |
---|
85 | # Work in a package specific directory in the release directory. |
---|
86 | # |
---|
87 | cd ${release} |
---|
88 | rm -rf ${workspace} |
---|
89 | mkdir ${workspace} |
---|
90 | cd ${workspace} |
---|
91 | |
---|
92 | echo "tar Jxf ../${prefix}.tar.xz" |
---|
93 | tar Jxf ../${prefix}.tar.xz |
---|
94 | |
---|
95 | # |
---|
96 | # Get the RSB to download the source we need to release. This is 100% of the |
---|
97 | # actual sourced used. |
---|
98 | # |
---|
99 | cd ${prefix} |
---|
100 | cd rtems |
---|
101 | export_source=rtems |
---|
102 | mkdir sources patches |
---|
103 | # |
---|
104 | # Copy in any source not present on the server. If these are not copied in |
---|
105 | # the RSB does not find them. |
---|
106 | # |
---|
107 | for p in rtems-tools rtems |
---|
108 | do |
---|
109 | cp ${top}/${release}/${p}-${release}.tar.xz sources/ |
---|
110 | done |
---|
111 | # |
---|
112 | # Fetch the source for RTEMS tools. |
---|
113 | # |
---|
114 | echo "../source-builder/sb-set-builder --dry-run --with-download " \ |
---|
115 | "--without-error-report --without-release-url " \ |
---|
116 | "${rtems_pkgs}" |
---|
117 | ../source-builder/sb-set-builder --dry-run --with-download \ |
---|
118 | --without-error-report \ |
---|
119 | --without-release-url \ |
---|
120 | ${rtems_pkgs} |
---|
121 | # |
---|
122 | # If git, svn or cvs exist the release fails. |
---|
123 | # |
---|
124 | if [ -d sources/git -o -d sources/svn -o -d sources/cvs ]; then |
---|
125 | echo "error: ${release} contains repositories and cannot be released." |
---|
126 | exit 1 |
---|
127 | fi |
---|
128 | # |
---|
129 | # Clean out the packages we do not places in 'sources' we copied in.. |
---|
130 | # |
---|
131 | for p in rtems-tools rtems |
---|
132 | do |
---|
133 | rm sources/${p}-${release}.tar.xz |
---|
134 | done |
---|
135 | cd .. |
---|
136 | # |
---|
137 | # Fetch the source for 3rd party packages tools. |
---|
138 | # |
---|
139 | if [ -n "${bare_pkgs}" -a ${bare_pkgs} != None ]; then |
---|
140 | cd bare |
---|
141 | export_source=${export_source} bare |
---|
142 | echo "../source-builder/sb-set-builder --dry-run --with-download " \ |
---|
143 | "--without-error-report --without-release-url " \ |
---|
144 | "${bare_pkgs}" |
---|
145 | ../source-builder/sb-set-builder --dry-run --with-download \ |
---|
146 | --without-error-report \ |
---|
147 | --without-release-url \ |
---|
148 | ${bare_pkgs} |
---|
149 | # |
---|
150 | # If svn or cvs exist the release fails. |
---|
151 | # |
---|
152 | if [ -d sources/svn -o -d sources/cvs ]; then |
---|
153 | echo "error: ${release} contains repositories and cannot be released." |
---|
154 | exit 1 |
---|
155 | fi |
---|
156 | # |
---|
157 | # If there are git repos create packages of them as they are. |
---|
158 | # |
---|
159 | if [ -d sources/git ]; then |
---|
160 | cd sources |
---|
161 | cd git |
---|
162 | for g in $(ls) |
---|
163 | do |
---|
164 | cd ${g} |
---|
165 | hash=$(git status | grep '^HEAD detached at ' | sed 's/^HEAD detached at //') |
---|
166 | prefix=$(echo ${g}-${hash} | sed 's/\./\-/') |
---|
167 | echo "Packaging GIT repo: ${g} to ${prefix}" |
---|
168 | git archive --format=tar --prefix=${prefix}/ ${hash} | xz > ../../${prefix}.tar.xz |
---|
169 | cd .. |
---|
170 | done |
---|
171 | cd .. |
---|
172 | rm -rf git |
---|
173 | cd .. |
---|
174 | fi |
---|
175 | cd .. |
---|
176 | fi |
---|
177 | # |
---|
178 | # Export the sources and patches. |
---|
179 | # |
---|
180 | rm -rf ${top}/${release}/sources |
---|
181 | mkdir ${top}/${release}/sources |
---|
182 | for p in ${export_source} |
---|
183 | do |
---|
184 | cp ${p}/sources/* ${top}/${release}/sources/ |
---|
185 | cp ${p}/patches/* ${top}/${release}/sources/ |
---|
186 | done |
---|
187 | cd .. |
---|
188 | |
---|
189 | cd .. |
---|
190 | rm -rf ${workspace} |
---|
191 | cd .. |
---|
192 | |
---|
193 | cd ${release}/sources |
---|
194 | rm -f ${checksum}sum.txt |
---|
195 | for f in $(ls -1) |
---|
196 | do |
---|
197 | if [ ! -d ${f} ]; then |
---|
198 | csum=$(${checksum} -q ${f}) |
---|
199 | echo "${csum} ${f}" >> ${checksum}sum.txt |
---|
200 | fi |
---|
201 | done |
---|
202 | |
---|
203 | cd ../.. |
---|
204 | |
---|
205 | echo "Created: ${release}/sources/${checksum}sum.txt" |
---|
206 | echo "Created: ${release}/sources" |
---|
207 | |
---|
208 | exit 0 |
---|