1 # Recursively replace @@include@@ template variables with the referenced file,
2 # and write the resulting text to stdout.
3 process_template_includes() {
5 # Includes are relative to the file that does the include.
7 # Clear IFS so 'read' doesn't trim whitespace
12 INCLINE=$(sed -e '/^[[:space:]]*@@include@@/!d' <<<$LINE)
13 if [ -n "$INCLINE" ]; then
14 INCFILE=$(echo $INCLINE | sed -e "s#@@include@@\(.*\)#\1#")
15 # Simple filename match to detect cyclic includes.
16 CYCLE=$(sed -e "\#$INCFILE#"'!d' <<<$INCSTACK)
18 echo "ERROR: Possible cyclic include detected." 1>&2
19 echo "$INCSTACK$INCFILE" 1>&2
22 if [ ! -r "$INCDIR/$INCFILE" ]; then
23 echo "ERROR: Couldn't read include file: $INCDIR/$INCFILE" 1>&2
26 process_template_includes "$INCDIR/$INCFILE"
32 INCSTACK=${INCSTACK%"$1->"}
35 # Replace template variables (@@VARNAME@@) in the given template file. If a
36 # second argument is given, save the processed text to that filename, otherwise
37 # modify the template file in place.
39 # Don't worry if some of these substitution variables aren't set.
40 # Note that this function is run in a sub-shell so we don't leak this
41 # setting, since we still want unbound variables to be an error elsewhere.
46 local TMPLOUT="$TMPLIN"
50 # Process includes first so included text also gets substitutions.
51 TMPLINCL="$(process_template_includes "$TMPLIN")"
53 -e "s#@@PACKAGE@@#${PACKAGE}#g" \
54 -e "s#@@PACKAGE_FILENAME@@#${PACKAGE_FILENAME}#g" \
55 -e "s#@@PROGNAME@@#${PROGNAME}#g" \
56 -e "s#@@CHANNEL@@#${CHANNEL}#g" \
57 -e "s#@@COMPANY_FULLNAME@@#${COMPANY_FULLNAME}#g" \
58 -e "s#@@VERSION@@#${VERSION}#g" \
59 -e "s#@@PACKAGE_RELEASE@@#${PACKAGE_RELEASE}#g" \
60 -e "s#@@VERSIONFULL@@#${VERSIONFULL}#g" \
61 -e "s#@@INSTALLDIR@@#${INSTALLDIR}#g" \
62 -e "s#@@BUILDDIR@@#${BUILDDIR}#g" \
63 -e "s#@@STAGEDIR@@#${STAGEDIR}#g" \
64 -e "s#@@SCRIPTDIR@@#${SCRIPTDIR}#g" \
65 -e "s#@@MENUNAME@@#${MENUNAME}#g" \
66 -e "s#@@PRODUCTURL@@#${PRODUCTURL}#g" \
67 -e "s#@@PREDEPENDS@@#${PREDEPENDS}#g" \
68 -e "s#@@DEPENDS@@#${DEPENDS}#g" \
69 -e "s#@@PROVIDES@@#${PROVIDES}#g" \
70 -e "s#@@REPLACES@@#${REPLACES}#g" \
71 -e "s#@@CONFLICTS@@#${CONFLICTS}#g" \
72 -e "s#@@ARCHITECTURE@@#${ARCHITECTURE}#g" \
73 -e "s#@@MAINTNAME@@#${MAINTNAME}#g" \
74 -e "s#@@MAINTMAIL@@#${MAINTMAIL}#g" \
75 -e "s#@@REPOCONFIG@@#${REPOCONFIG}#g" \
76 -e "s#@@SSLREPOCONFIG@@#${SSLREPOCONFIG}#g" \
77 -e "s#@@SHORTDESC@@#${SHORTDESC}#g" \
78 -e "s#@@FULLDESC@@#${FULLDESC}#g" \
79 -e "s#@@DEFAULT_FLAGS@@#${DEFAULT_FLAGS:-}#g" \
80 -e "s#@@SXS_USER_DATA_DIR@@#${SXS_USER_DATA_DIR:-}#g" \
81 -e "s#@@USR_BIN_SYMLINK_NAME@@#${USR_BIN_SYMLINK_NAME:-}#g" \
82 > "$TMPLOUT" <<< "$TMPLINCL"
85 # Setup the installation directory hierachy in the package staging area.
86 prep_staging_common() {
87 install -m 755 -d "${STAGEDIR}/${INSTALLDIR}" \
88 "${STAGEDIR}/usr/bin" \
89 "${STAGEDIR}/usr/share/applications" \
90 "${STAGEDIR}/usr/share/gnome-control-center/default-apps" \
91 "${STAGEDIR}/usr/share/man/man1"
95 source "${BUILDDIR}/installer/version.txt"
96 VERSION="${MAJOR}.${MINOR}.${BUILD}.${PATCH}"
97 # TODO(phajdan.jr): Provide a mechanism to pass a different package
98 # release number if needed. The meaning of it is to bump it for
99 # packaging-only changes while the underlying software has the same version.
100 # This corresponds to the Release field in RPM spec files and debian_revision
101 # component of the Version field for DEB control file.
102 # Generally with Chrome's fast release cycle it'd be more hassle to try
103 # to bump this number between releases.
107 stage_install_common() {
108 echo "Staging common install files in '${STAGEDIR}'..."
110 # TODO(mmoss) This assumes we built the static binaries. To support shared
111 # builds, we probably want an install target in scons so it can give us all
112 # the right files. See also:
113 # http://code.google.com/p/chromium/issues/detail?id=4451
116 # We need to add the debug link so gdb knows to look for the symbols.
117 DEBUGFILE="${BUILDDIR}/${PROGNAME}.debug"
118 STRIPPEDFILE="${BUILDDIR}/${PROGNAME}.stripped"
119 "${BUILDDIR}/installer/common/eu-strip" -o "${STRIPPEDFILE}" -f "${DEBUGFILE}" "${BUILDDIR}/${PROGNAME}"
120 install -m 755 "${STRIPPEDFILE}" "${STAGEDIR}/${INSTALLDIR}/${PROGNAME}"
121 rm "${DEBUGFILE}" "${STRIPPEDFILE}"
124 install -m 644 "${BUILDDIR}/resources.pak" "${STAGEDIR}/${INSTALLDIR}/"
125 # TODO(mmoss): This has broken a couple times on adding new .pak files. Maybe
126 # we should flag all installer files in FILES.cfg and get them from there, so
127 # there's only one place people need to keep track of such things (and in
128 # only the public repository).
129 if [ -r "${BUILDDIR}/chrome_100_percent.pak" ]; then
130 install -m 644 "${BUILDDIR}/chrome_100_percent.pak" "${STAGEDIR}/${INSTALLDIR}/"
131 install -m 644 "${BUILDDIR}/chrome_200_percent.pak" "${STAGEDIR}/${INSTALLDIR}/"
133 install -m 644 "${BUILDDIR}/theme_resources_100_percent.pak" "${STAGEDIR}/${INSTALLDIR}/"
134 install -m 644 "${BUILDDIR}/ui_resources_100_percent.pak" "${STAGEDIR}/${INSTALLDIR}/"
137 # ICU data file; only necessary when icu_use_data_file_flag is set to 1
138 # in build/common.gypi.
139 install -m 644 "${BUILDDIR}/icudtl.dat" "${STAGEDIR}/${INSTALLDIR}/"
141 # V8 snapshot files; only necessary when v8_use_external_startup_data is
142 # set to 1 in build/common.gypi.
143 if [ -f "${BUILDDIR}/natives_blob.bin" ]; then
144 install -m 644 "${BUILDDIR}/natives_blob.bin" "${STAGEDIR}/${INSTALLDIR}/"
145 install -m 644 "${BUILDDIR}/snapshot_blob.bin" "${STAGEDIR}/${INSTALLDIR}/"
149 # Rename sandbox binary with hyphen instead of underscore because that's what
150 # the code looks for, but the build targets can't use hyphens (scons bug?)
151 install -m 4755 -s "${BUILDDIR}/${PROGNAME}_sandbox" \
152 "${STAGEDIR}/${INSTALLDIR}/${PROGNAME}-sandbox"
155 cp -a "${BUILDDIR}/locales" "${STAGEDIR}/${INSTALLDIR}/"
156 find "${STAGEDIR}/${INSTALLDIR}/locales" -type f -exec chmod 644 '{}' \;
157 find "${STAGEDIR}/${INSTALLDIR}/locales" -type d -exec chmod 755 '{}' \;
160 install -m 644 -s "${BUILDDIR}/libffmpegsumo.so" "${STAGEDIR}/${INSTALLDIR}/"
163 if [ -f "${BUILDDIR}/libwidevinecdmadapter.so" ]; then
164 install -m 644 -s "${BUILDDIR}/libwidevinecdmadapter.so" "${STAGEDIR}/${INSTALLDIR}/"
165 install -m 644 "${BUILDDIR}/libwidevinecdm.so" "${STAGEDIR}/${INSTALLDIR}/"
169 PEPPERFLASH_SRCDIR="${BUILDDIR}/PepperFlash"
170 PEPPERFLASH_DESTDIR="${STAGEDIR}/${INSTALLDIR}/PepperFlash"
171 install -m 755 -d "${PEPPERFLASH_DESTDIR}"
172 install -m 644 -s "${PEPPERFLASH_SRCDIR}/libpepflashplayer.so" \
173 "${PEPPERFLASH_DESTDIR}/"
174 install -m 644 "${PEPPERFLASH_SRCDIR}/manifest.json" \
175 "${PEPPERFLASH_DESTDIR}/"
177 # peerconnection shared library
178 if [ -f "${BUILDDIR}/lib/libpeerconnection.so" ]; then
179 install -m 755 -d "${STAGEDIR}/${INSTALLDIR}/lib/"
181 install -m 644 -s "${BUILDDIR}/lib/libpeerconnection.so" "${STAGEDIR}/${INSTALLDIR}/lib/"
185 if [ -f "${BUILDDIR}/lib/libc++.so" ]; then
186 install -m 755 -d "${STAGEDIR}/${INSTALLDIR}/lib/"
188 install -m 644 -s "${BUILDDIR}/lib/libc++.so" "${STAGEDIR}/${INSTALLDIR}/lib/"
192 # nacl_helper and nacl_helper_bootstrap
193 # Don't use "-s" (strip) because this runs binutils "strip", which
194 # mangles the special ELF program headers of nacl_helper_bootstrap.
195 # Explicitly use eu-strip instead, because it doesn't have that problem.
196 for file in nacl_helper nacl_helper_bootstrap; do
197 buildfile="${BUILDDIR}/${file}"
198 if [ -f "${buildfile}" ]; then
199 strippedfile="${buildfile}.stripped"
200 debugfile="${buildfile}.debug"
201 "${BUILDDIR}/installer/common/eu-strip" -o "${strippedfile}" -f "${debugfile}" "${buildfile}"
202 install -m 755 "${strippedfile}" "${STAGEDIR}/${INSTALLDIR}/${file}"
205 # Don't use "-s" (strip) because this would use the Linux toolchain to
206 # strip the NaCl binary, which has the potential to break it. It
207 # certainly resets the OSABI and ABIVERSION fields to non-NaCl values,
208 # although the NaCl IRT loader doesn't care about these fields. In any
209 # case, the IRT binaries are already stripped by NaCl's build process.
210 for filename in ${BUILDDIR}/nacl_irt_*.nexe; do
211 # Re-check the filename in case globbing matched nothing.
212 if [ -f "$filename" ]; then
213 install -m 644 "$filename" "${STAGEDIR}/${INSTALLDIR}/`basename "$filename"`"
218 if [ -d "${BUILDDIR}/default_apps" ]; then
219 cp -a "${BUILDDIR}/default_apps" "${STAGEDIR}/${INSTALLDIR}/"
220 find "${STAGEDIR}/${INSTALLDIR}/default_apps" -type d -exec chmod 755 '{}' \;
221 find "${STAGEDIR}/${INSTALLDIR}/default_apps" -type f -exec chmod 644 '{}' \;
224 # launcher script and symlink
225 process_template "${BUILDDIR}/installer/common/wrapper" \
226 "${STAGEDIR}/${INSTALLDIR}/${PACKAGE}"
227 chmod 755 "${STAGEDIR}/${INSTALLDIR}/${PACKAGE}"
228 if [ ! -f "${STAGEDIR}/${INSTALLDIR}/google-chrome" ]; then
229 ln -sn "${INSTALLDIR}/${PACKAGE}" \
230 "${STAGEDIR}/${INSTALLDIR}/google-chrome"
232 ln -snf "${INSTALLDIR}/${PACKAGE}" \
233 "${STAGEDIR}/usr/bin/${USR_BIN_SYMLINK_NAME}"
237 "${BUILDDIR}/installer/theme/product_logo_"*.png \
238 "${BUILDDIR}/installer/theme/product_logo_32.xpm" \
239 "${STAGEDIR}/${INSTALLDIR}/"
241 # desktop integration
242 install -m 755 "${BUILDDIR}/xdg-mime" "${STAGEDIR}${INSTALLDIR}/"
243 install -m 755 "${BUILDDIR}/xdg-settings" "${STAGEDIR}${INSTALLDIR}/"
244 process_template "${BUILDDIR}/installer/common/desktop.template" \
245 "${STAGEDIR}/usr/share/applications/${PACKAGE}.desktop"
246 chmod 644 "${STAGEDIR}/usr/share/applications/${PACKAGE}.desktop"
247 process_template "${BUILDDIR}/installer/common/default-app.template" \
248 "${STAGEDIR}/usr/share/gnome-control-center/default-apps/${PACKAGE}.xml"
249 chmod 644 "${STAGEDIR}/usr/share/gnome-control-center/default-apps/${PACKAGE}.xml"
250 process_template "${BUILDDIR}/installer/common/default-app-block.template" \
251 "${STAGEDIR}${INSTALLDIR}/default-app-block"
252 chmod 644 "${STAGEDIR}${INSTALLDIR}/default-app-block"
255 install -m 755 "${BUILDDIR}/${PROGNAME}.1" \
256 "${STAGEDIR}/usr/share/man/man1/${PACKAGE}.1"