diff --git a/base/debian/cuttlefish-base.cuttlefish-host-resources.init b/base/debian/cuttlefish-base.cuttlefish-host-resources.init index bd384595dd..ed644d17f3 100755 --- a/base/debian/cuttlefish-base.cuttlefish-host-resources.init +++ b/base/debian/cuttlefish-base.cuttlefish-host-resources.init @@ -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 @@ -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 diff --git a/base/rhel/cuttlefish.service b/base/rhel/cuttlefish.service new file mode 100644 index 0000000000..e443466836 --- /dev/null +++ b/base/rhel/cuttlefish.service @@ -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 + diff --git a/tools/buildutils/build_packages.sh b/tools/buildutils/build_packages.sh index 676204a60e..f8648adf42 100755 --- a/tools/buildutils/build_packages.sh +++ b/tools/buildutils/build_packages.sh @@ -2,6 +2,8 @@ set -e -x +REPO_DIR="$(realpath "$(dirname "$0")/../..")" + function install_debuild_dependencies() { echo "Installing debuild dependencies" sudo apt-get update @@ -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" diff --git a/tools/rpmbuild/.gitignore b/tools/rpmbuild/.gitignore new file mode 100644 index 0000000000..e7a9c1347b --- /dev/null +++ b/tools/rpmbuild/.gitignore @@ -0,0 +1 @@ +*.rpm diff --git a/tools/rpmbuild/BUILD/.gitkeep b/tools/rpmbuild/BUILD/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/rpmbuild/BUILDROOT/.gitkeep b/tools/rpmbuild/BUILDROOT/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/rpmbuild/RPMS/.gitkeep b/tools/rpmbuild/RPMS/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/rpmbuild/SPECS/cuttlefish_base.spec b/tools/rpmbuild/SPECS/cuttlefish_base.spec new file mode 100644 index 0000000000..3b914d4b05 --- /dev/null +++ b/tools/rpmbuild/SPECS/cuttlefish_base.spec @@ -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. + diff --git a/tools/rpmbuild/SPECS/cuttlefish_integration.spec b/tools/rpmbuild/SPECS/cuttlefish_integration.spec new file mode 100644 index 0000000000..b76b36c371 --- /dev/null +++ b/tools/rpmbuild/SPECS/cuttlefish_integration.spec @@ -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. + diff --git a/tools/rpmbuild/SPECS/cuttlefish_orchestration.spec b/tools/rpmbuild/SPECS/cuttlefish_orchestration.spec new file mode 100644 index 0000000000..ea3659b2f1 --- /dev/null +++ b/tools/rpmbuild/SPECS/cuttlefish_orchestration.spec @@ -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. + diff --git a/tools/rpmbuild/SPECS/cuttlefish_user.spec b/tools/rpmbuild/SPECS/cuttlefish_user.spec new file mode 100644 index 0000000000..4f0165ef46 --- /dev/null +++ b/tools/rpmbuild/SPECS/cuttlefish_user.spec @@ -0,0 +1,93 @@ +Name: cuttlefish-user +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: golang-bin +Requires: cuttlefish-base, openssl, shadow-utils + +%description +Cuttlefish Android Virtual Device companion package +Contains the host signaling server supporting multi-device flows over WebRTC. + + +%prep + + +%build +cd ../../../frontend +./build-webui.sh +cd src/host_orchestrator +go build +cd ../operator +go build + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p %{buildroot}/etc/default +mkdir -p %{buildroot}/etc/rc.d/init.d +mkdir -p %{buildroot}/usr/bin +mkdir -p %{buildroot}/usr/lib/cuttlefish-common/bin +mkdir -p %{buildroot}/usr/share/cuttlefish-common/operator/intercept/js +mkdir -p %{buildroot}/usr/share/cuttlefish-common/operator/static + + +%define srcpath ../../../frontend/src +install -m 755 %{srcpath}/host_orchestrator/host_orchestrator %{buildroot}/usr/lib/cuttlefish-common/bin/host_orchestrator +install -m 755 %{srcpath}/operator/operator %{buildroot}/usr/lib/cuttlefish-common/bin/operator +install -m 655 %{srcpath}/operator/intercept/js/server_connector.d.ts %{buildroot}/usr/share/cuttlefish-common/operator/intercept/js/server_connector.d.ts +install -m 655 %{srcpath}//operator/intercept/js/server_connector.js %{buildroot}/usr/share/cuttlefish-common/operator/intercept/js/server_connector.js + +%define srcpath ../../../frontend/src/operator/webui/dist/static +for filename in $(ls %{srcpath}) ; do + install -m 655 %{srcpath}/$filename %{buildroot}/usr/share/cuttlefish-common/operator/static/$filename +done + + +%files +/usr/lib/cuttlefish-common/bin/host_orchestrator +/usr/lib/cuttlefish-common/bin/operator + +/usr/share/cuttlefish-common/operator/intercept/js/server_connector.d.ts +/usr/share/cuttlefish-common/operator/intercept/js/server_connector.js + +/usr/share/cuttlefish-common/operator/static/index.html +/usr/share/cuttlefish-common/operator/static/3rdpartylicenses.txt +/usr/share/cuttlefish-common/operator/static/main.* +/usr/share/cuttlefish-common/operator/static/polyfills.* +/usr/share/cuttlefish-common/operator/static/runtime.* +/usr/share/cuttlefish-common/operator/static/styles.* + +#%%license add-license-file-here +#%%doc add-docs-here + +%post +ln -sf /usr/lib/cuttlefish-common/bin/host_orchestrator /usr/bin/cvd_host_orchestrator + +# The cvdnetwork group is created by cuttlefish-base +if ! getent passwd _cutf-operator > /dev/null 2>&1 ; then + adduser --system --shell /sbin/nologin --home /var/empty --no-create-home --gid cvdnetwork _cutf-operator +fi + +%preun +if [ -f /usr/bin/cvd_host_orchestrator ]; then + rm /usr/bin/cvd_host_orchestrator +fi + + +%postun +if getent passwd _cutf-operator > /dev/null 2>&1; then + userdel _cutf-operator +fi + + +%changelog +* Thu Jul 11 2024 Martin Zeitler +- Initial version. + diff --git a/tools/rpmbuild/SRPMS/.gitkeep b/tools/rpmbuild/SRPMS/.gitkeep new file mode 100644 index 0000000000..e69de29bb2