Commit c5e796b0 authored by thomasanderson's avatar thomasanderson Committed by Commit bot

Support relocatable RPM packages

BUG=31519

Review-Url: https://codereview.chromium.org/2107893004
Cr-Commit-Position: refs/heads/master@{#402666}
parent 6e5a7d11
@@include@@variables.include
APT_GET="`which apt-get 2> /dev/null`"
APT_CONFIG="`which apt-config 2> /dev/null`"
......
......@@ -11,8 +11,11 @@ PACKAGE="chromium-browser"
# Filename of the main executable (for generating launcher scripts, etc.)
PROGNAME=chrome
# Relocatable part of base directory for package installation.
INSTALLDIRPREFIX=/opt
# Base directory for package installation.
INSTALLDIR=/opt/chromium.org/chromium
INSTALLDIR="${INSTALLDIRPREFIX}"/chromium.org/chromium
# Display string for desktop menu/icon.
MENUNAME="Chromium Web Browser"
......
......@@ -11,8 +11,11 @@ PACKAGE="google-chrome"
# Filename of the main executable (for generating launcher scripts, etc.)
PROGNAME=chrome
# Relocatable part of base directory for package installation.
INSTALLDIRPREFIX=/opt
# Base directory for package installation.
INSTALLDIR=/opt/google/chrome
INSTALLDIR="${INSTALLDIRPREFIX}"/google/chrome
# Display string for desktop menu/icon.
MENUNAME="Google Chrome"
......
......@@ -58,6 +58,7 @@ process_template() (
-e "s#@@VERSION@@#${VERSION}#g" \
-e "s#@@PACKAGE_RELEASE@@#${PACKAGE_RELEASE}#g" \
-e "s#@@VERSIONFULL@@#${VERSIONFULL}#g" \
-e "s#@@INSTALLDIRPREFIX@@#${INSTALLDIRPREFIX}#g" \
-e "s#@@INSTALLDIR@@#${INSTALLDIR}#g" \
-e "s#@@BUILDDIR@@#${BUILDDIR}#g" \
-e "s#@@STAGEDIR@@#${STAGEDIR}#g" \
......@@ -225,8 +226,6 @@ stage_install_common() {
ln -sn "${INSTALLDIR}/${PACKAGE}" \
"${STAGEDIR}/${INSTALLDIR}/google-chrome"
fi
ln -snf "${INSTALLDIR}/${PACKAGE}" \
"${STAGEDIR}/usr/bin/${USR_BIN_SYMLINK_NAME}"
# app icons
install -m 644 \
......
......@@ -4,7 +4,7 @@ if [ ! -x "$XDG_ICON_RESOURCE" ]; then
echo "Error: Could not find xdg-icon-resource" >&2
exit 1
fi
for icon in "@@INSTALLDIR@@/product_logo_"*.png; do
for icon in "${INSTALLDIR}/product_logo_"*.png; do
size="${icon##*/product_logo_}"
"$XDG_ICON_RESOURCE" install --size "${size%.png}" "$icon" "@@PACKAGE@@"
done
......@@ -74,5 +74,5 @@ if [ -f "$GNOME_DFL_APPS" ]; then
fgrep -q "@@MENUNAME@@" "$GNOME_DFL_APPS" || insert_after_first_match \
"$GNOME_DFL_APPS" \
"^[ ]*<web-browsers>[ ]*$" \
"@@INSTALLDIR@@/default-app-block"
"${INSTALLDIR}/default-app-block"
fi
......@@ -4,7 +4,7 @@ if [ ! -x "$XDG_ICON_RESOURCE" ]; then
echo "Error: Could not find xdg-icon-resource" >&2
exit 1
fi
for icon in "@@INSTALLDIR@@/product_logo_"*.png; do
for icon in "${INSTALLDIR}/product_logo_"*.png; do
size="${icon##*/product_logo_}"
"$XDG_ICON_RESOURCE" uninstall --size "${size%.png}" "@@PACKAGE@@"
done
......
@@include@@variables.include
# Install the repository signing key (see also:
# https://www.google.com/linuxrepositories/)
install_rpm_key() {
......
......@@ -7,9 +7,9 @@ add_nss_symlinks() {
do
target=$(echo $f | sed 's/\.[01]d$//')
if [ -f "/$LIBDIR/$target" ]; then
ln -snf "/$LIBDIR/$target" "@@INSTALLDIR@@/$f"
ln -snf "/$LIBDIR/$target" "${INSTALLDIR}/$f"
elif [ -f "/usr/$LIBDIR/$target" ]; then
ln -snf "/usr/$LIBDIR/$target" "@@INSTALLDIR@@/$f"
ln -snf "/usr/$LIBDIR/$target" "${INSTALLDIR}/$f"
else
echo $f not found in "/$LIBDIR/$target" or "/usr/$LIBDIR/$target".
exit 1
......@@ -17,13 +17,21 @@ add_nss_symlinks() {
done
}
add_chrome_symlinks() {
ln -snf "${INSTALLDIR}/@@PACKAGE@@" "/usr/bin/@@USR_BIN_SYMLINK_NAME@@"
}
remove_nss_symlinks() {
for f in $NSS_FILES
do
rm -rf "@@INSTALLDIR@@/$f"
rm -rf "${INSTALLDIR}/$f"
done
}
remove_udev_symlinks() {
rm -rf "@@INSTALLDIR@@/libudev.so.0"
rm -rf "${INSTALLDIR}/libudev.so.0"
}
remove_chrome_symlinks() {
rm -rf "/usr/bin/@@USR_BIN_SYMLINK_NAME@@"
}
# Set the installation directory at install time.
# Currently only does anything for RPM packages.
INSTALLDIR="@@INSTALLDIR@@"
if [ -n "${RPM_INSTALL_PREFIX-}" ]; then
INSTALLDIR="${RPM_INSTALL_PREFIX}"/${INSTALLDIR##"@@INSTALLDIRPREFIX@@/"}
fi
# System-wide package configuration.
DEFAULTS_FILE="/etc/default/@@PACKAGE@@"
......
......@@ -6,8 +6,14 @@
set -e
@@include@@../common/variables.include
@@include@@../common/postinst.include
@@include@@../common/apt.include
@@include@@../common/symlinks.include
# Add to the alternatives system
#
# On Ubuntu 12.04, we have the following priorities
......@@ -44,6 +50,11 @@ case $CHANNEL in
;;
esac
remove_chrome_symlinks
add_chrome_symlinks
remove_udev_symlinks
update-alternatives --install /usr/bin/x-www-browser x-www-browser \
/usr/bin/@@USR_BIN_SYMLINK_NAME@@ $PRIORITY
update-alternatives --install /usr/bin/gnome-www-browser gnome-www-browser \
......@@ -52,12 +63,6 @@ update-alternatives --install /usr/bin/gnome-www-browser gnome-www-browser \
update-alternatives --install /usr/bin/google-chrome google-chrome \
/usr/bin/@@USR_BIN_SYMLINK_NAME@@ $PRIORITY
@@include@@../common/apt.include
@@include@@../common/symlinks.include
remove_udev_symlinks
## MAIN ##
if [ ! -e "$DEFAULTS_FILE" ]; then
echo 'repo_add_once="true"' > "$DEFAULTS_FILE"
......
......@@ -13,10 +13,13 @@ if [ "$action" != "purge" ] ; then
exit 0
fi
@@include@@../common/variables.include
@@include@@../common/apt.include
@@include@@../common/symlinks.include
remove_chrome_symlinks
remove_udev_symlinks
# Only remove the defaults file if it is not empty. An empty file was probably
......
......@@ -16,6 +16,8 @@ if [ "$action" = "upgrade" ] ; then
exit 0
fi
@@include@@../common/variables.include
@@include@@../common/prerm.include
# Remove from the alternatives system
......
......@@ -88,7 +88,6 @@ rm -rf "$RPM_BUILD_ROOT"
# accidentally "own" stuff that's not ours (crbug.com/123990).
/etc/cron.daily/@@PACKAGE@@
%ghost %attr(755,root,root) /usr/bin/google-chrome
/usr/bin/@@USR_BIN_SYMLINK_NAME@@
/usr/share/applications/@@PACKAGE@@.desktop
/usr/share/gnome-control-center/default-apps/@@PACKAGE@@.xml
%docdir /usr/share/man/man1
......@@ -109,6 +108,8 @@ exit 0
#------------------------------------------------------------------------------
%post
@@include@@../common/variables.include
@@include@@../common/postinst.include
@@include@@../common/rpm.include
......@@ -118,6 +119,9 @@ exit 0
remove_nss_symlinks
add_nss_symlinks
remove_chrome_symlinks
add_chrome_symlinks
remove_udev_symlinks
DEFAULTS_FILE="/etc/default/@@PACKAGE@@"
......@@ -188,6 +192,8 @@ elif [ "$1" -eq "1" ]; then
mode="upgrade"
fi
@@include@@../common/variables.include
@@include@@../common/rpm.include
@@include@@../common/symlinks.include
......@@ -196,11 +202,12 @@ fi
# old_pkg's %preun runs after new_pkg's %post.
if [ "$mode" = "uninstall" ]; then
@@include@@../common/prerm.include
remove_nss_symlinks
remove_udev_symlinks
%{_sbindir}/update-alternatives --remove google-chrome \
/usr/bin/@@USR_BIN_SYMLINK_NAME@@
remove_nss_symlinks
remove_chrome_symlinks
remove_udev_symlinks
fi
# On Debian we only remove when we purge. However, RPM has no equivalent to
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment