Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPMbuild Support #613

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a844b62
rpmbuild support for base & user.
syslogic Jul 11, 2024
65c41df
rpmbuild support for base & user.
syslogic Jul 11, 2024
5be7c29
rpmbuild support for integration & orchestration.
syslogic Jul 11, 2024
4ae6f82
rpmbuild support for integration & orchestration.
syslogic Jul 11, 2024
4998344
file cuttlefish-host-resources added.
syslogic Jul 11, 2024
ba8b52f
%post macro added.
syslogic Jul 11, 2024
ed08c6d
*.rpm ignored.
syslogic Jul 11, 2024
471937d
npm audit fix
syslogic Jul 11, 2024
d14d1ec
dependencies updated.
syslogic Jul 11, 2024
f4e58bb
group cvdnetwork being added.
syslogic Jul 11, 2024
5f07d21
missing files added; some fixes.
syslogic Jul 11, 2024
d6f3bae
dependencies updated.
syslogic Jul 11, 2024
af59d1c
building for x85_64.
syslogic Jul 11, 2024
21cae7f
building for x85_64.
syslogic Jul 11, 2024
5f456ce
%post install script improved.
syslogic Jul 12, 2024
6a9c2b8
package names adjusted.
syslogic Jul 12, 2024
ea29436
dependencies updated.
syslogic Jul 16, 2024
9182d89
package scripts added.
syslogic Jul 16, 2024
e5ba904
package scripts added.
syslogic Jul 16, 2024
ddbabb6
package scripts added.
syslogic Jul 16, 2024
ab91abc
default init-script info header added.
syslogic Jul 16, 2024
ebeb624
package scripts added.
syslogic Jul 16, 2024
dcaf16f
package scripts added.
syslogic Jul 16, 2024
6ff8942
npm audit fix (reverted from commit 471937df9f51d2b7ee44195295f1d6199…
syslogic Jul 16, 2024
f090410
package scripts added.
syslogic Jul 17, 2024
4484903
package scripts added.
syslogic Jul 17, 2024
8871e57
restored "set -e -x".
syslogic Jul 17, 2024
d46d58d
restored "set -e -x" (now split).
syslogic Jul 17, 2024
afb5ab2
dependencies updated.
syslogic Jul 17, 2024
4238336
restored "set -e -x"; APT/DNF check replaced.
syslogic Jul 17, 2024
a309274
rpmbuild directory structure added.
syslogic Jul 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion base/debian/cuttlefish-base.cuttlefish-host-resources.init
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
# Make sure calls to this script get redirected to systemctl when
# using systemd

### BEGIN INIT INFO
# Provides: cuttlefish-host-resources
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO

# some system may not support bridge type by default
modprobe bridge

Expand Down Expand Up @@ -353,7 +363,12 @@ case "$1" in
# Nothing to do; we reread configuration on each invocation
;;
status)
rh_status
# command `rh_status` may not be available.
if command -v rh_status > /dev/null ; then
rh_status
else
systemctl status cuttlefish.service
fi
;;
shutdown)
stop
Expand Down
15 changes: 15 additions & 0 deletions base/rhel/cuttlefish.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Cuttlefish Host Resources
After=syslog.target network.target
Requires=libvirtd.service
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/etc/rc.d/init.d/cuttlefish-host-resources start

[Install]
WantedBy=multi-user.target

30 changes: 24 additions & 6 deletions tools/buildutils/build_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -e -x
syslogic marked this conversation as resolved.
Show resolved Hide resolved

REPO_DIR="$(realpath "$(dirname "$0")/../..")"

