File: submit

package info (click to toggle)
calendarserver 9.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 25,688 kB
  • sloc: python: 195,037; sql: 78,794; xml: 16,936; sh: 2,502; ansic: 66; makefile: 26
file content (221 lines) | stat: -rwxr-xr-x 5,480 bytes parent folder | download
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/sh

##
# Copyright (c) 2005-2017 Apple Inc. All rights reserved.
#
# 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.
##

##
# Submit project to B&I (Apple internal build)
##

set -e
set -u


 wd="$(cd "$(dirname "$0")" && pwd)";
src="$(cd "${wd}/.." && pwd)";

unset CALENDARSERVER_BUILD_DEPS;

project="CalendarServer";
uri="https://github.com/apple/ccs-calendarserver.git";

##
# Command line
##

  build=false;
install=false;
package=false;

    build_no_verify_source=false;
              tag_to_build="";
           project_version="";

usage ()
{
  program="$(basename "$0")";

  if [ "${1-}" != "-" ]; then echo "$@"; echo; fi;

  echo "Usage: ${program} release [release ...]";
  echo "       ${program} release -b[ipn]";
  echo "";
  echo "Options:";
  echo "	-b Run buildit";
  echo "	-i Install resulting build on this system";
  echo "	-p Create a package with the resulting build";
  echo "	-n skip buildit source verification";
  echo "  -t which tag to submit";
  echo "  -v project version (defaults to -t value)";

  if [ "${1-}" == "-" ]; then return 0; fi;
  exit 64;
}

while getopts 'hbipnt:v:' option; do
  case "$option" in
    '?') usage; ;;
    'h') usage -; exit 0; ;;
    'b')                      build=true; ;;
    'i')                    install=true; ;;
    'p')                    package=true; ;;
    'n') 	   build_no_verify_source=true; ;;
    't')        tag_to_build="${OPTARG}"; ;;
    'v')     project_version="${OPTARG}"; ;;
  esac;
done;
shift $((${OPTIND} - 1));

if [ "${tag_to_build}" != "" ]; then
  if [ "${project_version}" == "" ]; then
    project_version="${tag_to_build}";
  fi;
fi;


if ! "${build}"; then
  # Submitting, not just building
  if "${install}"; then usage "-i flag requires -b"; fi;
  if "${package}"; then usage "-p flag requires -b"; fi;
  if "${build_no_verify_source}"; then usage "-n flag requires -b"; fi;
  if [ "${project_version}" == "" ]; then usage "project_version required if submitting"; fi;
else
  # Not submitting, just building
  if [ "${project_version}" == "" ]; then
    project_version="${project}-untagged";
  fi;
fi;

if [ $# == 0 ]; then usage "No releases specified"; fi;
releases="$@"; shift $#;

if [ $# != 0 ]; then usage "Unrecognized arguments:" "$@"; fi;

##
# Do the Right Thing
##

#
# Do submission
#

tmp="$(mktemp -d -t CalendarServer_build)";
wc="${tmp}/${project_version}";

echo "${tag_to_build}";

if [ "${tag_to_build}" != "" ]; then
  # Clone and checkout tag
  git clone "${uri}" "${wc}";
  cd "${wc}";
  git checkout "${tag_to_build}";
else
  # Copy from local directory
  echo "";
  echo "Copying ${src}...";
  # Only copy files that are under revision control
  git_files="$(mktemp -t git_files_XXXX)";
  cd "${src}";
  git ls-tree --name-only -r HEAD > "${git_files}";
  rsync -av                      \
    --files-from="${git_files}"  \
    "${src}/" "${wc}"            \
    ;
  rm "${git_files}";
fi;

cd "${wc}";

echo ""
echo "Tweaking for B&I...";
ln -s support/Apple.make "${wc}/Makefile";

cat - >> "${wc}/SubmissionInfo.xml" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<submission>
 <project>${project}</project>
 <version>${project_version}</version>
 <source>
  <git>
   <repository>${uri}</repository>
   <tag>${tag_to_build}</tag>
   <date>$(date -u)</date>
  </git>
 </source>
</submission>
EOF

echo "${tag_to_build}" > "${wc}/gitversion.txt";

echo "";
echo "Preparing sources for ${project_version}...";
"${wc}/support/_cache_deps";

# Clean up after _cache_deps
find "${wc}/.develop" -depth 1 ! '(' -name pip_downloads -o -name tools ')' -print | {
  while read filename; do
    echo "Cruft in .develop: ${filename}";
    # exit 1;
  done;
}

if "${build}"; then
  echo "";
  echo "Building ${project_version}...";

  if "${package}"; then
    package_tmp="${tmp}/pkg";
    install -d "${package_tmp}";
    merge_flags="-merge ${package_tmp}";
  elif "${install}"; then
    merge_flags="-merge /";
  else
    merge_flags="";
  fi;

  release_flags="";
  for release in "${releases}"; do
    release_flags="${release_flags} -update Prevailing${release}";
  done;

  if "${build_no_verify_source}"; then
    verify_flags=" -noverifysource";
  else
    verify_flags="";
  fi;

  sudo ~rc/bin/buildit "${wc}" \
    $(file /System/Library/Frameworks/Python.framework/Versions/Current/Python | sed -n -e 's|^.*(for architecture \([^)][^)]*\).*$|-arch \1|p' | sed 's|ppc7400|ppc|') \
    ${merge_flags}${release_flags}${verify_flags};

  if "${package}"; then
    package_file="${src}/${project_version}.tgz";
    echo "Creating package: ${package_file}...";
    tar -C "${package_tmp}" -cvzf "${package_file}" .;
    sudo rm -rf "${package_tmp}";
    if "${install}"; then
      echo "Installing package: ${package_file}";
      tar -C / -xvzf "${package_file}";
    fi;
  fi;
else
  echo "";
  echo "Submitting sources for ${project_version}...";
  rm -rf "${wc}/.dependencies";
  ~rc/bin/submitproject "${wc}" ${releases};
fi;

sudo rm -rf "${tmp}";