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