function install_debuild_dependencies() {
echo "Installing debuild dependencies"
sudo apt-get update
Expand All @@ -22,11 +24,27 @@ function build_package() {
popd
}

REPO_DIR="$(realpath "$(dirname "$0")/../..")"
INSTALL_BAZEL="$(dirname $0)/installbazel.sh"
function build_spec() {
local specfile="${REPO_DIR}/tools/rpmbuild/SPECS/$1"
echo "Installing package dependencies"
sudo dnf builddep --skip-unavailable $specfile
echo "Building packages"
rpmbuild --define "_topdir `pwd`/tools/rpmbuild" -v -ba $specfile
}

sudo "${INSTALL_BAZEL}"
install_debuild_dependencies
if [[ -f /bin/dnf ]]; then
build_spec cuttlefish_base.spec
build_spec cuttlefish_user.spec
build_spec cuttlefish_integration.spec
build_spec cuttlefish_orchestration.spec
exit 0
else
INSTALL_BAZEL="$(dirname $0)/installbazel.sh"
sudo "${INSTALL_BAZEL}"
install_debuild_dependencies
build_package "${REPO_DIR}/base"
build_package "${REPO_DIR}/frontend"
exit 0
fi
exit 1

build_package "${REPO_DIR}/base"
build_package "${REPO_DIR}/frontend"
1 change: 1 addition & 0 deletions tools/rpmbuild/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.rpm
Empty file added tools/rpmbuild/BUILD/.gitkeep
Empty file.
Empty file.
Empty file added tools/rpmbuild/RPMS/.gitkeep
Empty file.
114 changes: 114 additions & 0 deletions tools/rpmbuild/SPECS/cuttlefish_base.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
Name: cuttlefish-base
Version: 0.9.29
Release: 1%{?dist}
Summary: Cuttlefish Android Virtual Device

License: Apache License 2.0
URL: https://github.com/google/android-cuttlefish

BuildArch: x86_64
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: curl-devel, openssl-devel, protobuf-devel, protobuf-compiler

Requires: shadow-utils, redhat-lsb-core, ebtables-legacy, iproute
Requires: iptables-legacy, bridge-utils, dnsmasq, libfdt, e2fsprogs, ebtables, iptables, bsdtar
Requires: libcurl, libdrm, mesa-libGL, libusb, libXext, net-tools, openssl, python3, util-linux
Requires: curl >= 7.63.0, glibc >= 2.34, libgcc >= 3.0, libstdc++ >= 11
Requires: fmt-devel, gflags-devel, jsoncpp-devel, protobuf-devel, openssl-devel, libxml2-devel
#Requires: f2fs-tools, libx11-6, libz3-4
# libwayland-client0, libwayland-server0
Requires: wayland-utils


%description
Cuttlefish Android Virtual Device
Contains set of tools and binaries required to boot up and manage
Cuttlefish Android Virtual Device that are used in all deployments.

%prep
%define workdir `pwd`


%build
cd ../../../base/cvd
bazel build cuttlefish:cvd --spawn_strategy=local


%install
rm -rf $RPM_BUILD_ROOT
mkdir -p %{buildroot}/usr/bin
mkdir -p %{buildroot}/usr/lib/cuttlefish-common/bin
mkdir -p %{buildroot}/etc/default
mkdir -p %{buildroot}/etc/rc.d/init.d
mkdir -p %{buildroot}/etc/NetworkManager/conf.d
mkdir -p %{buildroot}/etc/modules-load.d
mkdir -p %{buildroot}/etc/security/limits.d
mkdir -p %{buildroot}/lib/systemd/system
mkdir -p %{buildroot}/lib/udev/rules.d/

%define srcpath ../../../base/host/packages/cuttlefish-base
install -m 655 %{srcpath}/etc/NetworkManager/conf.d/99-cuttlefish.conf %{buildroot}/etc/NetworkManager/conf.d/99-cuttlefish.conf
install -m 655 %{srcpath}/etc/modules-load.d/cuttlefish-common.conf %{buildroot}/etc/modules-load.d/cuttlefish-common.conf
install -m 655 %{srcpath}/etc/security/limits.d/1_cuttlefish.conf %{buildroot}/etc/security/limits.d/1_cuttlefish.conf

%define srcpath ../../../base/debian
install -m 655 %{srcpath}/cuttlefish-base.cuttlefish-host-resources.default %{buildroot}/etc/default/cuttlefish-host-resources
install -m 655 %{srcpath}/cuttlefish-base.cuttlefish-host-resources.init %{buildroot}/etc/rc.d/init.d/cuttlefish-host-resources

%define srcpath ../../../base/rhel
install -m 655 %{srcpath}/cuttlefish.service %{buildroot}/lib/systemd/system/cuttlefish.service

%define srcpath ../../../base/cvd/bazel-bin
install -m 755 %{srcpath}/cuttlefish/cvd %{buildroot}/usr/lib/cuttlefish-common/bin/cvd

%define srcpath ../../../base/host/deploy
install -m 655 %{srcpath}/install_zip.sh %{buildroot}/usr/bin/install_zip.sh
install -m 655 %{srcpath}/unpack_boot_image.py %{buildroot}/usr/lib/cuttlefish-common/bin/unpack_boot_image.py
install -m 655 %{srcpath}/capability_query.py %{buildroot}/usr/lib/cuttlefish-common/bin/capability_query.py

%define srcpath ../../../base/debian
install -m 655 %{srcpath}/cuttlefish-integration.udev %{buildroot}/lib/udev/rules.d/60-cuttlefish-integration.rules

%post
ln -sf /usr/lib/cuttlefish-common/bin/cvd /usr/bin/cvd
getent group cvdnetwork > /dev/null 2>&1 || groupadd --system cvdnetwork
udevadm control --reload-rules && udevadm trigger
systemctl restart NetworkManager
systemctl daemon-reload
systemctl start cuttlefish

%preun
systemctl stop cuttlefish
rm /usr/bin/cvd


%postun
udevadm control --reload-rules && udevadm trigger
systemctl restart NetworkManager
systemctl daemon-reload
if getent group cvdnetwork > /dev/null 2>&1 ; then
groupdel cvdnetwork
fi


%files
/etc/default/cuttlefish-host-resources
/etc/rc.d/init.d/cuttlefish-host-resources
/etc/NetworkManager/conf.d/99-cuttlefish.conf
/etc/modules-load.d/cuttlefish-common.conf
/etc/security/limits.d/1_cuttlefish.conf
/usr/bin/install_zip.sh
/lib/systemd/system/cuttlefish.service
/usr/lib/cuttlefish-common/bin/cvd
/usr/lib/cuttlefish-common/bin/unpack_boot_image.py
/usr/lib/cuttlefish-common/bin/capability_query.py
/lib/udev/rules.d/60-cuttlefish-integration.rules

#%%license add-license-file-here
#%%doc add-docs-here


%changelog
* Thu Jul 11 2024 Martin Zeitler <?>
- Initial version.

67 changes: 67 additions & 0 deletions tools/rpmbuild/SPECS/cuttlefish_integration.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Name: cuttlefish-integration
Version: 0.9.29
Release: 1%{?dist}
Summary: Contains the host signaling server supporting multi-device flows over WebRTC.

License: Apache License 2.0
URL: https://github.com/google/android-cuttlefish

BuildArch: x86_64
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

#BuildRequires:
Requires: qemu-kvm, cuttlefish-base

%description
Cuttlefish Android Virtual Device companion package
Contains the host signaling server supporting multi-device flows over WebRTC.

%prep


%build


%install
rm -rf $RPM_BUILD_ROOT
mkdir -p %{buildroot}/etc/default
mkdir -p %{buildroot}/etc/modprobe.d
mkdir -p %{buildroot}/etc/rsyslog.d
mkdir -p %{buildroot}/etc/ssh
mkdir -p %{buildroot}/lib/udev/rules.d

%define srcpath ../../../base/host/packages/cuttlefish-integration
install -m 655 %{srcpath}/etc/default/instance_configs.cfg.template %{buildroot}/etc/default/instance_configs.cfg.template
install -m 655 %{srcpath}/etc/modprobe.d/cuttlefish-integration.conf %{buildroot}/etc/modprobe.d/cuttlefish-integration.conf
install -m 655 %{srcpath}/etc/rsyslog.d/91-cuttlefish.conf %{buildroot}/etc/rsyslog.d/91-cuttlefish.conf
install -m 655 %{srcpath}/etc/ssh/sshd_config.cuttlefish %{buildroot}/etc/ssh/sshd_config.cuttlefish

%define srcpath ../../../base/debian
install -m 655 %{srcpath}/cuttlefish-integration.udev %{buildroot}/lib/udev/rules.d/60-cuttlefish-integration.rules


%files
/etc/default/instance_configs.cfg.template
/etc/modprobe.d/cuttlefish-integration.conf
/etc/rsyslog.d/91-cuttlefish.conf
/etc/ssh/sshd_config.cuttlefish
/lib/udev/rules.d/60-cuttlefish-integration.rules

#%%license add-license-file-here
#%%doc add-docs-here

%post
systemctl restart systemd-modules-load.service
systemctl reload rsyslog.service

%preun


%postun
systemctl restart systemd-modules-load.service
systemctl reload rsyslog.service

%changelog
* Thu Jul 11 2024 Martin Zeitler <?>
- Initial version.

88 changes: 88 additions & 0 deletions tools/rpmbuild/SPECS/cuttlefish_orchestration.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
Name: cuttlefish-orchestration
Version: 0.9.29
Release: 1%{?dist}
Summary: Contains the host orchestrator.

License: Apache License 2.0
URL: https://github.com/google/android-cuttlefish

BuildArch: x86_64
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires: openssl
Requires: cuttlefish-base, cuttlefish-user, shadow-utils, bash, openssl, nginx, systemd-journal-remote

%description
Cuttlefish Android Virtual Device companion package
Contains the host orchestrator.

%prep


%build
cd ../../../frontend
if [ ! -d .sslcert ]; then
./gen_ssl_cert.sh -o .sslcert
fi



%install
rm -rf $RPM_BUILD_ROOT
mkdir -p %{buildroot}/etc/cuttlefish-orchestration/ssl/cert
mkdir -p %{buildroot}/etc/default
mkdir -p %{buildroot}/etc/nginx/conf.d
mkdir -p %{buildroot}/etc/rc.d/init.d
mkdir -p %{buildroot}/etc/sudoers.d

%define srcpath ../../../frontend/.sslcert
install -m 655 %{srcpath}/cert.pem %{buildroot}/etc/cuttlefish-orchestration/ssl/cert/cert.pem
install -m 655 %{srcpath}/key.pem %{buildroot}/etc/cuttlefish-orchestration/ssl/cert/key.pem

%define srcpath ../../../frontend/host/packages/cuttlefish-orchestration
install -m 655 %{srcpath}/etc/nginx/conf.d/cuttlefish-orchestration.conf %{buildroot}/etc/nginx/conf.d/cuttlefish-orchestration.conf
install -m 655 %{srcpath}/etc/sudoers.d/cuttlefish-orchestration %{buildroot}/etc/sudoers.d/cuttlefish-orchestration


%files
/etc/cuttlefish-orchestration/ssl/cert/cert.pem
/etc/cuttlefish-orchestration/ssl/cert/key.pem
/etc/nginx/conf.d/cuttlefish-orchestration.conf
/etc/sudoers.d/cuttlefish-orchestration

#%%license add-license-file-here
#%%doc add-docs-here


%post
ln -sf /usr/lib/cuttlefish-common/bin/cvd /usr/bin/fetch_cvd

# The cvdnetwork group is created by cuttlefish-base
if ! getent passwd _cvd-executor > /dev/null 2>&1 ; then
adduser --system --shell /sbin/nologin --home /var/empty --no-create-home _cvd-executor
usermod -a -G cvdnetwork,kvm _cvd-executor
fi

# Reload nginx having the orchestration configuration
systemctl try-reload-or-restart nginx.service


%preun


%postun
if [ -f /usr/bin/fetch_cvd ]; then
rm /usr/bin/fetch_cvd
fi

if getent passwd _cvd-executor > /dev/null 2>&1; then
userdel _cvd-executor
fi

# Reload nginx without the orchestration configuration
systemctl try-reload-or-restart nginx.service

%changelog
* Thu Jul 11 2024 Martin Zeitler <?>
- Initial version.

Loading