summaryrefslogtreecommitdiff
path: root/packages/google-compute-engine/packaging/google-compute-engine.spec
blob: 3f5fcb19bb12928b445a35bbf80c5556c5f27e1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Copyright 2018 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# For EL7, if building on CentOS, override dist to be el7.
%if 0%{?rhel} == 7
  %define dist .el7
%endif

Name: google-compute-engine
Epoch: 1
Version: %{_version}
Release: g2%{?dist}
Summary: Google Compute Engine guest environment.
License: ASL 2.0
Url: https://github.com/GoogleCloudPlatform/compute-image-packages
Source0: %{name}_%{version}.orig.tar.gz
Requires: curl
Requires: google-compute-engine-oslogin
%if 0%{?rhel} == 8
Requires: python3-google-compute-engine >= 1:20190916.00
%else
Requires: python-google-compute-engine >= 1:20190916.00
%endif
Requires: rsyslog

BuildArch: noarch
BuildRequires: systemd

# Allow other files in the source that don't end up in the package.
%define _unpackaged_files_terminate_build 0

%description
This package contains scripts, configuration, and init files for features
specific to the Google Compute Engine cloud environment.

%prep
%autosetup

%install
cp -a src/{etc,usr} %{buildroot}
install -d %{buildroot}/{%{_unitdir},%{_presetdir},%{_udevrulesdir}}
cp -a src/lib/systemd/system/* %{buildroot}/%{_unitdir}
cp -a src/lib/systemd/system-preset/* %{buildroot}/%{_presetdir}
cp -a src/lib/udev/rules.d/* %{buildroot}/%{_udevrulesdir}

%files
%defattr(0644,root,root,0755)
%attr(0755,-,-) %{_bindir}/*
%attr(0755,-,-) /etc/dhcp/dhclient.d/google_hostname.sh
%{_udevrulesdir}/*
%{_unitdir}/*
%{_presetdir}/*
%config /etc/modprobe.d/*
%config /etc/rsyslog.d/*
%config /etc/sysctl.d/*

%post
if [ $1 -eq 2 ]; then
  # New service might not be enabled during upgrade.
  systemctl enable google-network-daemon.service
fi

# On upgrade run instance setup again to handle any new configs and restart
# daemons.
if [ $1 -eq 2 ]; then
  /usr/bin/google_instance_setup
  systemctl reload-or-restart google-accounts-daemon.service
  systemctl reload-or-restart google-clock-skew-daemon.service
  systemctl reload-or-restart google-network-daemon.service
fi

%systemd_post google-accounts-daemon.service
%systemd_post google-clock-skew-daemon.service
%systemd_post google-instance-setup.service
%systemd_post google-network-daemon.service
%systemd_post google-shutdown-scripts.service
%systemd_post google-startup-scripts.service

# Remove old services.
if [ -f /lib/systemd/system/google-ip-forwarding-daemon.service ]; then
  systemctl stop --no-block google-ip-forwarding-daemon
  systemctl disable google-ip-forwarding-daemon.service
fi

if [ -f /lib/systemd/system/google-network-setup.service ]; then
  systemctl stop --no-block google-network-setup
  systemctl disable google-network-setup.service
fi

%preun
# On uninstall only.
if [ $1 -eq 0 ]; then
  %systemd_preun google-accounts-daemon.service
  %systemd_preun google-clock-skew-daemon.service
  %systemd_preun google-instance-setup.service
  %systemd_preun google-network-daemon.service
  %systemd_preun google-shutdown-scripts.service
  %systemd_preun google-startup-scripts.service
fi