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