diff --git a/.github/workflows/reusable-build.yaml b/.github/workflows/reusable-build.yaml index b9425d7cd16..2a46d6fc4f5 100644 --- a/.github/workflows/reusable-build.yaml +++ b/.github/workflows/reusable-build.yaml @@ -3,6 +3,7 @@ name: ReusableBuild on: [workflow_call] jobs: + build-arm64-cuttlefish-deb-job: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/reusable-docker.yml b/.github/workflows/reusable-docker.yml new file mode 100644 index 00000000000..6eccd95fa70 --- /dev/null +++ b/.github/workflows/reusable-docker.yml @@ -0,0 +1,138 @@ +name: Reusable Docker Container Run + +on: + workflow_call: + secrets: + token: + required: true + inputs: + registry: + default: 'ghcr.io' + required: false + type: string + username: + required: true + type: string + image: + required: true + type: string + tag: + default: latest + required: false + type: string + platform: + default: linux/amd64 + required: false + type: string + outputs: + builder: + value: ${{ jobs.docker-run.outputs.builder }} + description: "Build output" + testing: + value: ${{ jobs.docker-run.outputs.testing }} + description: "Package test output" + integration: + value: ${{ jobs.docker-run.outputs.integration }} + description: "Integration output" + orchestration: + value: ${{ jobs.docker-run.outputs.orchestration }} + description: "Orchestration output" +jobs: + + docker-run: + runs-on: ubuntu-latest + outputs: + builder: ${{ steps.build-rpm-packages.outputs.result }} + testing: ${{ steps.test-rpm-packages.outputs.result }} + integration: ${{ steps.test-integration.outputs.result }} + orchestration: ${{ steps.test-orchestration.outputs.result }} + env: + DEFAULT_OPTIONS: '--attach STDOUT --attach STDERR --quiet' + steps: + + # https://github.com/docker/login-action + - name: Log in to the Container registry + uses: 'docker/login-action@v3' + id: container-registry + with: + registry: ${{ INPUTS.REGISTRY }} + username: ${{ INPUTS.USERNAME }} + password: ${{ SECRETS.TOKEN }} + + # https://docs.docker.com/reference/cli/docker/container/run/ + # https://docs.docker.com/reference/cli/docker/container/cp/ + # --entrypoint ${{ INPUTS.ENTRY-POINT }} cannot be changed with GitHub docker. + - name: Run docker and somehow extract the archive from the volume. + if: ${{ contains(INPUTS.IMAGE, 'builder') && !contains(INPUTS.PLATFORM, 'linux/arm64') }} + id: build-rpm-packages + shell: bash + env: + RPM_PLATFORM: ${{ INPUTS.PLATFORM }} + DOCKER_IMAGE: ${{ INPUTS.REGISTRY }}/${{ INPUTS.USERNAME }}/${{ INPUTS.IMAGE }}:${{ INPUTS.TAG }} + DOCKER_OPTIONS: '--name rpm-builder' + run: | + # docker run $DOCKER_OPTIONS $DEFAULT_OPTIONS --env platform="$RPM_PLATFORM" $$DOCKER_IMAGE + docker run $DOCKER_OPTIONS $DEFAULT_OPTIONS $DOCKER_IMAGE >> $GITHUB_STEP_SUMMARY + MOUNT_POINT=$(docker volume ls --filter driver="local" --format '{{.Mountpoint}}') + VOLUME_HASH=$(docker volume ls --filter driver="local" --format '{{.Name}}') + DIRECTORY=/var/lib/docker/volumes/$VOLUME_HASH/_data + CID=`docker ps -aqf "name=^rpm-builder$"` + + echo Listing container $CID with attached volume: $DIRECTORY + echo Mountpoint value: $MOUNT_POINT + + # TODO: Finds nothing, because the entrypoint.sh does not seem to execute. + # docker cp $CID:/root/android-cuttlefish-rpm.tar.gz ${{ RUNNER.TEMP }} + # docker cp rpm-builder:/root/android-cuttlefish-rpm.tar.gz ${{ RUNNER.TEMP }} + sudo ls -la $DIRECTORY + cp $DIRECTORY/android-cuttlefish-rpm.tar.gz ${{ RUNNER.TEMP }} + + docker rm rpm-builder + echo "result=ok" >> $GITHUB_OUTPUT + + # https://github.com/actions/upload-artifact + - name: Retain Artifacts (*.rpm) + uses: 'actions/upload-artifact@v4' + id: retain-rpm-packages + if: ${{ contains(INPUTS.IMAGE, 'builder') && !contains(INPUTS.PLATFORM, 'linux/arm64') }} + with: + path: ${{ RUNNER.TEMP }}/*.tar.gz + name: android-cuttlefish-rhel-${{ INPUTS.PLATFORM }} + retention-days: 14 + + # https://docs.docker.com/reference/cli/docker/container/run/ + - name: Run package tests + if: ${{ contains(INPUTS.IMAGE, 'testing') }} + id: test-rpm-packages + shell: bash + env: + DOCKER_IMAGE: ${{ INPUTS.REGISTRY }}/${{ INPUTS.USERNAME }}/${{ INPUTS.IMAGE }}:${{ INPUTS.TAG }} + DOCKER_OPTIONS: '--name rpm-testing' + run: | + docker run $DOCKER_OPTIONS $DEFAULT_OPTIONS $DOCKER_IMAGE >> $GITHUB_STEP_SUMMARY + docker rm rpm-testing + echo "result=ok" >> $GITHUB_OUTPUT + + # https://docs.docker.com/reference/cli/docker/container/run/ + - name: Run integration test + if: ${{ contains(INPUTS.IMAGE, 'integration') }} + id: test-integration + shell: bash + env: + DOCKER_IMAGE: ${{ INPUTS.REGISTRY }}/${{ INPUTS.USERNAME }}/${{ INPUTS.IMAGE }}:${{ INPUTS.TAG }} + DOCKER_OPTIONS: '--name rhel-integration' + run: | + docker run $DOCKER_OPTIONS $DEFAULT_OPTIONS $DOCKER_IMAGE >> $GITHUB_STEP_SUMMARY + echo "result=ok" >> $GITHUB_OUTPUT + + # https://docs.docker.com/reference/cli/docker/container/run/ + - name: Run orchestration test + if: ${{ contains(INPUTS.DOCKER-IMAGE, 'orchestration') }} + id: test-orchestration + shell: bash + env: + DOCKER_IMAGE: ${{ INPUTS.REGISTRY }}/${{ INPUTS.USERNAME }}/${{ INPUTS.IMAGE }}:${{ INPUTS.TAG }} + DOCKER_OPTIONS: '--name rhel-orchestration' + run: | + docker run $DOCKER_OPTIONS $DEFAULT_OPTIONS $DOCKER_IMAGE >> $GITHUB_STEP_SUMMARY + echo "result=ok" >> $GITHUB_OUTPUT diff --git a/.github/workflows/rpm-builder.yml b/.github/workflows/rpm-builder.yml new file mode 100644 index 00000000000..fa1e5de4a35 --- /dev/null +++ b/.github/workflows/rpm-builder.yml @@ -0,0 +1,116 @@ +name: RPM Builder + +on: [ push ] + +jobs: + + build-images: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + + strategy: + max-parallel: 1 + matrix: + platform: [ linux/amd64 ] + # target: [ rpm-builder, rpm-testing, rhel-integration, rhel-orchestration ] + target: [ rpm-builder, rpm-testing ] + include: + - target: rpm-builder + stage: builder + - target: rpm-testing + stage: testing + # - target: rhel-integration + # stage: integration + # - target: rhel-orchestration + # stage: orchestration + # exclude: + # - platform: linux/arm64 + # target: rpm-testing + # - platform: linux/arm64 + # target: rhel-integration + # - platform: linux/arm64 + # target: rpm-testing + + steps: + - uses: 'actions/checkout@v4' + - uses: 'docker/setup-qemu-action@v3' + with: + platforms: arm64 + + # https://github.com/docker/metadata-action + - name: Extract metadata (tags, labels) + uses: 'docker/metadata-action@v5' + id: metadata + with: + images: ghcr.io/${{ GITHUB.ACTOR }}/${{ MATRIX.TARGET }} + tags: ${{ GITHUB.ACTOR }}/${{ MATRIX.TARGET }}:latest + + - uses: 'docker/login-action@v3' + id: container-registry + with: + registry: 'ghcr.io' + username: ${{ GITHUB.ACTOR }} + password: ${{ SECRETS.GITHUB_TOKEN }} + + # https://github.com/marketplace/actions/build-and-push-docker-images + - uses: 'docker/setup-buildx-action@v3' + - name: Build and push Docker image + uses: 'docker/build-push-action@v6' + id: build + with: + context: . + file: docker/rpm-builder/Dockerfile + push: ${{ GITHUB.EVENT_NAME != 'pull_request' }} + platforms: ${{ MATRIX.PLATFORM }} + target: ${{ MATRIX.TARGET_STAGE }} + builder: ${{ steps.buildx.outputs.name }} + labels: ${{ steps.metadata.outputs.labels }} + tags: ${{ steps.metadata.outputs.tags }} + + # Note: The digest comes from `buildx`, not the metadata. + # https://github.com/actions/attest-build-provenance + - name: Generate artifact attestation + uses: 'actions/attest-build-provenance@v2' + with: + subject-name: ghcr.io/${{ GITHUB.ACTOR }}/${{ MATRIX.TARGET }} + subject-digest: ${{ steps.build.outputs.digest }} + push-to-registry: true + + run-images: + uses: ./.github/workflows/reusable-docker.yml + needs: build-images + with: + registry: 'ghcr.io' + username: ${{ GITHUB.ACTOR }} + image: ${{ MATRIX.TARGET }} + platform: ${{ MATRIX.PLATFORM }} + secrets: + token: ${{ SECRETS.GITHUB_TOKEN }} + strategy: + max-parallel: 1 + matrix: + # The `platform` is being passed into the shell as variable $RPM_PLATFORM. + # platform: [ linux/amd64, linux/arm64 ] + platform: [ linux/amd64 ] + # target: [ rpm-builder, rpm-testing, rhel-integration, rhel-orchestration ] + target: [ rpm-builder, rpm-testing ] + include: + - target: rpm-builder + stage: builder + - target: rpm-testing + stage: testing +# - target: rhel-integration +# stage: integration +# - target: rhel-orchestration +# stage: orchestration +# exclude: +# - platform: linux/arm64 +# target: rpm-testing +# - platform: linux/arm64 +# target: rhel-integration +# - platform: linux/arm64 +# target: rpm-testing diff --git a/base/cvd/MODULE.bazel b/base/cvd/MODULE.bazel index 8582198416f..478adf1dbc3 100644 --- a/base/cvd/MODULE.bazel +++ b/base/cvd/MODULE.bazel @@ -59,6 +59,7 @@ git_override( ) git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + git_repository( name = "fruit", build_file = "@//:BUILD.fruit.bazel", @@ -146,7 +147,6 @@ git_repository( build_file = "@//build_external/wayland:BUILD.wayland.bazel", commit = "b2649cb3ee6bd70828a17e50beb16591e6066288", # 1.22.0 remote = "https://gitlab.freedesktop.org/wayland/wayland.git", - patch_strip = 1, patches = [ "@//build_external/wayland:PATCH.wayland.wayland_config.patch", ], diff --git a/base/debian/cuttlefish-base.cuttlefish-host-resources.init b/base/debian/cuttlefish-base.cuttlefish-host-resources.init index 6956fceff2c..4080aac444f 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 @@ -359,7 +369,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 00000000000..e4434668361 --- /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/docker/rpm-builder/Dockerfile b/docker/rpm-builder/Dockerfile new file mode 100644 index 00000000000..69f900dfbb5 --- /dev/null +++ b/docker/rpm-builder/Dockerfile @@ -0,0 +1,86 @@ +# Dockerfile based on Rocky Linux +# https://docs.docker.com/reference/dockerfile/ +# https://hub.docker.com/_/rockylinux +ARG ROCKY_LINUX_VERSION=9.5 +FROM rockylinux/rockylinux:$ROCKY_LINUX_VERSION AS rockylinux +LABEL description="RPM Builder" version="1.0.0" repository="https://github.com/google/android-cuttlefish" maintainer="Martin Zeitler" + +# Base Image +FROM rockylinux AS base +ENTRYPOINT [ "/bin/sh" ] +WORKDIR "/root" +VOLUME "/root" + +# The EPEL repository installs `dnf-core-plugin` (`config-manager` and `builddeps`) and provides `ncurses-compat-libs`. +RUN dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm sudo git nano && dnf -y upgrade + +# Configuring further package repositories: / https://wiki.rockylinux.org/rocky/repo/#extra-repositories +RUN dnf config-manager --set-enabled crb && dnf config-manager --set-disabled extras && dnf clean all + +# Modify file `~/.bash_profile`. +RUN echo "export GOPATH=${HOME}/go" >> ~/.bash_profile \ +echo "export PATH=${PATH}:${HOME}/go/bin" >> ~/.bash_profile \ +echo "USE_BAZEL_VERSION=${BAZEL_VERSION}" >> ~/.bazeliskrc \ +source ~/.bash_profile + + +# RPM Builder +FROM base AS builder +ARG BAZEL_VERSION=7.6.0 + +# Add entrypoint script. +ADD ./docker/rpm-builder/buildscript.sh /root/buildscript.sh +ENTRYPOINT [ "/bin/sh", "-c", "./buildscript.sh" ] + +# Build dependencies. +# RUN dnf -y install dpkg-dev devscripts vim-enhanced +# RUN dnf -y install rpm-devel rpmdevtools rpmlint gcc make python diffutils patch +RUN dnf -y install rpm-build golang-bin curl-devel wayland-devel ncurses-compat-libs \ +# Package `protobuf` comes from CRB repository +protobuf protobuf-devel protobuf-compiler && dnf clean all + +# Run go install `bazelisk`. +RUN go install github.com/bazelbuild/bazelisk@latest + + +# RPM Testing +FROM base AS testing + +# Add entrypoint script. +ADD ./docker/rpm-builder/testscript.sh /root/testscript.sh +ENTRYPOINT [ "/bin/sh", "-c", "./testscript.sh" ] + +# Runtime Dependencies +RUN dnf -y install libwayland-* && dnf clean all + + +# Integration Test +FROM base AS integration + +# Expose Operator Port (HTTP:1080, HTTPS:1443) +EXPOSE 1080 1443 +# Expose HO(Host Orchestrator) Port (HTTP:2080, HTTPS:2443) +EXPOSE 2080 2443 +# Expose WebRTC +EXPOSE 8443/tcp 15550-15560 +# Expose ADB +EXPOSE 6520-6620 + +# Runtime Dependencies +RUN dnf -y install qemu-kvm && dnf clean all + + +# Orchestration Test +FROM base AS orchestration + +# Expose Operator Port (HTTP:1080, HTTPS:1443) +EXPOSE 1080 1443 +# Expose HO(Host Orchestrator) Port (HTTP:2080, HTTPS:2443) +EXPOSE 2080 2443 +# Expose WebRTC +EXPOSE 8443/tcp 15550-15560 +# Expose ADB +EXPOSE 6520-6620 + +# Runtime Dependencies +RUN dnf -y install nginx systemd-journal-remote && dnf clean all diff --git a/docker/rpm-builder/buildscript.sh b/docker/rpm-builder/buildscript.sh new file mode 100755 index 00000000000..03a64d1a2a8 --- /dev/null +++ b/docker/rpm-builder/buildscript.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# The file deployed seems stuck. +REPO_NAME=android-cuttlefish +REPO_OWNER=syslogic + +git clone https://github.com/${REPO_OWNER}/${REPO_NAME}.git +cd $REPO_NAME || exit +[ "${REPO_OWNER}" == "syslogic" ] && echo git switch rpm-build +./tools/buildutils/build_packages.sh +tar zcvf ~/android-cuttlefish-rpm.tar.gz ~/${REPO_NAME}/tools/rpmbuild/*.rpm +ls -la ~ diff --git a/docker/rpm-builder/testscript.sh b/docker/rpm-builder/testscript.sh new file mode 100755 index 00000000000..4dcaa6e2337 --- /dev/null +++ b/docker/rpm-builder/testscript.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# TODO: Somehow obtain the published artifacts, which are currently not even built. +# cd /root || exit + +sudo dnf -y install cuttlerfish-*.rpm diff --git a/tools/buildutils/build_packages.sh b/tools/buildutils/build_packages.sh index ddf4f8427d4..8f733638afd 100755 --- a/tools/buildutils/build_packages.sh +++ b/tools/buildutils/build_packages.sh @@ -1,7 +1,9 @@ -#!/usr/bin/env bash +#!/bin/bash set -e -x +REPO_DIR="$(realpath "$(dirname "$0")/../..")" + function install_debuild_dependencies() { echo "Installing debuild dependencies" sudo apt-get update @@ -22,11 +24,25 @@ function build_package() { popd } -REPO_DIR="$(realpath "$(dirname "$0")/../..")" -INSTALL_BAZEL="$(dirname $0)/installbazel.sh" - -command -v bazel &> /dev/null || sudo "${INSTALL_BAZEL}" -install_debuild_dependencies +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" +} -build_package "${REPO_DIR}/base" -build_package "${REPO_DIR}/frontend" +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" + if ! { command -v bazel || command -v bazelisk; } >/dev/null 2>&1; then sudo "${INSTALL_BAZEL}"; fi + install_debuild_dependencies + build_package "${REPO_DIR}/base" + build_package "${REPO_DIR}/frontend" + exit 0 +fi diff --git a/tools/rpmbuild/.gitignore b/tools/rpmbuild/.gitignore new file mode 100644 index 00000000000..3a195fe6650 --- /dev/null +++ b/tools/rpmbuild/.gitignore @@ -0,0 +1,2 @@ +*.srpm +*.rpm diff --git a/tools/rpmbuild/BUILD/.gitkeep b/tools/rpmbuild/BUILD/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tools/rpmbuild/BUILDROOT/.gitkeep b/tools/rpmbuild/BUILDROOT/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tools/rpmbuild/RPMS/.gitkeep b/tools/rpmbuild/RPMS/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tools/rpmbuild/SPECS/cuttlefish_base.spec b/tools/rpmbuild/SPECS/cuttlefish_base.spec new file mode 100644 index 00000000000..294e4f74de3 --- /dev/null +++ b/tools/rpmbuild/SPECS/cuttlefish_base.spec @@ -0,0 +1,130 @@ +Name: cuttlefish-base +Version: 1.2.0 +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) + +# Note: `ncurses-compat-libs` require EPEL repository and `protobuf` requires CRB repository. +BuildRequires: curl-devel, openssl-devel, wayland-devel ncurses-compat-libs, 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 +# $HOME/go/bin/bazelisk build cuttlefish:cvd --spawn_strategy=local +$HOME/go/bin/bazelisk build //cuttlefish/package: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 + +# TODO: there are more commands there now. +%define srcpath ../../../base/cvd/bazel-bin/cuttlefish/package +# acloud_translator cvd_internal_env health process_restarter +# adb_connector cvd_internal_start kernel_log_monitor record_cvd +# allocd_client cvd_internal_status log_tee restart_cvd +# assemble_cvd cvd_internal_stop logcat_receiver run_cvd +# console_forwarder cvd_send_id_disclosure metrics screen_recording_server +# control_env_proxy_server cvd_update_security_algorithm metrics_launcher snapshot_util_cvd +# cvd echo_server mkenvimage_slim socket_vsock_proxy +# cvd.repo_mapping extract-ikconfig modem_simulator tcp_connector +# cvd.runfiles extract-vmlinux openwrt_control_server tombstone_receiver +# cvd.runfiles_manifest generate_shader_embed operator_proxy +# cvd_import_locations gnss_grpc_proxy powerbtn_cvd +# cvd_internal_display graphics_detector powerwash_cvd +install -m 755 %{srcpath}/cuttlefish-common/bin/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 00000000000..cc838d4c14d --- /dev/null +++ b/tools/rpmbuild/SPECS/cuttlefish_integration.spec @@ -0,0 +1,68 @@ +Name: cuttlefish-integration +Version: 1.2.0 +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: cuttlefish-base, qemu-kvm + +%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 00000000000..54376c2aad5 --- /dev/null +++ b/tools/rpmbuild/SPECS/cuttlefish_orchestration.spec @@ -0,0 +1,88 @@ +Name: cuttlefish-orchestration +Version: 1.2.0 +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, bash, shadow-utils, 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 00000000000..a2f7e39cf43 --- /dev/null +++ b/tools/rpmbuild/SPECS/cuttlefish_user.spec @@ -0,0 +1,93 @@ +Name: cuttlefish-user +Version: 1.2.0 +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, shadow-utils, openssl + +%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 00000000000..e69de29bb2d