Home | History | Annotate | Download | only in rpm
      1 #------------------------------------------------------------------------------
      2 #   chrome.spec
      3 #------------------------------------------------------------------------------
      4 
      5 #------------------------------------------------------------------------------
      6 #   Prologue information
      7 #------------------------------------------------------------------------------
      8 Summary         : @@MENUNAME@@
      9 License         : Multiple, see @@PRODUCTURL@@
     10 Name            : @@PACKAGE@@-@@CHANNEL@@
     11 Version         : @@VERSION@@
     12 Release         : @@PACKAGE_RELEASE@@
     13 Group           : Applications/Internet
     14 Vendor          : @@COMPANY_FULLNAME@@
     15 Url             : @@PRODUCTURL@@
     16 Packager        : @@MAINTNAME@@ <@@MAINTMAIL@@>
     17 
     18 Provides        : @@PROVIDES@@ = %{version}
     19 Requires        : @@DEPENDS@@
     20 Autoreqprov     : No
     21 Conflicts       : @@REPLACES@@
     22 
     23 BuildRoot       : %{_tmppath}/%{name}-%{version}-root
     24 
     25 # The prefix is pretty important; RPM uses this to figure out
     26 # how to make a package relocatable
     27 prefix          : /opt
     28 
     29 #------------------------------------------------------------------------------
     30 #   Description
     31 #------------------------------------------------------------------------------
     32 %Description
     33 @@SHORTDESC@@
     34 
     35 @@FULLDESC@@
     36 
     37 #------------------------------------------------------------------------------
     38 #   Build rule - How to make the package
     39 #------------------------------------------------------------------------------
     40 %build
     41 
     42 #------------------------------------------------------------------------------
     43 #       Installation rule - how to install it (note that it
     44 #   gets installed into a temp directory given by $RPM_BUILD_ROOT)
     45 #------------------------------------------------------------------------------
     46 %install
     47 rm -rf "$RPM_BUILD_ROOT"
     48 
     49 if [ -z "@@STAGEDIR@@" -o ! -d "@@STAGEDIR@@" ] ; then
     50     echo "@@STAGEDIR@@ appears to be incorrectly set - aborting"
     51     exit 1
     52 fi
     53 
     54 if [ -z "@@INSTALLDIR@@" -o ! -d "@@STAGEDIR@@/@@INSTALLDIR@@" ] ; then
     55     echo "@@INSTALLDIR@@ appears to be incorrectly set - aborting"
     56     exit 1
     57 fi
     58 
     59 install -m 755 -d \
     60   "$RPM_BUILD_ROOT/etc" \
     61   "$RPM_BUILD_ROOT/opt" \
     62   "$RPM_BUILD_ROOT/usr"
     63 # This is hard coded for now
     64 cp -a "@@STAGEDIR@@/etc/" "$RPM_BUILD_ROOT/"
     65 cp -a "@@STAGEDIR@@/opt/" "$RPM_BUILD_ROOT/"
     66 cp -a "@@STAGEDIR@@/usr/" "$RPM_BUILD_ROOT/"
     67 
     68 #------------------------------------------------------------------------------
     69 #   Rule to clean up a build
     70 #------------------------------------------------------------------------------
     71 %clean
     72 rm -rf "$RPM_BUILD_ROOT"
     73 
     74 #------------------------------------------------------------------------------
     75 #   Files listing.
     76 #------------------------------------------------------------------------------
     77 %files
     78 %defattr(-,root,root)
     79 #%doc README
     80 
     81 # We cheat and just let RPM figure it out for us; everything we install
     82 # should go under this prefix anyways.
     83 @@INSTALLDIR@@
     84 
     85 # Be explicit about the files we scatter throughout the system we don't
     86 # accidentally "own" stuff that's not ours (crbug.com/123990).
     87 /etc/cron.daily/@@PACKAGE_FILENAME@@
     88 /usr/bin/@@PACKAGE_FILENAME@@
     89 /usr/share/gnome-control-center/default-apps/@@PACKAGE_FILENAME@@.xml
     90 %docdir /usr/share/man/man1
     91 /usr/share/man/man1/@@PACKAGE_FILENAME@@.1
     92 
     93 #------------------------------------------------------------------------------
     94 #   Pre install script
     95 #------------------------------------------------------------------------------
     96 %pre
     97 
     98 exit 0
     99 
    100 
    101 
    102 
    103 #------------------------------------------------------------------------------
    104 #   Post install script
    105 #------------------------------------------------------------------------------
    106 %post
    107 
    108 @@include@@../common/postinst.include
    109 
    110 @@include@@../common/rpm.include
    111 
    112 @@include@@../common/symlinks.include
    113 
    114 remove_nss_symlinks
    115 add_nss_symlinks
    116 
    117 remove_udev_symlinks
    118 add_udev_symlinks
    119 
    120 DEFAULTS_FILE="/etc/default/@@PACKAGE@@"
    121 if [ ! -e "$DEFAULTS_FILE" ]; then
    122   echo 'repo_add_once="true"' > "$DEFAULTS_FILE"
    123 fi
    124 
    125 . "$DEFAULTS_FILE"
    126 
    127 if [ "$repo_add_once" = "true" ]; then
    128   determine_rpm_package_manager
    129 
    130   case $PACKAGEMANAGER in
    131   "yum")
    132     install_yum
    133     ;;
    134   "urpmi")
    135     install_urpmi
    136     ;;
    137   "yast")
    138     install_yast
    139     ;;
    140   esac
    141 fi
    142 
    143 # Some package managers have locks that prevent everything from being
    144 # configured at install time, so wait a bit then kick the cron job to do
    145 # whatever is left. Probably the db will be unlocked by then, but if not, the
    146 # cron job will keep retrying.
    147 # Do this with 'at' instead of a backgrounded shell because zypper waits on all
    148 # sub-shells to finish before it finishes, which is exactly the opposite of
    149 # what we want here. Also preemptively start atd because for some reason it's
    150 # not always running, which kind of defeats the purpose of having 'at' as a
    151 # required LSB command.
    152 service atd start
    153 echo "sh /etc/cron.daily/@@PACKAGE@@" | at now + 2 minute > /dev/null 2>&1
    154 exit 0
    155 
    156 
    157 #------------------------------------------------------------------------------
    158 #   Pre uninstallation script
    159 #------------------------------------------------------------------------------
    160 %preun
    161 
    162 if [ "$1" -eq "0" ]; then
    163   mode="uninstall"
    164 elif [ "$1" -eq "1" ]; then
    165   mode="upgrade"
    166 fi
    167 
    168 @@include@@../common/rpm.include
    169 
    170 @@include@@../common/symlinks.include
    171 
    172 # Only remove menu items and symlinks on uninstall. When upgrading,
    173 # old_pkg's %preun runs after new_pkg's %post.
    174 if [ "$mode" = "uninstall" ]; then
    175 @@include@@../common/prerm.include
    176   remove_nss_symlinks
    177   remove_udev_symlinks
    178 fi
    179 
    180 # On Debian we only remove when we purge. However, RPM has no equivalent to
    181 # dpkg --purge, so this is all disabled.
    182 #
    183 #determine_rpm_package_manager
    184 #
    185 #case $PACKAGEMANAGER in
    186 #"yum")
    187 #  remove_yum
    188 #  ;;
    189 #"urpmi")
    190 #  remove_urpmi
    191 #  ;;
    192 #"yast")
    193 #  remove_yast
    194 #  ;;
    195 #esac
    196 
    197 exit 0
    198 
    199 #------------------------------------------------------------------------------
    200 #   Post uninstallation script
    201 #------------------------------------------------------------------------------
    202 %postun
    203 
    204 exit 0
    205