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 # DIST_UPDATES=trusty-updates |
10 # APT_REPO=http://archive.ubuntu.com/ubuntu | 11 # APT_REPO=http://archive.ubuntu.com/ubuntu |
11 # KEYRING_FILE=/usr/share/keyrings/ubuntu-archive-keyring.gpg | 12 # KEYRING_FILE=/usr/share/keyrings/ubuntu-archive-keyring.gpg |
12 # DEBIAN_PACKAGES="gcc libz libssl" | 13 # DEBIAN_PACKAGES="gcc libz libssl" |
13 | 14 |
14 #@ This script builds Debian/Ubuntu sysroot images for building Google Chrome. | 15 #@ This script builds Debian/Ubuntu sysroot images for building Google Chrome. |
15 #@ | 16 #@ |
16 #@ Generally this script is invoked as: | 17 #@ Generally this script is invoked as: |
17 #@ sysroot-creator-<flavour>.sh <mode> <args>* | 18 #@ sysroot-creator-<flavour>.sh <mode> <args>* |
18 #@ Available modes are shown below. | 19 #@ Available modes are shown below. |
19 #@ | 20 #@ |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 DownloadOrCopy() { | 97 DownloadOrCopy() { |
97 if [ -f "$2" ] ; then | 98 if [ -f "$2" ] ; then |
98 echo "$2 already in place" | 99 echo "$2 already in place" |
99 return | 100 return |
100 fi | 101 fi |
101 | 102 |
102 HTTP=0 | 103 HTTP=0 |
103 echo "$1" | grep -qs ^http:// && HTTP=1 | 104 echo "$1" | grep -qs ^http:// && HTTP=1 |
104 if [ "$HTTP" = "1" ]; then | 105 if [ "$HTTP" = "1" ]; then |
105 SubBanner "downloading from $1 -> $2" | 106 SubBanner "downloading from $1 -> $2" |
106 wget "$1" -O "${2}.partial" | 107 # Appending the "$$" shell pid is necessary here to prevent concurrent |
107 mv "${2}.partial" $2 | 108 # instances of sysroot-creator.sh from trying to write to the same file. |
| 109 wget "$1" -O "${2}.partial.$$" |
| 110 mv "${2}.partial.$$" $2 |
108 else | 111 else |
109 SubBanner "copying from $1" | 112 SubBanner "copying from $1" |
110 cp "$1" "$2" | 113 cp "$1" "$2" |
111 fi | 114 fi |
112 } | 115 } |
113 | 116 |
114 | 117 |
115 SetEnvironmentVariables() { | 118 SetEnvironmentVariables() { |
116 ARCH="" | 119 ARCH="" |
117 echo $1 | grep -qs Amd64$ && ARCH=AMD64 | 120 echo $1 | grep -qs Amd64$ && ARCH=AMD64 |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 550 |
548 #@ | 551 #@ |
549 #@ BuildSysrootMips | 552 #@ BuildSysrootMips |
550 #@ | 553 #@ |
551 #@ Build everything and package it | 554 #@ Build everything and package it |
552 BuildSysrootMips() { | 555 BuildSysrootMips() { |
553 if [ "$HAS_ARCH_MIPS" = "0" ]; then | 556 if [ "$HAS_ARCH_MIPS" = "0" ]; then |
554 return | 557 return |
555 fi | 558 fi |
556 ClearInstallDir | 559 ClearInstallDir |
557 local package_file="$BUILD_DIR/package_with_sha256sum_arm" | 560 local package_file="$BUILD_DIR/package_with_sha256sum_mips" |
558 GeneratePackageListMips "$package_file" | 561 GeneratePackageListMips "$package_file" |
559 local files_and_sha256sums="$(cat ${package_file})" | 562 local files_and_sha256sums="$(cat ${package_file})" |
560 StripChecksumsFromPackageList "$package_file" | 563 StripChecksumsFromPackageList "$package_file" |
561 VerifyPackageFilesMatch "$package_file" "$DEBIAN_DEP_LIST_MIPS" | 564 VerifyPackageFilesMatch "$package_file" "$DEBIAN_DEP_LIST_MIPS" |
562 APT_REPO=${APT_REPO_MIPS:=$APT_REPO} | 565 APT_REPO=${APT_REPO_MIPS:=$APT_REPO} |
563 InstallIntoSysroot ${files_and_sha256sums} | 566 InstallIntoSysroot ${files_and_sha256sums} |
564 CleanupJailSymlinks | 567 CleanupJailSymlinks |
565 HacksAndPatchesMips | 568 HacksAndPatchesMips |
566 CreateTarBall | 569 CreateTarBall |
567 } | 570 } |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 #@ | 809 #@ |
807 #@ Regenerate the package lists for all architectures. | 810 #@ Regenerate the package lists for all architectures. |
808 UpdatePackageListsAll() { | 811 UpdatePackageListsAll() { |
809 RunCommand UpdatePackageListsAmd64 | 812 RunCommand UpdatePackageListsAmd64 |
810 RunCommand UpdatePackageListsI386 | 813 RunCommand UpdatePackageListsI386 |
811 RunCommand UpdatePackageListsARM | 814 RunCommand UpdatePackageListsARM |
812 RunCommand UpdatePackageListsARM64 | 815 RunCommand UpdatePackageListsARM64 |
813 RunCommand UpdatePackageListsMips | 816 RunCommand UpdatePackageListsMips |
814 } | 817 } |
815 | 818 |
| 819 DumpStringsStderr() { |
| 820 echo "$1" | xargs echo | tr ' ' '\n' | sort 1>&2 |
| 821 } |
| 822 |
| 823 #@ |
| 824 #@ DumpPackageListsAmd64 |
| 825 #@ |
| 826 #@ Prints required packages for amd64 architecture to stderr. |
| 827 DumpPackageListsAmd64() { |
| 828 DumpStringsStderr "${DEBIAN_PACKAGES} ${DEBIAN_PACKAGES_X86:=} |
| 829 ${DEBIAN_PACKAGES_AMD64:=}" |
| 830 } |
| 831 |
| 832 #@ |
| 833 #@ DumpPackageListsI386 |
| 834 #@ |
| 835 #@ Prints required packages for i386 architecture to stderr. |
| 836 DumpPackageListsI386() { |
| 837 DumpStringsStderr "${DEBIAN_PACKAGES} ${DEBIAN_PACKAGES_X86:=}" |
| 838 } |
| 839 |
| 840 #@ |
| 841 #@ DumpPackageListsARM |
| 842 #@ |
| 843 #@ Prints required packages for arm architecture to stderr. |
| 844 DumpPackageListsARM() { |
| 845 DumpStringsStderr "${DEBIAN_PACKAGES} ${DEBIAN_PACKAGES_ARM:=}" |
| 846 } |
| 847 |
| 848 #@ |
| 849 #@ DumpPackageListsARM64 |
| 850 #@ |
| 851 #@ Prints required packages for arm64 architecture to stderr. |
| 852 DumpPackageListsARM64() { |
| 853 DumpStringsStderr "${DEBIAN_PACKAGES} ${DEBIAN_PACKAGES_ARM64:=}" |
| 854 } |
| 855 |
| 856 #@ |
| 857 #@ DumpPackageListsMips |
| 858 #@ |
| 859 #@ Prints required packages for mips architecture to stderr. |
| 860 DumpPackageListsMips() { |
| 861 DumpStringsStderr "${DEBIAN_PACKAGES}" |
| 862 } |
| 863 |
| 864 #@ |
| 865 #@ PrintArchitectures |
| 866 #@ |
| 867 #@ Prints supported architectures. |
| 868 PrintArchitectures() { |
| 869 if [ "$HAS_ARCH_AMD64" = "1" ]; then |
| 870 echo Amd64 |
| 871 fi |
| 872 if [ "$HAS_ARCH_I386" = "1" ]; then |
| 873 echo I386 |
| 874 fi |
| 875 if [ "$HAS_ARCH_ARM" = "1" ]; then |
| 876 echo ARM |
| 877 fi |
| 878 if [ "$HAS_ARCH_ARM64" = "1" ]; then |
| 879 echo ARM64 |
| 880 fi |
| 881 if [ "$HAS_ARCH_MIPS" = "1" ]; then |
| 882 echo Mips |
| 883 fi |
| 884 } |
| 885 |
| 886 #@ |
| 887 #@ PrintDistro |
| 888 #@ |
| 889 #@ Prints distro. eg: ubuntu |
| 890 PrintDistro() { |
| 891 echo ${DISTRO} |
| 892 } |
| 893 |
| 894 #@ |
| 895 #@ DumpRelease |
| 896 #@ |
| 897 #@ Prints disto release. eg: trusty |
| 898 PrintRelease() { |
| 899 echo ${DIST} |
| 900 } |
| 901 |
816 RunCommand() { | 902 RunCommand() { |
817 SetEnvironmentVariables "$1" | 903 SetEnvironmentVariables "$1" |
818 SanityCheck | 904 SanityCheck |
819 "$@" | 905 "$@" |
820 } | 906 } |
821 | 907 |
822 if [ $# -eq 0 ] ; then | 908 if [ $# -eq 0 ] ; then |
823 echo "ERROR: you must specify a mode on the commandline" | 909 echo "ERROR: you must specify a mode on the commandline" |
824 echo | 910 echo |
825 Usage | 911 Usage |
826 exit 1 | 912 exit 1 |
827 elif [ "$(type -t $1)" != "function" ]; then | 913 elif [ "$(type -t $1)" != "function" ]; then |
828 echo "ERROR: unknown function '$1'." >&2 | 914 echo "ERROR: unknown function '$1'." >&2 |
829 echo "For help, try:" | 915 echo "For help, try:" |
830 echo " $0 help" | 916 echo " $0 help" |
831 exit 1 | 917 exit 1 |
832 else | 918 else |
833 ChangeDirectory | 919 ChangeDirectory |
834 if echo $1 | grep -qs "All$"; then | 920 if echo $1 | grep -qs --regexp='\(^Print\)\|\(All$\)'; then |
835 "$@" | 921 "$@" |
836 else | 922 else |
837 RunCommand "$@" | 923 RunCommand "$@" |
838 fi | 924 fi |
839 fi | 925 fi |
OLD | NEW |