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

Side by Side Diff: ports/devenv/package

Issue 1285953002: Switch devenv to use pkg packages (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@toolchain_install
Patch Set: Created 5 years, 4 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
« no previous file with comments | « ports/devenv/install-base-packages.sh ('k') | ports/devenv/setup-environment » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 # Copyright (c) 2014 The Native Client Authors. All rights reserved. 2 # Copyright (c) 2014 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # Package installer script for use inside the devenv environment. 6 # Package installer script for use inside the devenv environment.
7 # Assumes setup-environment has been source at least once in the parent 7 # Assumes setup-environment has been source at least once in the parent
8 # environment. 8 # environment.
9 # Written to avoid using anything other than bash, geturl, and unzip when 9 # Written to avoid using anything other than bash, geturl, and unzip when
10 # installing core packages. 10 # installing core packages.
11 11
12 set -o errexit 12 set -o errexit
13 set -o nounset 13 set -o nounset
14 shopt -s nullglob 14 shopt -s nullglob
15 15
16 NACL_ARCH_ALT="${NACL_ARCH}"
17 if [[ "${TOOLCHAIN}" == "pnacl" ]]; then
18 NACL_ARCH_ALT="pnacl"
19 fi
20
21 PKG_ARCH="${NACL_ARCH}"
22 if [[ "${TOOLCHAIN}" == "pnacl" ]]; then
23 PKG_ARCH="pnacl"
24 fi
zhitingzhu 2015/08/18 19:13:24 Looks like this can be combined: NACL_ARCH_ALT="$
Sam Clegg 2015/08/18 23:13:39 Removed.
25 if [[ "${NACL_ARCH}" == "x86_64" ]]; then
26 PKG_ARCH="x86-64"
27 fi
28
16 STORAGE_URL=${STORAGE_URL:-https://naclports.storage.googleapis.com/builds} 29 STORAGE_URL=${STORAGE_URL:-https://naclports.storage.googleapis.com/builds}
17 SDK_VERSION=${SDK_VERSION:-pepper_46} 30 SDK_VERSION=${SDK_VERSION:-pepper_46}
18 31
19 # This default version for packages that are downloaded and installed. 32 # This default version for packages that are downloaded and installed.
20 # To update this use 'git describe <rev>' to get the revision string. Be 33 # To update this use 'git describe <rev>' to get the revision string. Be
21 # sure to wait until the bot have build all the packages for a given 34 # sure to wait until the bot have build all the packages for a given
22 # revision before changing this value. 35 # revision before changing this value.
23 36
24 REVISION=${REVISION:-trunk-583-g2ea9c03} 37 REVISION=${REVISION:-trunk-606-g394684c}
25 DEFAULT_SOURCE="${STORAGE_URL}/${SDK_VERSION}/${REVISION}/publish" 38 PKG_DIR=pkg_${TOOLCHAIN}_${PKG_ARCH}
26 LOCAL_SOURCE="http://localhost:5103/" 39 DEFAULT_SOURCE="${STORAGE_URL}/${SDK_VERSION}/${REVISION}/publish/${PKG_DIR}"
40 LOCAL_SOURCE="http://localhost:5103/${PKG_DIR}"
27 VERBOSE=0 41 VERBOSE=0
28 42
29 NACL_ARCH_ALT="${NACL_ARCH}"
30 if [[ "${TOOLCHAIN}" == "pnacl" ]]; then
31 NACL_ARCH_ALT="pnacl"
32 fi
33
34 # Locations for package archives. 43 # Locations for package archives.
35 # Prefer this one going forward: 44 # Prefer this one going forward:
36 PACKAGE_BY_ARCH=${TOOLCHAIN}/${NACL_ARCH_ALT}.zip 45 PACKAGE_BY_ARCH=${TOOLCHAIN}/${NACL_ARCH_ALT}.zip
37 # Old default: 46 # Old default:
38 PACKAGE_AS_ONE=${TOOLCHAIN}.zip 47 PACKAGE_AS_ONE=${TOOLCHAIN}.zip
39 48
40 # List of packages (keep sorted). 49 # List of packages (keep sorted).
41 # Pairs of <package-name>:<status><package-subdir>[:<source>:<alt-subdir>] 50 # Pairs of <package-name>:<status><package-subdir>[:<source>:<alt-subdir>]
42 PACKAGE_INFO="\ 51 PACKAGE_INFO="\
43 bash|ok|${PACKAGE_BY_ARCH} \
44 blackbox|WIP|${PACKAGE_BY_ARCH} \
45 busybox|WIP|glibc/busybox-1.22.0.zip \
46 bzip2|ok|${PACKAGE_BY_ARCH} \
47 civitweb|WIP|${PACKAGE_AS_ONE} \
48 coreutils|ok|${PACKAGE_BY_ARCH} \
49 curl|ok|${PACKAGE_AS_ONE} \
50 drod|WIP|${PACKAGE_AS_ONE} \
51 emacs|ok|glibc/emacs-24.3.zip \
52 findutils|ok|${PACKAGE_BY_ARCH} \
53 fvwm|ok|${PACKAGE_BY_ARCH} \
54 gawk|ok|${PACKAGE_BY_ARCH} \
55 gforth|ok|${PACKAGE_AS_ONE} \
56 git|ok|${PACKAGE_BY_ARCH} \
57 grep|ok|${PACKAGE_BY_ARCH} \
58 less|ok|${PACKAGE_BY_ARCH} \
59 lua5.3|ok|${PACKAGE_BY_ARCH} \
60 m4|ok|${PACKAGE_BY_ARCH} \
61 make|ok|${PACKAGE_BY_ARCH} \
62 mingn.base|ok|glibc/tarballs/base.${NACL_ARCH}.zip \
63 mingn.lib|ok|glibc/tarballs/lib.all.zip \
64 nano|ok|${PACKAGE_AS_ONE} \
65 nethack|ok|${PACKAGE_AS_ONE} \
66 ninja|WIP|${PACKAGE_BY_ARCH} \
67 openssh|ok|glibc.zip \
68 python3|WIP|${TOOLCHAIN}/python.zip \
69 python|ok|${TOOLCHAIN}/python.zip \
70 ruby|ok|${TOOLCHAIN}/ruby.zip \
71 sqlite|ok|${PACKAGE_AS_ONE} \
72 subversion|WIP|${PACKAGE_BY_ARCH} \
73 tar|WIP|${PACKAGE_AS_ONE} \
74 texlive|ok|${PACKAGE_BY_ARCH} \
75 thttpd|ok|glibc.zip \
76 tk|ok|${PACKAGE_BY_ARCH} \
77 toybox|WIP|${TOOLCHAIN}/toybox-0.4.7.zip \
78 twm|ok|${PACKAGE_BY_ARCH} \
79 vim|ok|${PACKAGE_AS_ONE} \
80 xeyes|ok|${PACKAGE_BY_ARCH} \
81 xz|ok|${PACKAGE_BY_ARCH} \
82 " 52 "
83 53
84 ALIASES="\ 54 ALIASES="\
85 lua|lua5.3 55 bash|bash-4.3 \
56 binutils|binutils-7dc2f2590 \
57 gcc|gcc-396037926 \
58 blackbox|blackbox
59 busybox|busybox-1.22.0
60 bzip2|bzip2 \
61 civitweb|civitweb \
62 coreutils|coreutils-5.2.1 \
63 nacl-spawn|nacl-spawn-0.1 \
64 corelibs|corelibs-0.2 \
65 file|file-5.24 \
66 curl|curl-7.37.0 \
67 drod|drod \
68 emacs|emacs-24.3 \
69 findutils|findutils-4.4.2 \
70 fvwm|fvwm \
71 gawk|gawk \
72 gforth|gforth \
73 tree|tree-1.7.0 \
74 git|git-2.3.0 \
75 pcre|pcre-8.36 \
76 grep|grep-2.21 \
77 less|less-451 \
78 lua|lua-5.3 \
79 m4|m4 \
80 make|make-3.82 \
81 mingn|mingn-0.2 \
82 nano|nano-2.2.6 \
83 nethack|nethack \
84 ninja|ninja \
85 openssh|openssh \
86 python3|python3-3.4 \
87 python|python-2.7.7 \
88 ruby|ruby \
89 sqlite|sqlite \
90 subversion|subversion \
91 tar|tar \
92 texlive|texlive \
93 thttpd|thttpd \
94 tk|tk \
95 toybox|toybox \
96 twm|twm \
97 vim|vim-7.4 \
98 xeyes|xeyes \
99 xz|xz \
86 " 100 "
87 101
88 RemoveDir() {
89 local path="$1"
90 if [ -d ${path} ]; then
91 rm -rf ${path}/* || true
92 rm -rf ${path}
93 fi
94 }
95
96 # 102 #
97 # $1 - package name 103 # $1 - package name
98 # 104 #
99 InstallPackage() { 105 InstallPackage() {
100 local package="$1" 106 package=$1
101 local subdir="${PACKAGE_BY_ARCH}"
102 local source_base="${PACKAGE_SOURCE}"
103 107
104 # Replace package aliases with alternates. 108 # Replace package aliases with alternates.
105 for names in ${ALIASES}; do 109 for names in ${ALIASES}; do
106 local names_array=(${names//|/ }) 110 local names_array=(${names//|/ })
107 if [ "${package}" = "${names_array[0]}" ]; then 111 if [ "${package}" = "${names_array[0]}" ]; then
108 package="${names_array[1]}" 112 package="${names_array[1]}"
109 fi 113 fi
110 done 114 done
111 115 if [[ ${PACKAGE_FORCE} != 1 ]]; then
112 for info in ${PACKAGE_INFO}; do 116 if pkg info --quiet ${package}; then
113 local info_array=(${info//|/ }) 117 return
114 if [ "${package}" = "${info_array[0]}" ]; then
115 subdir="${info_array[2]}"
116 if [[ "${ALTERNATE_SOURCE}" == "0" && \
117 ${#info_array[@]} > 3 && \
118 "${info_array[3]}" != "" ]]; then
119 source_base="${info_array[3]}"
120 subdir="${info_array[4]}"
121 fi
122 fi 118 fi
123 done
124
125 local url=${source_base}/${package}/${subdir}
126 InstallPackageFromUrl ${package} ${url}
127 }
128
129 #
130 # $1 - package name
131 # $2 - zip file url
132 #
133 InstallPackageFromUrl() {
134 local package=$1
135 local url=$2
136 local package_dir=/packages/${package}.${NACL_ARCH}
137 local clobber=1
138
139 # Special case for MinGN.
140 if [[ "${package}" = "mingn.base" || "${package}" = "mingn.lib" ]]; then
141 url="${PACKAGE_SOURCE}/mingn/${subdir}"
142 package_dir="/"
143 clobber=0
144 fi
145 # Special case for coreutils.
146 if [[ "${package}" = "coreutils" ]]; then
147 package_dir="/coreutils.${NACL_ARCH}"
148 clobber=0
149 fi 119 fi
150 120
151 local stamp_dir=/stamps/${package}.${NACL_ARCH} 121 if ! pkg add ${PACKAGE_SOURCE}/${package}.tbz; then
152 local url_stamp="${stamp_dir}/${url//\//_}" 122 echo "pkg add failed: $?"
153
154 if [ -d ${package_dir}/${package} ]; then
155 local package_inside=${package_dir}/${package}
156 else
157 local package_inside=${package_dir}
158 fi
159
160 if [[ ${PACKAGE_FORCE} != 1 && -d ${url_stamp} ]]; then
161 # Package is up to date.
162 return
163 fi
164
165 if [ -d ${stamp_dir} ]; then
166 echo "Updating ${package} package..."
167 else
168 echo "Installing ${package} package..."
169 fi
170 local archive=/tmp/devenv.${package}.zip
171 echo "Downloading ${url}..."
172 if ! geturl ${url} ${archive}; then
173 echo "geturl failed"
174 exit 1 123 exit 1
175 fi 124 fi
176
177 echo "Extracting ${package}..."
178 if [ ! -e ${archive} ]; then
179 echo "${archive} does not exist!"
180 exit 1
181 fi
182 if [ "${clobber}" = 1 ]; then
183 RemoveDir ${package_dir}
184 fi
185 if [ ! -d ${package_dir%/*} ]; then
186 mkdir -p ${package_dir}
187 fi
188 local unzip_flags=
189 if [ ${VERBOSE} != "1" ]; then
190 unzip_flags=-q
191 fi
192 if ! unzip -o $unzip_flags -d ${package_dir} ${archive}; then
193 echo "error: unzip failed"
194 exit 1
195 fi
196 rm ${archive}
197
198 # Update package_inside.
199 if [ -d ${package_dir}/${package} ]; then
200 package_inside=${package_dir}/${package}
201 else
202 package_inside=${package_dir}
203 fi
204
205 # TODO(bradnelson): Do something better.
206 # Rename appropriate nexe/pexe to unsuffixed version.
207 local suffixes=".pexe _pnacl.pexe _${NACL_ARCH}.nexe .nexe"
208 local platform_dirs="_platform_specific/${NACL_ARCH}/ \
209 _platform_specific/all/"
210 if [ "${NACL_ARCH}" = "i686" ]; then
211 suffixes+=" _x86_32.nexe"
212 platform_dirs+=" _platform_specific/x86_32/"
213 fi
214 for alt in "" _ppapi; do
215 for plat in "" ${platform_dirs}; do
216 for suffix in ${suffixes}; do
217 local exe=${package_inside}/${plat}${package}${alt}${suffix}
218 if [ -e ${exe} ]; then
219 cp ${exe} ${package_inside}/${package}
220 fi
221 done
222 done
223 done
224
225 # Remove out stamps and write out new one.
226 RemoveDir ${stamp_dir}
227 mkdir -p ${url_stamp}
228 echo "Done."
229 } 125 }
230 126
231 function Usage() { 127 function Usage() {
232 echo "Usage: $0 [options]" 128 echo "Usage: $0 [options]"
233 echo " -i <package> = install package" 129 echo " -i <package> = install package"
234 echo " -s <source> = alternate package source" 130 echo " -s <source> = alternate package source"
235 echo " -L = local package source (use with make run in naclports)" 131 echo " -L = local package source (use with make run in naclports)"
236 echo " -f = force install" 132 echo " -f = force install"
237 echo " -l = list known packages" 133 echo " -l = list known packages"
238 echo " -h = help" 134 echo " -h = help"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 ALTERNATE_SOURCE=1 202 ALTERNATE_SOURCE=1
307 fi 203 fi
308 fi 204 fi
309 205
310 for package in ${PACKAGE_LIST}; do 206 for package in ${PACKAGE_LIST}; do
311 InstallPackage ${package} 207 InstallPackage ${package}
312 done 208 done
313 } 209 }
314 210
315 main "$@" 211 main "$@"
OLDNEW
« no previous file with comments | « ports/devenv/install-base-packages.sh ('k') | ports/devenv/setup-environment » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698