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 | # This script packages a package in a tar file. |
---|
34 | # |
---|
35 | echo "RTEMS Release Package, v0.1" |
---|
36 | |
---|
37 | # |
---|
38 | # Defaults. |
---|
39 | # |
---|
40 | . ${release_top}/rtems-release-defaults |
---|
41 | |
---|
42 | # |
---|
43 | # Common package start. |
---|
44 | # |
---|
45 | . ./rtems-release-package-start |
---|
46 | |
---|
47 | # |
---|
48 | # Work in a package specific directory in the release directory. |
---|
49 | # |
---|
50 | echo "git clone ${git_remote} ${git_local}" |
---|
51 | git clone ${git_remote} ${git_local} |
---|
52 | |
---|
53 | stamped_tar=${prefix}-unstamped |
---|
54 | |
---|
55 | # |
---|
56 | # Clone the repo and then check if there are any submodules. |
---|
57 | # |
---|
58 | # If there are submodules, exclude the ones we do not wish to package, eg the |
---|
59 | # whole of the FreeBSD source tree. For the ones to package get the commit |
---|
60 | # (treeish) for the branch we releasing and then create an archive. The |
---|
61 | # submodule archives are merged into the main archive once we have collected |
---|
62 | # them all. |
---|
63 | # |
---|
64 | # |
---|
65 | cd ${git_local} |
---|
66 | echo "git fetch origin" |
---|
67 | git fetch origin |
---|
68 | git_submodules=$(git submodule | cut -w -f 2) |
---|
69 | if [ -n "${git_submodules}" ]; then |
---|
70 | echo "git submodules found ...." |
---|
71 | git submodule init |
---|
72 | for s in ${git_submodules} |
---|
73 | do |
---|
74 | ok=$(echo ${git_submodules_excludes} | sed -e "s/.*${s}.*/no/g") |
---|
75 | if [ "${ok}" != "no" ]; then |
---|
76 | echo "git submodule update ${s}" |
---|
77 | git submodule update ${s} |
---|
78 | treeish=$(git ls-tree origin/${version} ${s} | cut -w -f 3) |
---|
79 | cd ${s} |
---|
80 | echo "git archive --format=tar --prefix=${prefix}/${s}/ ${treeish}" |
---|
81 | git archive --format=tar --prefix=${prefix}/${s}/ ${treeish} > \ |
---|
82 | ../../${stamped_tar}-${s}.tar |
---|
83 | cd .. # ${s} |
---|
84 | else |
---|
85 | echo "git submodule ${s} excluded" |
---|
86 | fi |
---|
87 | done |
---|
88 | fi |
---|
89 | echo "git archive --format=tar --prefix=${prefix}/ origin/${version}" |
---|
90 | git archive --format=tar --prefix=${prefix}/ origin/${version} > \ |
---|
91 | ../${stamped_tar}.tar |
---|
92 | cd .. # ${git_local} |
---|
93 | |
---|
94 | if [ ! -f ${stamped_tar}.tar ]; then |
---|
95 | echo "error: git archive failed, no tar file" |
---|
96 | exit 1 |
---|
97 | fi |
---|
98 | echo "tar xf ${stamped_tar}.tar" |
---|
99 | tar Jxf ${stamped_tar}.tar |
---|
100 | if [ -n "${git_submodules}" ]; then |
---|
101 | for s in ${git_submodules} |
---|
102 | do |
---|
103 | ok=$(echo ${git_submodules_excludes} | sed -e "s/.*${s}.*/no/g") |
---|
104 | if [ "${ok}" != "no" ]; then |
---|
105 | echo "tar xf ${stamped_tar}-${s}.tar" |
---|
106 | tar Jxf ${stamped_tar}-${s}.tar |
---|
107 | fi |
---|
108 | done |
---|
109 | fi |
---|
110 | |
---|
111 | cd ${prefix} |
---|
112 | echo "Creating VERSION: ${release}" |
---|
113 | echo "[version]" > VERSION |
---|
114 | echo "release = ${release}" >> VERSION |
---|
115 | cd .. # ${prefix} |
---|
116 | |
---|
117 | # |
---|
118 | # Run the worker script if provided. It can perform any package |
---|
119 | # specific set up functions. This is done before we finally |
---|
120 | # package the release. |
---|
121 | # |
---|
122 | if [ -n "${worker}" ]; then |
---|
123 | ${worker} ${package} ${version} ${revision} ${top} |
---|
124 | fi |
---|
125 | |
---|
126 | # |
---|
127 | # The '..' is the release directory. |
---|
128 | # |
---|
129 | echo "tar cf - ${prefix}" |
---|
130 | tar cf - ${prefix} | ${comp} > ../${prefix}.tar.${comp_ext} |
---|
131 | |
---|
132 | echo "Created: ${release}/${prefix}.tar.${comp_ext}" |
---|
133 | |
---|
134 | # |
---|
135 | # Comman package end. |
---|
136 | # |
---|
137 | . ${top}/rtems-release-package-end |
---|
138 | |
---|
139 | exit 0 |
---|