OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 # | 4 # |
5 # This script should not be run directly but sourced by the other | 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 | 6 # scripts (e.g. sysroot-creator-trusty.sh). Its up to the parent scripts |
7 # to define certain environment variables: e.g. | 7 # to define certain environment variables: e.g. |
8 # DISTRO=ubuntu | 8 # DISTRO=ubuntu |
9 # DIST=trusty | 9 # DIST=trusty |
10 # APT_REPO=http://archive.ubuntu.com/ubuntu | 10 # APT_REPO=http://archive.ubuntu.com/ubuntu |
(...skipping 30 matching lines...) Expand all Loading... |
41 if [ -z "${KEYRING_FILE:-}" ]; then | 41 if [ -z "${KEYRING_FILE:-}" ]; then |
42 echo "error: KEYRING_FILE not defined" | 42 echo "error: KEYRING_FILE not defined" |
43 exit 1 | 43 exit 1 |
44 fi | 44 fi |
45 | 45 |
46 if [ -z "${DEBIAN_PACKAGES:-}" ]; then | 46 if [ -z "${DEBIAN_PACKAGES:-}" ]; then |
47 echo "error: DEBIAN_PACKAGES not defined" | 47 echo "error: DEBIAN_PACKAGES not defined" |
48 exit 1 | 48 exit 1 |
49 fi | 49 fi |
50 | 50 |
51 readonly REPO_BASEDIR="${APT_REPO}/dists/${DIST}" | |
52 | |
53 readonly HAS_ARCH_AMD64=${HAS_ARCH_AMD64:=0} | 51 readonly HAS_ARCH_AMD64=${HAS_ARCH_AMD64:=0} |
54 readonly HAS_ARCH_I386=${HAS_ARCH_I386:=0} | 52 readonly HAS_ARCH_I386=${HAS_ARCH_I386:=0} |
55 readonly HAS_ARCH_ARM=${HAS_ARCH_ARM:=0} | 53 readonly HAS_ARCH_ARM=${HAS_ARCH_ARM:=0} |
56 readonly HAS_ARCH_ARM64=${HAS_ARCH_ARM64:=0} | 54 readonly HAS_ARCH_ARM64=${HAS_ARCH_ARM64:=0} |
57 readonly HAS_ARCH_MIPS=${HAS_ARCH_MIPS:=0} | 55 readonly HAS_ARCH_MIPS=${HAS_ARCH_MIPS:=0} |
58 | 56 |
59 readonly REQUIRED_TOOLS="wget" | 57 readonly REQUIRED_TOOLS="wget" |
60 | 58 |
61 ###################################################################### | 59 ###################################################################### |
62 # Package Config | 60 # Package Config |
63 ###################################################################### | 61 ###################################################################### |
64 | 62 |
65 PACKAGES_EXT=${PACKAGES_EXT:-bz2} | 63 PACKAGES_EXT=${PACKAGES_EXT:-bz2} |
66 readonly RELEASE_FILE="Release" | 64 readonly RELEASE_FILE="Release" |
67 readonly RELEASE_FILE_GPG="Release.gpg" | 65 readonly RELEASE_FILE_GPG="Release.gpg" |
68 readonly RELEASE_LIST="${REPO_BASEDIR}/${RELEASE_FILE}" | |
69 readonly RELEASE_LIST_GPG="${REPO_BASEDIR}/${RELEASE_FILE_GPG}" | |
70 | 66 |
71 readonly DEBIAN_DEP_LIST_AMD64="packagelist.${DIST}.amd64" | 67 readonly DEBIAN_DEP_LIST_AMD64="packagelist.${DIST}.amd64" |
72 readonly DEBIAN_DEP_LIST_I386="packagelist.${DIST}.i386" | 68 readonly DEBIAN_DEP_LIST_I386="packagelist.${DIST}.i386" |
73 readonly DEBIAN_DEP_LIST_ARM="packagelist.${DIST}.arm" | 69 readonly DEBIAN_DEP_LIST_ARM="packagelist.${DIST}.arm" |
74 readonly DEBIAN_DEP_LIST_ARM64="packagelist.${DIST}.arm64" | 70 readonly DEBIAN_DEP_LIST_ARM64="packagelist.${DIST}.arm64" |
75 readonly DEBIAN_DEP_LIST_MIPS="packagelist.${DIST}.mipsel" | 71 readonly DEBIAN_DEP_LIST_MIPS="packagelist.${DIST}.mipsel" |
76 | 72 |
77 ###################################################################### | 73 ###################################################################### |
78 # Helper | 74 # Helper |
79 ###################################################################### | 75 ###################################################################### |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 182 } |
187 | 183 |
188 ExtractPackageBz2() { | 184 ExtractPackageBz2() { |
189 if [ "${PACKAGES_EXT}" = "bz2" ]; then | 185 if [ "${PACKAGES_EXT}" = "bz2" ]; then |
190 bzcat "$1" | egrep '^(Package:|Filename:|SHA256:) ' > "$2" | 186 bzcat "$1" | egrep '^(Package:|Filename:|SHA256:) ' > "$2" |
191 else | 187 else |
192 xzcat "$1" | egrep '^(Package:|Filename:|SHA256:) ' > "$2" | 188 xzcat "$1" | egrep '^(Package:|Filename:|SHA256:) ' > "$2" |
193 fi | 189 fi |
194 } | 190 } |
195 | 191 |
196 GeneratePackageListCommon() { | 192 GeneratePackageListDist() { |
197 local output_file="$1" | 193 local arch="$1" |
198 local arch="$2" | 194 local apt_repo="$2" |
199 local apt_repo="$3" | 195 local dist="$3" |
200 local packages="$4" | |
201 | 196 |
202 local repo_basedir="${apt_repo}/dists/${DIST}" | 197 TMP_PACKAGE_LIST="${BUILD_DIR}/Packages.${dist}_${arch}" |
203 local package_list="${BUILD_DIR}/Packages.${DIST}_${arch}.${PACKAGES_EXT}" | 198 local repo_basedir="${apt_repo}/dists/${dist}" |
204 local tmp_package_list="${BUILD_DIR}/Packages.${DIST}_${arch}" | 199 local package_list="${BUILD_DIR}/Packages.${dist}_${arch}.${PACKAGES_EXT}" |
205 local package_file_arch="main/binary-${arch}/Packages.${PACKAGES_EXT}" | 200 local package_file_arch="main/binary-${arch}/Packages.${PACKAGES_EXT}" |
206 local package_list_arch="${repo_basedir}/${package_file_arch}" | 201 local package_list_arch="${repo_basedir}/${package_file_arch}" |
207 | 202 |
208 DownloadOrCopy "${package_list_arch}" "${package_list}" | 203 DownloadOrCopy "${package_list_arch}" "${package_list}" |
209 VerifyPackageListing "${package_file_arch}" "${package_list}" | 204 VerifyPackageListing "${package_file_arch}" "${package_list}" ${dist} |
210 ExtractPackageBz2 "$package_list" "$tmp_package_list" | 205 ExtractPackageBz2 "${package_list}" "${TMP_PACKAGE_LIST}" |
211 GeneratePackageList "$tmp_package_list" "$output_file" "${packages}" | 206 } |
| 207 |
| 208 GeneratePackageListCommon() { |
| 209 GeneratePackageListDist "$2" "$3" ${DIST} |
| 210 local output_file="$1" |
| 211 local packages="$4" |
| 212 local list_base="${TMP_PACKAGE_LIST}" |
| 213 if [ ! -z ${DIST_UPDATES:-} ]; then |
| 214 GeneratePackageListDist "$2" "$3" ${DIST_UPDATES} |
| 215 cat "${TMP_PACKAGE_LIST}" | ./merge-package-lists.py "${list_base}" |
| 216 fi |
| 217 GeneratePackageList "${list_base}" "${output_file}" "${packages}" |
212 } | 218 } |
213 | 219 |
214 GeneratePackageListAmd64() { | 220 GeneratePackageListAmd64() { |
215 GeneratePackageListCommon "$1" amd64 ${APT_REPO} "${DEBIAN_PACKAGES} | 221 GeneratePackageListCommon "$1" amd64 ${APT_REPO} "${DEBIAN_PACKAGES} |
216 ${DEBIAN_PACKAGES_X86:=} ${DEBIAN_PACKAGES_AMD64:=}" | 222 ${DEBIAN_PACKAGES_X86:=} ${DEBIAN_PACKAGES_AMD64:=}" |
217 } | 223 } |
218 | 224 |
219 GeneratePackageListI386() { | 225 GeneratePackageListI386() { |
220 GeneratePackageListCommon "$1" i386 ${APT_REPO} "${DEBIAN_PACKAGES} | 226 GeneratePackageListCommon "$1" i386 ${APT_REPO} "${DEBIAN_PACKAGES} |
221 ${DEBIAN_PACKAGES_X86:=}" | 227 ${DEBIAN_PACKAGES_X86:=}" |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 exit 1 | 657 exit 1 |
652 fi | 658 fi |
653 } | 659 } |
654 | 660 |
655 # | 661 # |
656 # VerifyPackageListing | 662 # VerifyPackageListing |
657 # | 663 # |
658 # Verifies the downloaded Packages.bz2 file has the right checksums. | 664 # Verifies the downloaded Packages.bz2 file has the right checksums. |
659 # | 665 # |
660 VerifyPackageListing() { | 666 VerifyPackageListing() { |
661 local file_path=$1 | 667 local file_path="$1" |
662 local output_file=$2 | 668 local output_file="$2" |
663 local release_file="${BUILD_DIR}/${RELEASE_FILE}" | 669 local dist="$3" |
664 local release_file_gpg="${BUILD_DIR}/${RELEASE_FILE_GPG}" | 670 |
| 671 local repo_basedir="${APT_REPO}/dists/${dist}" |
| 672 local release_list="${repo_basedir}/${RELEASE_FILE}" |
| 673 local release_list_gpg="${repo_basedir}/${RELEASE_FILE_GPG}" |
| 674 |
| 675 local release_file="${BUILD_DIR}/${dist}-${RELEASE_FILE}" |
| 676 local release_file_gpg="${BUILD_DIR}/${dist}-${RELEASE_FILE_GPG}" |
665 | 677 |
666 CheckForDebianGPGKeyring | 678 CheckForDebianGPGKeyring |
667 | 679 |
668 DownloadOrCopy ${RELEASE_LIST} ${release_file} | 680 DownloadOrCopy ${release_list} ${release_file} |
669 DownloadOrCopy ${RELEASE_LIST_GPG} ${release_file_gpg} | 681 DownloadOrCopy ${release_list_gpg} ${release_file_gpg} |
670 echo "Verifying: ${release_file} with ${release_file_gpg}" | 682 echo "Verifying: ${release_file} with ${release_file_gpg}" |
671 set -x | 683 set -x |
672 gpgv --keyring "${KEYRING_FILE}" "${release_file_gpg}" "${release_file}" | 684 gpgv --keyring "${KEYRING_FILE}" "${release_file_gpg}" "${release_file}" |
673 set +x | 685 set +x |
674 | 686 |
675 echo "Verifying: ${output_file}" | 687 echo "Verifying: ${output_file}" |
676 local checksums=$(grep ${file_path} ${release_file} | cut -d " " -f 2) | 688 local checksums=$(grep ${file_path} ${release_file} | cut -d " " -f 2) |
677 local sha256sum=$(echo ${checksums} | cut -d " " -f 3) | 689 local sha256sum=$(echo ${checksums} | cut -d " " -f 3) |
678 | 690 |
679 if [ "${#sha256sum}" -ne "64" ]; then | 691 if [ "${#sha256sum}" -ne "64" ]; then |
680 echo "Bad sha256sum from ${RELEASE_LIST}" | 692 echo "Bad sha256sum from ${release_list}" |
681 exit 1 | 693 exit 1 |
682 fi | 694 fi |
683 | 695 |
684 echo "${sha256sum} ${output_file}" | sha256sum --quiet -c | 696 echo "${sha256sum} ${output_file}" | sha256sum --quiet -c |
685 } | 697 } |
686 | 698 |
687 # | 699 # |
688 # GeneratePackageList | 700 # GeneratePackageList |
689 # | 701 # |
690 # Looks up package names in ${BUILD_DIR}/Packages and write list of URLs | 702 # Looks up package names in ${BUILD_DIR}/Packages and write list of URLs |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 echo " $0 help" | 823 echo " $0 help" |
812 exit 1 | 824 exit 1 |
813 else | 825 else |
814 ChangeDirectory | 826 ChangeDirectory |
815 if echo $1 | grep -qs "All$"; then | 827 if echo $1 | grep -qs "All$"; then |
816 "$@" | 828 "$@" |
817 else | 829 else |
818 RunCommand "$@" | 830 RunCommand "$@" |
819 fi | 831 fi |
820 fi | 832 fi |
OLD | NEW |