Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: build/linux/sysroot_scripts/sysroot-creator.sh

Issue 2023703002: Beginning work on GN build (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Really add //build. Add dart_bootstrap rule. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 #
5 # This script should not be run directly but sourced by the other
6 # scripts (e.g. sysroot-creator-trusty.sh). Its up to the parent scripts
7 # to define certain environment variables: e.g.
8 # DISTRO=ubuntu
9 # DIST=trusty
10 # APT_REPO=http://archive.ubuntu.com/ubuntu
11 # KEYRING_FILE=/usr/share/keyrings/ubuntu-archive-keyring.gpg
12 # DEBIAN_PACKAGES="gcc libz libssl"
13
14 #@ This script builds a Debian sysroot images for building Google Chrome.
15 #@
16 #@ Generally this script is invoked as:
17 #@ sysroot-creator-<flavour>.sh <mode> <args>*
18 #@ Available modes are shown below.
19 #@
20 #@ List of modes:
21
22 ######################################################################
23 # Config
24 ######################################################################
25
26 set -o nounset
27 set -o errexit
28
29 SCRIPT_DIR=$(cd $(dirname $0) && pwd)
30
31 if [ -z "${DIST:-}" ]; then
32 echo "error: DIST not defined"
33 exit 1
34 fi
35
36 if [ -z "${APT_REPO:-}" ]; then
37 echo "error: APT_REPO not defined"
38 exit 1
39 fi
40
41 if [ -z "${KEYRING_FILE:-}" ]; then
42 echo "error: KEYRING_FILE not defined"
43 exit 1
44 fi
45
46 if [ -z "${DEBIAN_PACKAGES:-}" ]; then
47 echo "error: DEBIAN_PACKAGES not defined"
48 exit 1
49 fi
50
51 readonly REPO_BASEDIR="${APT_REPO}/dists/${DIST}"
52
53 readonly REQUIRED_TOOLS="wget"
54
55 ######################################################################
56 # Package Config
57 ######################################################################
58
59 PACKAGES_EXT=${PACKAGES_EXT:-bz2}
60 readonly RELEASE_FILE="Release"
61 readonly RELEASE_FILE_GPG="Release.gpg"
62 readonly RELEASE_LIST="${REPO_BASEDIR}/${RELEASE_FILE}"
63 readonly RELEASE_LIST_GPG="${REPO_BASEDIR}/${RELEASE_FILE_GPG}"
64 readonly PACKAGE_FILE_AMD64="main/binary-amd64/Packages.${PACKAGES_EXT}"
65 readonly PACKAGE_FILE_I386="main/binary-i386/Packages.${PACKAGES_EXT}"
66 readonly PACKAGE_FILE_ARM="main/binary-armhf/Packages.${PACKAGES_EXT}"
67 readonly PACKAGE_FILE_MIPS="main/binary-mipsel/Packages.${PACKAGES_EXT}"
68 readonly PACKAGE_LIST_AMD64="${REPO_BASEDIR}/${PACKAGE_FILE_AMD64}"
69 readonly PACKAGE_LIST_I386="${REPO_BASEDIR}/${PACKAGE_FILE_I386}"
70 readonly PACKAGE_LIST_ARM="${REPO_BASEDIR}/${PACKAGE_FILE_ARM}"
71 readonly PACKAGE_LIST_MIPS="${REPO_BASEDIR}/${PACKAGE_FILE_MIPS}"
72
73 readonly DEBIAN_DEP_LIST_AMD64="packagelist.${DIST}.amd64"
74 readonly DEBIAN_DEP_LIST_I386="packagelist.${DIST}.i386"
75 readonly DEBIAN_DEP_LIST_ARM="packagelist.${DIST}.arm"
76 readonly DEBIAN_DEP_LIST_MIPS="packagelist.${DIST}.mipsel"
77
78 ######################################################################
79 # Helper
80 ######################################################################
81
82 Banner() {
83 echo "######################################################################"
84 echo $*
85 echo "######################################################################"
86 }
87
88
89 SubBanner() {
90 echo "----------------------------------------------------------------------"
91 echo $*
92 echo "----------------------------------------------------------------------"
93 }
94
95
96 Usage() {
97 egrep "^#@" "${BASH_SOURCE[0]}" | cut --bytes=3-
98 }
99
100
101 DownloadOrCopy() {
102 if [ -f "$2" ] ; then
103 echo "$2 already in place"
104 return
105 fi
106
107 HTTP=0
108 echo "$1" | grep -qs ^http:// && HTTP=1
109 if [ "$HTTP" = "1" ]; then
110 SubBanner "downloading from $1 -> $2"
111 wget "$1" -O "${2}.partial"
112 mv "${2}.partial" $2
113 else
114 SubBanner "copying from $1"
115 cp "$1" "$2"
116 fi
117 }
118
119
120 SetEnvironmentVariables() {
121 ARCH=""
122 echo $1 | grep -qs Amd64$ && ARCH=AMD64
123 if [ -z "$ARCH" ]; then
124 echo $1 | grep -qs I386$ && ARCH=I386
125 fi
126 if [ -z "$ARCH" ]; then
127 echo $1 | grep -qs Mips$ && ARCH=MIPS
128 fi
129 if [ -z "$ARCH" ]; then
130 echo $1 | grep -qs ARM$ && ARCH=ARM
131 fi
132 if [ -z "${ARCH}" ]; then
133 echo "ERROR: Unable to determine architecture based on: $1"
134 exit 1
135 fi
136 ARCH_LOWER=$(echo $ARCH | tr '[:upper:]' '[:lower:]')
137 }
138
139
140 # some sanity checks to make sure this script is run from the right place
141 # with the right tools
142 SanityCheck() {
143 Banner "Sanity Checks"
144
145 local chrome_dir=$(cd "${SCRIPT_DIR}/../../.." && pwd)
146 BUILD_DIR="${chrome_dir}/out/sysroot-build/${DIST}"
147 mkdir -p ${BUILD_DIR}
148 echo "Using build directory: ${BUILD_DIR}"
149
150 for tool in ${REQUIRED_TOOLS} ; do
151 if ! which ${tool} > /dev/null ; then
152 echo "Required binary $tool not found."
153 echo "Exiting."
154 exit 1
155 fi
156 done
157
158 # This is where the staging sysroot is.
159 INSTALL_ROOT="${BUILD_DIR}/${DIST}_${ARCH_LOWER}_staging"
160 TARBALL="${BUILD_DIR}/${DISTRO}_${DIST}_${ARCH_LOWER}_sysroot.tgz"
161
162 if ! mkdir -p "${INSTALL_ROOT}" ; then
163 echo "ERROR: ${INSTALL_ROOT} can't be created."
164 exit 1
165 fi
166 }
167
168
169 ChangeDirectory() {
170 # Change directory to where this script is.
171 cd ${SCRIPT_DIR}
172 }
173
174
175 ClearInstallDir() {
176 Banner "Clearing dirs in ${INSTALL_ROOT}"
177 rm -rf ${INSTALL_ROOT}/*
178 }
179
180
181 CreateTarBall() {
182 Banner "Creating tarball ${TARBALL}"
183 tar zcf ${TARBALL} -C ${INSTALL_ROOT} .
184 }
185
186 ExtractPackageBz2() {
187 if [ "${PACKAGES_EXT}" == "bz2" ]; then
188 bzcat "$1" | egrep '^(Package:|Filename:|SHA256:) ' > "$2"
189 else
190 xzcat "$1" | egrep '^(Package:|Filename:|SHA256:) ' > "$2"
191 fi
192 }
193
194 GeneratePackageListAmd64() {
195 local output_file="$1"
196 local package_list="${BUILD_DIR}/Packages.${DIST}_amd64.${PACKAGES_EXT}"
197 local tmp_package_list="${BUILD_DIR}/Packages.${DIST}_amd64"
198 DownloadOrCopy "${PACKAGE_LIST_AMD64}" "${package_list}"
199 VerifyPackageListing "${PACKAGE_FILE_AMD64}" "${package_list}"
200 ExtractPackageBz2 "$package_list" "$tmp_package_list"
201 GeneratePackageList "$tmp_package_list" "$output_file" "${DEBIAN_PACKAGES}
202 ${DEBIAN_PACKAGES_X86} ${DEBIAN_PACKAGES_AMD64}"
203 }
204
205 GeneratePackageListI386() {
206 local output_file="$1"
207 local package_list="${BUILD_DIR}/Packages.${DIST}_i386.${PACKAGES_EXT}"
208 local tmp_package_list="${BUILD_DIR}/Packages.${DIST}_amd64"
209 DownloadOrCopy "${PACKAGE_LIST_I386}" "${package_list}"
210 VerifyPackageListing "${PACKAGE_FILE_I386}" "${package_list}"
211 ExtractPackageBz2 "$package_list" "$tmp_package_list"
212 GeneratePackageList "$tmp_package_list" "$output_file" "${DEBIAN_PACKAGES}
213 ${DEBIAN_PACKAGES_X86}"
214 }
215
216 GeneratePackageListARM() {
217 local output_file="$1"
218 local package_list="${BUILD_DIR}/Packages.${DIST}_arm.${PACKAGES_EXT}"
219 local tmp_package_list="${BUILD_DIR}/Packages.${DIST}_arm"
220 DownloadOrCopy "${PACKAGE_LIST_ARM}" "${package_list}"
221 VerifyPackageListing "${PACKAGE_FILE_ARM}" "${package_list}"
222 ExtractPackageBz2 "$package_list" "$tmp_package_list"
223 GeneratePackageList "$tmp_package_list" "$output_file" "${DEBIAN_PACKAGES}
224 ${DEBIAN_PACKAGES_ARM}"
225 }
226
227 GeneratePackageListMips() {
228 local output_file="$1"
229 local package_list="${BUILD_DIR}/Packages.${DIST}_mips.${PACKAGES_EXT}"
230 local tmp_package_list="${BUILD_DIR}/Packages.${DIST}_mips"
231 DownloadOrCopy "${PACKAGE_LIST_MIPS}" "${package_list}"
232 VerifyPackageListing "${PACKAGE_FILE_MIPS}" "${package_list}"
233 ExtractPackageBz2 "$package_list" "$tmp_package_list"
234 GeneratePackageList "$tmp_package_list" "$output_file" "${DEBIAN_PACKAGES}"
235 }
236
237 StripChecksumsFromPackageList() {
238 local package_file="$1"
239 sed -i 's/ [a-f0-9]\{64\}$//' "$package_file"
240 }
241
242 VerifyPackageFilesMatch() {
243 local downloaded_package_file="$1"
244 local stored_package_file="$2"
245 diff -u "$downloaded_package_file" "$stored_package_file"
246 if [ "$?" -ne "0" ]; then
247 echo "ERROR: downloaded package files does not match $2."
248 echo "You may need to run UpdatePackageLists."
249 exit 1
250 fi
251 }
252
253 ######################################################################
254 #
255 ######################################################################
256
257 HacksAndPatchesAmd64() {
258 Banner "Misc Hacks & Patches"
259 # these are linker scripts with absolute pathnames in them
260 # which we rewrite here
261 lscripts="${INSTALL_ROOT}/usr/lib/x86_64-linux-gnu/libpthread.so \
262 ${INSTALL_ROOT}/usr/lib/x86_64-linux-gnu/libc.so"
263
264 # Rewrite linker scripts
265 sed -i -e 's|/usr/lib/x86_64-linux-gnu/||g' ${lscripts}
266 sed -i -e 's|/lib/x86_64-linux-gnu/||g' ${lscripts}
267
268 # This is for chrome's ./build/linux/pkg-config-wrapper
269 # which overwrites PKG_CONFIG_LIBDIR internally
270 SubBanner "Move pkgconfig scripts"
271 mkdir -p ${INSTALL_ROOT}/usr/lib/pkgconfig
272 mv ${INSTALL_ROOT}/usr/lib/x86_64-linux-gnu/pkgconfig/* \
273 ${INSTALL_ROOT}/usr/lib/pkgconfig
274
275 SubBanner "Adding an additional ld.conf include"
276 LD_SO_HACK_CONF="${INSTALL_ROOT}/etc/ld.so.conf.d/zz_hack.conf"
277 echo /usr/lib/gcc/x86_64-linux-gnu/4.6 > "$LD_SO_HACK_CONF"
278 echo /usr/lib >> "$LD_SO_HACK_CONF"
279 }
280
281
282 HacksAndPatchesI386() {
283 Banner "Misc Hacks & Patches"
284 # these are linker scripts with absolute pathnames in them
285 # which we rewrite here
286 lscripts="${INSTALL_ROOT}/usr/lib/i386-linux-gnu/libpthread.so \
287 ${INSTALL_ROOT}/usr/lib/i386-linux-gnu/libc.so"
288
289 # Rewrite linker scripts
290 sed -i -e 's|/usr/lib/i386-linux-gnu/||g' ${lscripts}
291 sed -i -e 's|/lib/i386-linux-gnu/||g' ${lscripts}
292
293 # This is for chrome's ./build/linux/pkg-config-wrapper
294 # which overwrites PKG_CONFIG_LIBDIR internally
295 SubBanner "Move pkgconfig scripts"
296 mkdir -p ${INSTALL_ROOT}/usr/lib/pkgconfig
297 mv ${INSTALL_ROOT}/usr/lib/i386-linux-gnu/pkgconfig/* \
298 ${INSTALL_ROOT}/usr/lib/pkgconfig
299
300 SubBanner "Adding an additional ld.conf include"
301 LD_SO_HACK_CONF="${INSTALL_ROOT}/etc/ld.so.conf.d/zz_hack.conf"
302 echo /usr/lib/gcc/i486-linux-gnu/4.6 > "$LD_SO_HACK_CONF"
303 echo /usr/lib >> "$LD_SO_HACK_CONF"
304 }
305
306
307 HacksAndPatchesARM() {
308 Banner "Misc Hacks & Patches"
309 # these are linker scripts with absolute pathnames in them
310 # which we rewrite here
311 lscripts="${INSTALL_ROOT}/usr/lib/arm-linux-gnueabihf/libpthread.so \
312 ${INSTALL_ROOT}/usr/lib/arm-linux-gnueabihf/libc.so"
313
314 # Rewrite linker scripts
315 sed -i -e 's|/usr/lib/arm-linux-gnueabihf/||g' ${lscripts}
316 sed -i -e 's|/lib/arm-linux-gnueabihf/||g' ${lscripts}
317
318 # This is for chrome's ./build/linux/pkg-config-wrapper
319 # which overwrites PKG_CONFIG_LIBDIR internally
320 SubBanner "Move pkgconfig files"
321 mkdir -p ${INSTALL_ROOT}/usr/lib/pkgconfig
322 mv ${INSTALL_ROOT}/usr/lib/arm-linux-gnueabihf/pkgconfig/* \
323 ${INSTALL_ROOT}/usr/lib/pkgconfig
324 }
325
326
327 HacksAndPatchesMips() {
328 Banner "Misc Hacks & Patches"
329 # these are linker scripts with absolute pathnames in them
330 # which we rewrite here
331 lscripts="${INSTALL_ROOT}/usr/lib/mipsel-linux-gnu/libpthread.so \
332 ${INSTALL_ROOT}/usr/lib/mipsel-linux-gnu/libc.so"
333
334 # Rewrite linker scripts
335 sed -i -e 's|/usr/lib/mipsel-linux-gnu/||g' ${lscripts}
336 sed -i -e 's|/lib/mipsel-linux-gnu/||g' ${lscripts}
337
338 # This is for chrome's ./build/linux/pkg-config-wrapper
339 # which overwrites PKG_CONFIG_LIBDIR internally
340 SubBanner "Move pkgconfig files"
341 mkdir -p ${INSTALL_ROOT}/usr/lib/pkgconfig
342 mv ${INSTALL_ROOT}/usr/lib/mipsel-linux-gnu/pkgconfig/* \
343 ${INSTALL_ROOT}/usr/lib/pkgconfig
344 }
345
346
347 InstallIntoSysroot() {
348 Banner "Install Libs And Headers Into Jail"
349
350 mkdir -p ${BUILD_DIR}/debian-packages
351 mkdir -p ${INSTALL_ROOT}
352 while (( "$#" )); do
353 local file="$1"
354 local package="${BUILD_DIR}/debian-packages/${file##*/}"
355 shift
356 local sha256sum="$1"
357 shift
358 if [ "${#sha256sum}" -ne "64" ]; then
359 echo "Bad sha256sum from package list"
360 exit 1
361 fi
362
363 Banner "Installing ${file}"
364 DownloadOrCopy ${APT_REPO}/pool/${file} ${package}
365 if [ ! -s "${package}" ] ; then
366 echo
367 echo "ERROR: bad package ${package}"
368 exit 1
369 fi
370 echo "${sha256sum} ${package}" | sha256sum --quiet -c
371
372 SubBanner "Extracting to ${INSTALL_ROOT}"
373 dpkg --fsys-tarfile ${package}\
374 | tar -xf - -C ${INSTALL_ROOT}
375
376 done
377
378 # Prune /usr/share, leaving only pkgconfig
379 for name in ${INSTALL_ROOT}/usr/share/*; do
380 if [ "${name}" != "${INSTALL_ROOT}/usr/share/pkgconfig" ]; then
381 rm -r ${name}
382 fi
383 done
384 }
385
386
387 CleanupJailSymlinks() {
388 Banner "Jail symlink cleanup"
389
390 SAVEDPWD=$(pwd)
391 cd ${INSTALL_ROOT}
392 local libdirs="lib usr/lib"
393 if [ "${ARCH}" != "MIPS" ]; then
394 libdirs+=" lib64"
395 fi
396 find $libdirs -type l -printf '%p %l\n' | while read link target; do
397 # skip links with non-absolute paths
398 echo "${target}" | grep -qs ^/ || continue
399 echo "${link}: ${target}"
400 case "${link}" in
401 usr/lib/gcc/*-linux-gnu/4.*/* | usr/lib/gcc/arm-linux-gnueabihf/4.*/*)
402 # Relativize the symlink.
403 ln -snfv "../../../../..${target}" "${link}"
404 ;;
405 usr/lib/*-linux-gnu/* | usr/lib/arm-linux-gnueabihf/*)
406 # Relativize the symlink.
407 ln -snfv "../../..${target}" "${link}"
408 ;;
409 usr/lib/*)
410 # Relativize the symlink.
411 ln -snfv "../..${target}" "${link}"
412 ;;
413 lib64/* | lib/*)
414 # Relativize the symlink.
415 ln -snfv "..${target}" "${link}"
416 ;;
417 esac
418 done
419
420 find $libdirs -type l -printf '%p %l\n' | while read link target; do
421 # Make sure we catch new bad links.
422 if [ ! -r "${link}" ]; then
423 echo "ERROR: FOUND BAD LINK ${link}"
424 ls -l ${link}
425 exit 1
426 fi
427 done
428 cd "$SAVEDPWD"
429 }
430
431 #@
432 #@ BuildSysrootAmd64
433 #@
434 #@ Build everything and package it
435 BuildSysrootAmd64() {
436 ClearInstallDir
437 local package_file="$BUILD_DIR/package_with_sha256sum_amd64"
438 GeneratePackageListAmd64 "$package_file"
439 local files_and_sha256sums="$(cat ${package_file})"
440 StripChecksumsFromPackageList "$package_file"
441 VerifyPackageFilesMatch "$package_file" "$DEBIAN_DEP_LIST_AMD64"
442 InstallIntoSysroot ${files_and_sha256sums}
443 CleanupJailSymlinks
444 HacksAndPatchesAmd64
445 CreateTarBall
446 }
447
448 #@
449 #@ BuildSysrootI386
450 #@
451 #@ Build everything and package it
452 BuildSysrootI386() {
453 ClearInstallDir
454 local package_file="$BUILD_DIR/package_with_sha256sum_i386"
455 GeneratePackageListI386 "$package_file"
456 local files_and_sha256sums="$(cat ${package_file})"
457 StripChecksumsFromPackageList "$package_file"
458 VerifyPackageFilesMatch "$package_file" "$DEBIAN_DEP_LIST_I386"
459 InstallIntoSysroot ${files_and_sha256sums}
460 CleanupJailSymlinks
461 HacksAndPatchesI386
462 CreateTarBall
463 }
464
465 #@
466 #@ BuildSysrootARM
467 #@
468 #@ Build everything and package it
469 BuildSysrootARM() {
470 ClearInstallDir
471 local package_file="$BUILD_DIR/package_with_sha256sum_arm"
472 GeneratePackageListARM "$package_file"
473 local files_and_sha256sums="$(cat ${package_file})"
474 StripChecksumsFromPackageList "$package_file"
475 VerifyPackageFilesMatch "$package_file" "$DEBIAN_DEP_LIST_ARM"
476 APT_REPO=${APR_REPO_ARM:=$APT_REPO}
477 InstallIntoSysroot ${files_and_sha256sums}
478 CleanupJailSymlinks
479 HacksAndPatchesARM
480 CreateTarBall
481 }
482
483 #@
484 #@ BuildSysrootMips
485 #@
486 #@ Build everything and package it
487 BuildSysrootMips() {
488 ClearInstallDir
489 local package_file="$BUILD_DIR/package_with_sha256sum_arm"
490 GeneratePackageListMips "$package_file"
491 local files_and_sha256sums="$(cat ${package_file})"
492 StripChecksumsFromPackageList "$package_file"
493 VerifyPackageFilesMatch "$package_file" "$DEBIAN_DEP_LIST_MIPS"
494 APT_REPO=${APR_REPO_MIPS:=$APT_REPO}
495 InstallIntoSysroot ${files_and_sha256sums}
496 CleanupJailSymlinks
497 HacksAndPatchesMips
498 CreateTarBall
499 }
500
501 #@
502 #@ BuildSysrootAll
503 #@
504 #@ Build sysroot images for all architectures
505 BuildSysrootAll() {
506 RunCommand BuildSysrootAmd64
507 RunCommand BuildSysrootI386
508 RunCommand BuildSysrootARM
509 RunCommand BuildSysrootMips
510 }
511
512 UploadSysroot() {
513 local rev=$1
514 if [ -z "${rev}" ]; then
515 echo "Please specify a revision to upload at."
516 exit 1
517 fi
518 set -x
519 gsutil cp -a public-read "${TARBALL}" \
520 "gs://chrome-linux-sysroot/toolchain/$rev/"
521 set +x
522 }
523
524 #@
525 #@ UploadSysrootAmd64 <revision>
526 #@
527 UploadSysrootAmd64() {
528 UploadSysroot "$@"
529 }
530
531 #@
532 #@ UploadSysrootI386 <revision>
533 #@
534 UploadSysrootI386() {
535 UploadSysroot "$@"
536 }
537
538 #@
539 #@ UploadSysrootARM <revision>
540 #@
541 UploadSysrootARM() {
542 UploadSysroot "$@"
543 }
544
545 #@
546 #@ UploadSysrootMips <revision>
547 #@
548 UploadSysrootMips() {
549 UploadSysroot "$@"
550 }
551
552 #@
553 #@ UploadSysrootAll <revision>
554 #@
555 #@ Upload sysroot image for all architectures
556 UploadSysrootAll() {
557 RunCommand UploadSysrootAmd64 "$@"
558 RunCommand UploadSysrootI386 "$@"
559 RunCommand UploadSysrootARM "$@"
560 RunCommand UploadSysrootMips "$@"
561 }
562
563 #
564 # CheckForDebianGPGKeyring
565 #
566 # Make sure the Debian GPG keys exist. Otherwise print a helpful message.
567 #
568 CheckForDebianGPGKeyring() {
569 if [ ! -e "$KEYRING_FILE" ]; then
570 echo "KEYRING_FILE not found: ${KEYRING_FILE}"
571 echo "Debian GPG keys missing. Install the debian-archive-keyring package."
572 exit 1
573 fi
574 }
575
576 #
577 # VerifyPackageListing
578 #
579 # Verifies the downloaded Packages.bz2 file has the right checksums.
580 #
581 VerifyPackageListing() {
582 local file_path=$1
583 local output_file=$2
584 local release_file="${BUILD_DIR}/${RELEASE_FILE}"
585 local release_file_gpg="${BUILD_DIR}/${RELEASE_FILE_GPG}"
586
587 CheckForDebianGPGKeyring
588
589 DownloadOrCopy ${RELEASE_LIST} ${release_file}
590 DownloadOrCopy ${RELEASE_LIST_GPG} ${release_file_gpg}
591 echo "Verifying: ${release_file} with ${release_file_gpg}"
592 set -x
593 gpgv --keyring "${KEYRING_FILE}" "${release_file_gpg}" "${release_file}"
594 set +x
595
596 echo "Verifying: ${output_file}"
597 local checksums=$(grep ${file_path} ${release_file} | cut -d " " -f 2)
598 local sha256sum=$(echo ${checksums} | cut -d " " -f 3)
599
600 if [ "${#sha256sum}" -ne "64" ]; then
601 echo "Bad sha256sum from ${RELEASE_LIST}"
602 exit 1
603 fi
604
605 echo "${sha256sum} ${output_file}" | sha256sum --quiet -c
606 }
607
608 #
609 # GeneratePackageList
610 #
611 # Looks up package names in ${BUILD_DIR}/Packages and write list of URLs
612 # to output file.
613 #
614 GeneratePackageList() {
615 local input_file="$1"
616 local output_file="$2"
617 echo "Updating: ${output_file} from ${input_file}"
618 /bin/rm -f "${output_file}"
619 shift
620 shift
621 for pkg in $@ ; do
622 local pkg_full=$(grep -A 1 " ${pkg}\$" "$input_file" | \
623 egrep -o "pool/.*")
624 if [ -z "${pkg_full}" ]; then
625 echo "ERROR: missing package: $pkg"
626 exit 1
627 fi
628 local pkg_nopool=$(echo "$pkg_full" | sed "s/^pool\///")
629 local sha256sum=$(grep -A 4 " ${pkg}\$" "$input_file" | \
630 grep ^SHA256: | sed 's/^SHA256: //')
631 if [ "${#sha256sum}" -ne "64" ]; then
632 echo "Bad sha256sum from Packages"
633 exit 1
634 fi
635 echo $pkg_nopool $sha256sum >> "$output_file"
636 done
637 # sort -o does an in-place sort of this file
638 sort "$output_file" -o "$output_file"
639 }
640
641 #@
642 #@ UpdatePackageListsAmd64
643 #@
644 #@ Regenerate the package lists such that they contain an up-to-date
645 #@ list of URLs within the Debian archive. (For amd64)
646 UpdatePackageListsAmd64() {
647 GeneratePackageListAmd64 "$DEBIAN_DEP_LIST_AMD64"
648 StripChecksumsFromPackageList "$DEBIAN_DEP_LIST_AMD64"
649 }
650
651 #@
652 #@ UpdatePackageListsI386
653 #@
654 #@ Regenerate the package lists such that they contain an up-to-date
655 #@ list of URLs within the Debian archive. (For i386)
656 UpdatePackageListsI386() {
657 GeneratePackageListI386 "$DEBIAN_DEP_LIST_I386"
658 StripChecksumsFromPackageList "$DEBIAN_DEP_LIST_I386"
659 }
660
661 #@
662 #@ UpdatePackageListsARM
663 #@
664 #@ Regenerate the package lists such that they contain an up-to-date
665 #@ list of URLs within the Debian archive. (For arm)
666 UpdatePackageListsARM() {
667 GeneratePackageListARM "$DEBIAN_DEP_LIST_ARM"
668 StripChecksumsFromPackageList "$DEBIAN_DEP_LIST_ARM"
669 }
670
671 #@
672 #@ UpdatePackageListsMips
673 #@
674 #@ Regenerate the package lists such that they contain an up-to-date
675 #@ list of URLs within the Debian archive. (For arm)
676 UpdatePackageListsMips() {
677 GeneratePackageListMips "$DEBIAN_DEP_LIST_MIPS"
678 StripChecksumsFromPackageList "$DEBIAN_DEP_LIST_MIPS"
679 }
680
681 #@
682 #@ UpdatePackageListsAll
683 #@
684 #@ Regenerate the package lists for all architectures.
685 UpdatePackageListsAll() {
686 RunCommand UpdatePackageListsAmd64
687 RunCommand UpdatePackageListsI386
688 RunCommand UpdatePackageListsARM
689 RunCommand UpdatePackageListsMips
690 }
691
692 RunCommand() {
693 SetEnvironmentVariables "$1"
694 SanityCheck
695 "$@"
696 }
697
698 if [ $# -eq 0 ] ; then
699 echo "ERROR: you must specify a mode on the commandline"
700 echo
701 Usage
702 exit 1
703 elif [ "$(type -t $1)" != "function" ]; then
704 echo "ERROR: unknown function '$1'." >&2
705 echo "For help, try:"
706 echo " $0 help"
707 exit 1
708 else
709 ChangeDirectory
710 if echo $1 | grep -qs "All$"; then
711 "$@"
712 else
713 RunCommand "$@"
714 fi
715 fi
OLDNEW
« no previous file with comments | « build/linux/sysroot_scripts/packagelist.wheezy.mipsel ('k') | build/linux/sysroot_scripts/sysroot-creator-jessie.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698