From 8b6eac3c1ca974e6ec68166f67b71e9242ead1c2 Mon Sep 17 00:00:00 2001 From: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com> Date: Wed, 16 Nov 2022 15:46:00 -0700 Subject: [PATCH] create dpkg and iso workflows (#1941) * create dpkg workflow * run workflow on this branch for now * fix formatting * install dependencies * add debhelper * fix upload * add iso build * fix syntax error * docker buildx * cache key * pureos specific dependencies * Update pureos-iso.yaml * Update pureos-iso.yaml * allow downgrades * enable kvm * no fakemachine * disable kvm * use pureos debspawn * apt update still * sudo * with init * use debspawn 0.6.0 * fix download link --- .github/workflows/debian.yaml | 52 +++++++++++++++++++++++++ .github/workflows/pureos-iso.yaml | 64 +++++++++++++++++++++++++++++++ backend/src/os_install.rs | 40 +++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 .github/workflows/debian.yaml create mode 100644 .github/workflows/pureos-iso.yaml diff --git a/.github/workflows/debian.yaml b/.github/workflows/debian.yaml new file mode 100644 index 000000000..d1f696789 --- /dev/null +++ b/.github/workflows/debian.yaml @@ -0,0 +1,52 @@ +name: Debian Package + +on: + workflow_call: + workflow_dispatch: + +env: + NODEJS_VERSION: '16' + +jobs: + dpkg: + name: Build dpkg + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + repository: Start9Labs/embassy-os-deb + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODEJS_VERSION }} + + - name: Get npm cache directory + id: npm-cache-dir + run: | + echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT + - uses: actions/cache@v3 + id: npm-cache + with: + path: ${{ steps.npm-cache-dir.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install debmake debhelper-compat + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Run build + run: "make VERSION=0.3.x TAG=${{ github.ref_name }}" + + - uses: actions/upload-artifact@v3 + with: + name: deb + path: embassyos_0.3.x-1_amd64.deb \ No newline at end of file diff --git a/.github/workflows/pureos-iso.yaml b/.github/workflows/pureos-iso.yaml new file mode 100644 index 000000000..4c51259bd --- /dev/null +++ b/.github/workflows/pureos-iso.yaml @@ -0,0 +1,64 @@ +name: PureOS Based ISO + +on: + workflow_call: + workflow_dispatch: + push: + branches: + - master + - next + - feature/iso-ci + +jobs: + dpkg: + uses: ./.github/workflows/debian.yaml + + iso: + name: Build iso + runs-on: ubuntu-22.04 + needs: [dpkg] + steps: + - uses: actions/checkout@v3 + with: + repository: Start9Labs/eos-image-recipes + + - name: Install dependencies + run: | + sudo apt update + wget http://ftp.us.debian.org/debian/pool/main/d/debspawn/debspawn_0.6.0-1.1_all.deb + sha256sum ./debspawn_0.6.0-1.1_all.deb | grep 6cdb444844825b82ef388378f2c508fd8886f79a49800d4547a353ea6772d493 + sudo apt-get install -y ./debspawn_0.6.0-1.1_all.deb + wget https://repo.pureos.net/pureos/pool/main/d/debootstrap/debootstrap_1.0.125pureos1_all.deb + sudo apt-get install -y --allow-downgrades ./debootstrap_1.0.125pureos1_all.deb + wget https://repo.pureos.net/pureos/pool/main/p/pureos-archive-keyring/pureos-archive-keyring_2021.11.0_all.deb + sudo apt-get install -y ./pureos-archive-keyring_2021.11.0_all.deb + + - name: Configure debspawn + run: | + sudo mkdir -p /etc/debspawn/ + echo "AllowUnsafePermissions=true" | sudo tee /etc/debspawn/global.toml + + - uses: actions/cache@v3 + with: + path: /var/lib/debspawn + key: ${{ runner.os }}-debspawn-init-byzantium + + - name: Make build container + run: "debspawn list | grep byzantium || debspawn create --with-init byzantium" + + - run: "mkdir -p overlays/vendor/root" + + - name: Download dpkg + uses: actions/download-artifact@v3 + with: + name: deb + path: overlays/vendor/root + + - name: Run build + run: | + ./run-local-build.sh --no-fakemachine byzantium none custom "" true + + - uses: actions/upload-artifact@v3 + with: + name: iso + path: results/*.iso diff --git a/backend/src/os_install.rs b/backend/src/os_install.rs index 7bbcb1e4b..066a4bab6 100644 --- a/backend/src/os_install.rs +++ b/backend/src/os_install.rs @@ -279,6 +279,46 @@ pub async fn execute( .arg(&disk.logicalname) .invoke(crate::ErrorKind::Unknown) // TODO grub .await?; + let kern_version = String::from_utf8( + Command::new("uname") + .arg("-r") + .invoke(crate::ErrorKind::Unknown) // TODO kernel + .await?, + )?; + let root_uuid = String::from_utf8( + Command::new("grub-probe") + .arg("-d") + .arg("-target=fs_uuid") + .arg(&root_part) + .invoke(crate::ErrorKind::Unknown) + .await?, + )?; + tokio::fs::write( + current.join("boot/kexec_default.1.txt"), + format!( + concat!( + "Debian GNU/Linux|", + "elf|", + "kernel /vmlinuz-{kern_version}|", + "initrd /initrd.img-{kern_version}|", + "append root=UUID={root_uuid} ro boot=embassy quiet splash", + ), + kern_version = &kern_version, + root_uuid = &root_uuid, + ) + .as_bytes(), + ) + .await?; + tokio::fs::write( + current.join("boot/kexec_default_hashes.txt"), + Command::new("sha256sum") + .arg(format!("./vmlinuz-{}", kern_version)) + .arg(format!("./initrd.img-{}", kern_version)) + .current_dir(current.join("boot")) + .invoke(crate::ErrorKind::Filesystem) + .await?, + ) + .await?; dev.unmount().await?; sys.unmount().await?;