From 8ea3c3c29e6d6331fac6a5f4398c121602a2d3e8 Mon Sep 17 00:00:00 2001 From: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com> Date: Mon, 23 Oct 2023 14:40:00 -0600 Subject: [PATCH] consolidate and streamline build (#2469) * consolidate and streamline build * fix workflow syntax * fix workflow syntax * fix workflow syntax * fix workflow syntax * fix build scripts * only build platform-specific system images * fix build script * more build fixes * fix * fix compat build for x86 * wat * checkout * Prevent rebuild of compiled artifacts * Update startos-iso.yaml * Update startos-iso.yaml * fix raspi build * handle missing platform better * reduce arm vcpus * remove arch and platform from fe config, add to patch db --------- Co-authored-by: Matt Hill --- .github/workflows/startos-iso.yaml | 196 +++++------ .gitignore | 8 +- Makefile | 156 +++++---- backend/Cargo.lock | 23 -- backend/Cargo.toml | 4 +- backend/build-prod.sh | 25 +- backend/install-sdk.sh | 4 +- backend/src/bins/start_deno.rs | 21 +- backend/src/bins/start_init.rs | 10 +- backend/src/config/spec.rs | 4 +- backend/src/db/model.rs | 16 + backend/src/firmware.rs | 2 +- backend/src/init.rs | 8 +- backend/src/lib.rs | 8 +- backend/src/logs.rs | 17 +- backend/src/procedure/docker.rs | 2 +- backend/src/registry/marketplace.rs | 2 +- backend/src/shutdown.rs | 6 +- backend/src/update/mod.rs | 6 +- backend/src/util/docker.rs | 8 +- backend/src/version/mod.rs | 3 +- .../scripts/test-package/0.3.0.3/embassy.js | 4 +- backend/update-sqlx-data.sh | 2 +- basename.sh | 19 + build-cargo-dep.sh | 2 +- build/.gitignore | 2 + build/{lib => dpkg-deps}/conflicts | 4 +- build/{lib => dpkg-deps}/depends | 6 - build/dpkg-deps/docker.depends | 5 + build/dpkg-deps/generate.sh | 43 +++ build/dpkg-deps/unstable.depends | 2 + build/lib/motd | 4 +- build/lib/scripts/enable-kiosk | 6 +- build/lib/scripts/fake-apt | 2 +- build/lib/scripts/persist-apt-install | 2 +- build/raspberrypi/make-image.sh | 10 +- check-git-hash.sh | 6 +- check-platform.sh | 8 + {build/lib/scripts => debian}/postinst | 27 +- dpkg-build.sh | 48 +++ frontend/config-sample.json | 2 - .../shared/src/types/workspace-config.ts | 2 - .../server-logs/server-logs.page.html | 2 +- .../ui/src/app/services/api/mock-patch.ts | 1 + .../ui/src/app/services/config.service.ts | 4 - .../src/app/services/patch-db/data-model.ts | 1 + image-recipe/.gitignore | 2 + image-recipe/README.md | 23 ++ image-recipe/build.sh | 324 ++++++++++++++++++ image-recipe/prepare.sh | 24 ++ .../raspberrypi/img/etc}/fstab | 0 .../usr/lib/startos/scripts}/init_resize.sh | 2 +- .../raspberrypi/squashfs/boot/cmdline.txt | 1 + .../raspberrypi/squashfs/boot/config.txt | 86 +++++ .../squashfs/etc/embassy/config.yaml | 6 + .../squashfs/etc/modprobe.d/cfg80211.conf | 1 + .../squashfs/usr/bin/extract-ikconfig | 69 ++++ image-recipe/run-local-build.sh | 88 +++++ image-recipe/splash.png | Bin 0 -> 9834 bytes system-images/compat/Cargo.lock | 29 -- system-images/compat/Makefile | 11 +- system-images/compat/build.sh | 11 +- 62 files changed, 1052 insertions(+), 368 deletions(-) create mode 100755 basename.sh create mode 100644 build/.gitignore rename build/{lib => dpkg-deps}/conflicts (51%) rename build/{lib => dpkg-deps}/depends (88%) create mode 100644 build/dpkg-deps/docker.depends create mode 100755 build/dpkg-deps/generate.sh create mode 100644 build/dpkg-deps/unstable.depends create mode 100755 check-platform.sh rename {build/lib/scripts => debian}/postinst (81%) create mode 100755 dpkg-build.sh create mode 100644 image-recipe/.gitignore create mode 100644 image-recipe/README.md create mode 100755 image-recipe/build.sh create mode 100755 image-recipe/prepare.sh rename {build/raspberrypi => image-recipe/raspberrypi/img/etc}/fstab (100%) rename {build/raspberrypi => image-recipe/raspberrypi/img/usr/lib/startos/scripts}/init_resize.sh (98%) create mode 100644 image-recipe/raspberrypi/squashfs/boot/cmdline.txt create mode 100644 image-recipe/raspberrypi/squashfs/boot/config.txt create mode 100644 image-recipe/raspberrypi/squashfs/etc/embassy/config.yaml create mode 100644 image-recipe/raspberrypi/squashfs/etc/modprobe.d/cfg80211.conf create mode 100755 image-recipe/raspberrypi/squashfs/usr/bin/extract-ikconfig create mode 100755 image-recipe/run-local-build.sh create mode 100644 image-recipe/splash.png diff --git a/.github/workflows/startos-iso.yaml b/.github/workflows/startos-iso.yaml index c2e568d47..b33d57984 100644 --- a/.github/workflows/startos-iso.yaml +++ b/.github/workflows/startos-iso.yaml @@ -12,9 +12,9 @@ on: - dev - unstable - dev-unstable - - podman - - dev-podman - - dev-unstable-podman + - docker + - dev-docker + - dev-unstable-docker runner: type: choice description: Runner @@ -42,11 +42,55 @@ on: env: NODEJS_VERSION: "18.15.0" - ENVIRONMENT: '${{ fromJson(format(''["{0}", ""]'', github.event.inputs.environment || ''dev-podman''))[github.event.inputs.environment == ''NONE''] }}' + ENVIRONMENT: '${{ fromJson(format(''["{0}", ""]'', github.event.inputs.environment || ''dev''))[github.event.inputs.environment == ''NONE''] }}' jobs: - all: - name: Build + compile: + name: Compile Base Binaries + strategy: + fail-fast: true + matrix: + arch: >- + ${{ + fromJson('{ + "x86_64": ["x86_64"], + "x86_64-nonfree": ["x86_64"], + "aarch64": ["aarch64"], + "aarch64-nonfree": ["aarch64"], + "raspberrypi": ["aarch64"], + "ALL": ["x86_64", "aarch64"] + }')[github.event.inputs.platform || 'ALL'] + }} + runs-on: ${{ fromJson('["ubuntu-22.04", "buildjet-32vcpu-ubuntu-2204"]')[github.event.inputs.runner == 'fast'] }} + steps: + - run: | + sudo mount -t tmpfs tmpfs . + if: ${{ github.event.inputs.runner == 'fast' }} + + - uses: actions/checkout@v3 + with: + submodules: recursive + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODEJS_VERSION }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Make + run: make ARCH=${{ matrix.arch }} compiled-${{ matrix.arch }}.tar + + - uses: actions/upload-artifact@v3 + with: + name: compiled-${{ matrix.arch }}.tar + path: compiled-${{ matrix.arch }}.tar + image: + name: Build Image + needs: [compile] strategy: fail-fast: false matrix: @@ -68,86 +112,30 @@ jobs: format( '["ubuntu-22.04", "{0}"]', fromJson('{ - "x86_64": ["buildjet-32vcpu-ubuntu-2204", "buildjet-32vcpu-ubuntu-2204"], - "x86_64-nonfree": ["buildjet-32vcpu-ubuntu-2204", "buildjet-32vcpu-ubuntu-2204"], - "aarch64": ["buildjet-16vcpu-ubuntu-2204-arm", "buildjet-32vcpu-ubuntu-2204-arm"], - "aarch64-nonfree": ["buildjet-16vcpu-ubuntu-2204-arm", "buildjet-32vcpu-ubuntu-2204-arm"], - "raspberrypi": ["buildjet-16vcpu-ubuntu-2204-arm", "buildjet-32vcpu-ubuntu-2204-arm"], - }')[matrix.platform][github.event.inputs.platform == matrix.platform] + "x86_64": "buildjet-32vcpu-ubuntu-2204", + "x86_64-nonfree": "buildjet-32vcpu-ubuntu-2204", + "aarch64": "buildjet-8vcpu-ubuntu-2204-arm", + "aarch64-nonfree": "buildjet-8vcpu-ubuntu-2204-arm", + "raspberrypi": "buildjet-8vcpu-ubuntu-2204-arm", + }')[matrix.platform] ) )[github.event.inputs.runner == 'fast'] }} + env: + ARCH: >- + ${{ + fromJson('{ + "x86_64": "x86_64", + "x86_64-nonfree": "x86_64", + "aarch64": "aarch64", + "aarch64-nonfree": "aarch64", + "raspberrypi": "aarch64", + }')[matrix.platform] + }} steps: - - name: Free space - run: df -h && rm -rf /opt/hostedtoolcache* && df -h - if: ${{ github.event.inputs.runner != 'fast' }} - - - run: | - sudo mount -t tmpfs tmpfs . - if: ${{ github.event.inputs.runner == 'fast' && (matrix.platform == 'x86_64' || matrix.platform == 'x86_64-nonfree' || github.event.inputs.platform == matrix.platform) }} - - - uses: actions/checkout@v3 - with: - repository: Start9Labs/embassy-os-deb - path: embassy-os-deb - - uses: actions/checkout@v3 with: submodules: recursive - path: embassy-os-deb/embassyos-0.3.x - - - run: | - cp -r debian embassyos-0.3.x/ - VERSION=0.3.x ./control.sh - cp embassyos-0.3.x/backend/startd.service embassyos-0.3.x/debian/embassyos.startd.service - working-directory: embassy-os-deb - - - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODEJS_VERSION }} - - - uses: actions/cache@v3 - with: - path: /var/lib/docker - key: ${{ runner.os }}-${{ matrix.platform }}-docker-cache - - - 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 \ - crossbuild-essential-arm64 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Run dpkg build - working-directory: embassy-os-deb - run: "make VERSION=0.3.x TAG=${{ github.ref_name }}" - env: - OS_ARCH: ${{ matrix.platform }} - - - uses: actions/checkout@v3 - with: - repository: Start9Labs/startos-image-recipes - path: startos-image-recipes - ref: feature/podman - name: Install dependencies run: | @@ -166,52 +154,40 @@ jobs: - run: sudo mount -t tmpfs tmpfs /var/tmp/debspawn if: ${{ github.event.inputs.runner == 'fast' && (matrix.platform == 'x86_64' || matrix.platform == 'x86_64-nonfree') }} - - uses: actions/cache@v3 + - name: Download compiled artifacts + uses: actions/download-artifact@v3 with: - path: /var/lib/debspawn - key: ${{ runner.os }}-${{ matrix.platform }}-debspawn-init + name: compiled-${{ env.ARCH }}.tar - - run: "mkdir -p startos-image-recipes/overlays/deb" + - name: Extract compiled artifacts + run: tar -xvf compiled-${{ env.ARCH }}.tar - - run: "mv embassy-os-deb/embassyos_0.3.x-1_*.deb startos-image-recipes/overlays/deb/" - - - run: "sudo rm -rf embassy-os-deb ${{ steps.npm-cache-dir.outputs.dir }} $HOME/.cargo" + - name: Prevent rebuild of compiled artifacts + run: | + mkdir -p frontend/dist/raw + PLATFORM=${{ matrix.platform }} make -t compiled-${{ env.ARCH }}.tar - name: Run iso build - working-directory: startos-image-recipes - run: | - ./run-local-build.sh ${{ matrix.platform }} + run: PLATFORM=${{ matrix.platform }} make iso + if: ${{ matrix.platform != 'raspberrypi' }} + + - name: Run img build + run: PLATFORM=${{ matrix.platform }} make img + if: ${{ matrix.platform == 'raspberrypi' }} - uses: actions/upload-artifact@v3 with: name: ${{ matrix.platform }}.squashfs - path: startos-image-recipes/results/*.squashfs + path: results/*.squashfs - uses: actions/upload-artifact@v3 with: name: ${{ matrix.platform }}.iso - path: startos-image-recipes/results/*.iso + path: results/*.iso if: ${{ matrix.platform != 'raspberrypi' }} - - uses: actions/checkout@v3 - with: - submodules: recursive - path: start-os - if: ${{ matrix.platform == 'raspberrypi' }} - - - run: "mv startos-image-recipes/results/startos-*_raspberrypi.squashfs start-os/startos.raspberrypi.squashfs" - if: ${{ matrix.platform == 'raspberrypi' }} - - - run: rm -rf startos-image-recipes - if: ${{ matrix.platform == 'raspberrypi' }} - - - name: Build image - working-directory: start-os - run: make startos_raspberrypi.img - if: ${{ matrix.platform == 'raspberrypi' }} - - uses: actions/upload-artifact@v3 with: - name: raspberrypi.img - path: start-os/startos-*_raspberrypi.img + name: ${{ matrix.platform }}.img + path: results/*.img if: ${{ matrix.platform == 'raspberrypi' }} diff --git a/.gitignore b/.gitignore index c91de92fd..b97eb7334 100644 --- a/.gitignore +++ b/.gitignore @@ -16,13 +16,15 @@ deploy_web.sh secrets.db .vscode/ /cargo-deps/**/* +/PLATFORM.txt /ENVIRONMENT.txt /GIT_HASH.txt /VERSION.txt -/embassyos-*.tar.gz /eos-*.tar.gz /*.deb /target /*.squashfs -/debian -/DEBIAN \ No newline at end of file +/results +/dpkg-workdir +/compiled.tar +/compiled-*.tar \ No newline at end of file diff --git a/Makefile b/Makefile index 38f09468f..07a18aadb 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,31 @@ -OS_ARCH := $(shell echo "${OS_ARCH}") -ARCH := $(shell if [ "$(OS_ARCH)" = "raspberrypi" ]; then echo aarch64; else echo $(OS_ARCH) | sed 's/-nonfree$$//g'; fi) -ENVIRONMENT_FILE = $(shell ./check-environment.sh) -GIT_HASH_FILE = $(shell ./check-git-hash.sh) -VERSION_FILE = $(shell ./check-version.sh) +PLATFORM_FILE := $(shell ./check-platform.sh) +ENVIRONMENT_FILE := $(shell ./check-environment.sh) +GIT_HASH_FILE := $(shell ./check-git-hash.sh) +VERSION_FILE := $(shell ./check-version.sh) +BASENAME := $(shell ./basename.sh) +PLATFORM := $(shell if [ -f ./PLATFORM.txt ]; then cat ./PLATFORM.txt; else echo unknown; fi) +ARCH := $(shell if [ "$(PLATFORM)" = "raspberrypi" ]; then echo aarch64; else echo $(PLATFORM) | sed 's/-nonfree$$//g'; fi) +IMAGE_TYPE=$(shell if [ "$(PLATFORM)" = raspberrypi ]; then echo img; else echo iso; fi) EMBASSY_BINS := backend/target/$(ARCH)-unknown-linux-gnu/release/startbox libs/target/aarch64-unknown-linux-musl/release/embassy_container_init libs/target/x86_64-unknown-linux-musl/release/embassy_container_init EMBASSY_UIS := frontend/dist/raw/ui frontend/dist/raw/setup-wizard frontend/dist/raw/diagnostic-ui frontend/dist/raw/install-wizard -BUILD_SRC := $(shell find build) +BUILD_SRC := $(shell git ls-files build) build/lib/depends build/lib/conflicts +DEBIAN_SRC := $(shell git ls-files debian/) +IMAGE_RECIPE_SRC := $(shell git ls-files image-recipe/) EMBASSY_SRC := backend/startd.service $(BUILD_SRC) -COMPAT_SRC := $(shell find system-images/compat/ -not -path 'system-images/compat/target/*' -and -not -name *.tar -and -not -name target) -UTILS_SRC := $(shell find system-images/utils/ -not -name *.tar) -BINFMT_SRC := $(shell find system-images/binfmt/ -not -name *.tar) -BACKEND_SRC := $(shell find backend/src) $(shell find backend/migrations) $(shell find patch-db/*/src) $(shell find libs/*/src) libs/*/Cargo.toml backend/Cargo.toml backend/Cargo.lock frontend/dist/static -FRONTEND_SHARED_SRC := $(shell find frontend/projects/shared) $(shell ls -p frontend/ | grep -v / | sed 's/^/frontend\//g') frontend/package.json frontend/node_modules frontend/config.json patch-db/client/dist frontend/patchdb-ui-seed.json -FRONTEND_UI_SRC := $(shell find frontend/projects/ui) -FRONTEND_SETUP_WIZARD_SRC := $(shell find frontend/projects/setup-wizard) -FRONTEND_DIAGNOSTIC_UI_SRC := $(shell find frontend/projects/diagnostic-ui) -FRONTEND_INSTALL_WIZARD_SRC := $(shell find frontend/projects/install-wizard) -PATCH_DB_CLIENT_SRC := $(shell find patch-db/client -not -path patch-db/client/dist -and -not -path patch-db/client/node_modules) +COMPAT_SRC := $(shell git ls-files system-images/compat/) +UTILS_SRC := $(shell git ls-files system-images/utils/) +BINFMT_SRC := $(shell git ls-files system-images/binfmt/) +BACKEND_SRC := $(shell git ls-files backend) $(shell git ls-files --recurse-submodules patch-db) $(shell git ls-files libs) frontend/dist/static +FRONTEND_SHARED_SRC := $(shell git ls-files frontend/projects/shared) $(shell ls -p frontend/ | grep -v / | sed 's/^/frontend\//g') frontend/node_modules frontend/config.json patch-db/client/dist frontend/patchdb-ui-seed.json +FRONTEND_UI_SRC := $(shell git ls-files frontend/projects/ui) +FRONTEND_SETUP_WIZARD_SRC := $(shell git ls-files frontend/projects/setup-wizard) +FRONTEND_DIAGNOSTIC_UI_SRC := $(shell git ls-files frontend/projects/diagnostic-ui) +FRONTEND_INSTALL_WIZARD_SRC := $(shell git ls-files frontend/projects/install-wizard) +PATCH_DB_CLIENT_SRC := $(shell git ls-files --recurse-submodules patch-db/client) GZIP_BIN := $(shell which pigz || which gzip) TAR_BIN := $(shell which gtar || which tar) -ALL_TARGETS := $(EMBASSY_BINS) system-images/compat/docker-images/$(ARCH).tar system-images/utils/docker-images/$(ARCH).tar system-images/binfmt/docker-images/$(ARCH).tar $(EMBASSY_SRC) $(shell if [ "$(OS_ARCH)" = "raspberrypi" ]; then echo cargo-deps/aarch64-unknown-linux-gnu/release/pi-beep; fi) $(shell /bin/bash -c 'if [[ "${ENVIRONMENT}" =~ (^|-)unstable($$|-) ]]; then echo cargo-deps/$(ARCH)-unknown-linux-gnu/release/tokio-console; fi') $(ENVIRONMENT_FILE) $(GIT_HASH_FILE) $(VERSION_FILE) +COMPILED_TARGETS := $(EMBASSY_BINS) system-images/compat/docker-images/$(ARCH).tar system-images/utils/docker-images/$(ARCH).tar system-images/binfmt/docker-images/$(ARCH).tar +ALL_TARGETS := $(EMBASSY_SRC) $(ENVIRONMENT_FILE) $(GIT_HASH_FILE) $(VERSION_FILE) $(COMPILED_TARGETS) $(shell if [ "$(PLATFORM)" = "raspberrypi" ]; then echo cargo-deps/aarch64-unknown-linux-gnu/release/pi-beep; fi) $(shell /bin/bash -c 'if [[ "${ENVIRONMENT}" =~ (^|-)unstable($$|-) ]]; then echo cargo-deps/$(ARCH)-unknown-linux-gnu/release/tokio-console; fi') $(PLATFORM_FILE) ifeq ($(REMOTE),) mkdir = mkdir -p $1 @@ -40,14 +46,14 @@ define cp endef endif - - .DELETE_ON_ERROR: -.PHONY: all gzip install clean format sdk snapshots frontends ui backend reflash startos_raspberrypi.img sudo wormhole +.PHONY: all metadata install clean format sdk snapshots frontends ui backend reflash deb $(IMAGE_TYPE) squashfs sudo wormhole docker-buildx all: $(ALL_TARGETS) +metadata: $(VERSION_FILE) $(PLATFORM_FILE) $(ENVIRONMENT_FILE) $(GIT_HASH_FILE) + sudo: sudo true @@ -64,9 +70,13 @@ clean: rm -rf patch-db/client/dist rm -rf patch-db/target rm -rf cargo-deps - rm ENVIRONMENT.txt - rm GIT_HASH.txt - rm VERSION.txt + rm -rf dpkg-workdir + rm -rf image-recipe/deb + rm -rf results + rm -f ENVIRONMENT.txt + rm -f PLATFORM.txt + rm -f GIT_HASH.txt + rm -f VERSION.txt format: cd backend && cargo +nightly fmt @@ -75,8 +85,20 @@ format: sdk: cd backend/ && ./install-sdk.sh -startos_raspberrypi.img: $(BUILD_SRC) startos.raspberrypi.squashfs $(VERSION_FILE) $(ENVIRONMENT_FILE) $(GIT_HASH_FILE) | sudo - ./build/raspberrypi/make-image.sh +deb: results/$(BASENAME).deb + +debian/control: build/lib/depends build/lib/conflicts + ./debuild/control.sh + +results/$(BASENAME).deb: dpkg-build.sh $(DEBIAN_SRC) $(VERSION_FILE) $(PLATFORM_FILE) $(ENVIRONMENT_FILE) $(GIT_HASH_FILE) + PLATFORM=$(PLATFORM) ./dpkg-build.sh + +$(IMAGE_TYPE): results/$(BASENAME).$(IMAGE_TYPE) + +squashfs: results/$(BASENAME).squashfs + +results/$(BASENAME).$(IMAGE_TYPE) results/$(BASENAME).squashfs: $(IMAGE_RECIPE_SRC) results/$(BASENAME).deb + ./image-recipe/run-local-build.sh "results/$(BASENAME).deb" # For creating os images. DO NOT USE install: $(ALL_TARGETS) @@ -88,58 +110,65 @@ install: $(ALL_TARGETS) $(call ln,/usr/bin/startbox,$(DESTDIR)/usr/bin/start-deno) $(call ln,/usr/bin/startbox,$(DESTDIR)/usr/bin/avahi-alias) $(call ln,/usr/bin/startbox,$(DESTDIR)/usr/bin/embassy-cli) - if [ "$(OS_ARCH)" = "raspberrypi" ]; then $(call cp,cargo-deps/aarch64-unknown-linux-gnu/release/pi-beep,$(DESTDIR)/usr/bin/pi-beep); fi + if [ "$(PLATFORM)" = "raspberrypi" ]; then $(call cp,cargo-deps/aarch64-unknown-linux-gnu/release/pi-beep,$(DESTDIR)/usr/bin/pi-beep); fi if /bin/bash -c '[[ "${ENVIRONMENT}" =~ (^|-)unstable($$|-) ]]'; then $(call cp,cargo-deps/$(ARCH)-unknown-linux-gnu/release/tokio-console,$(DESTDIR)/usr/bin/tokio-console); fi + $(call mkdir,$(DESTDIR)/lib/systemd/system) + $(call cp,backend/startd.service,$(DESTDIR)/lib/systemd/system/startd.service) + $(call mkdir,$(DESTDIR)/usr/lib) - $(call rm,$(DESTDIR)/usr/lib/embassy) - $(call cp,build/lib,$(DESTDIR)/usr/lib/embassy) + $(call rm,$(DESTDIR)/usr/lib/startos) + $(call cp,build/lib,$(DESTDIR)/usr/lib/startos) - $(call cp,ENVIRONMENT.txt,$(DESTDIR)/usr/lib/embassy/ENVIRONMENT.txt) - $(call cp,GIT_HASH.txt,$(DESTDIR)/usr/lib/embassy/GIT_HASH.txt) - $(call cp,VERSION.txt,$(DESTDIR)/usr/lib/embassy/VERSION.txt) + $(call cp,PLATFORM.txt,$(DESTDIR)/usr/lib/startos/PLATFORM.txt) + $(call cp,ENVIRONMENT.txt,$(DESTDIR)/usr/lib/startos/ENVIRONMENT.txt) + $(call cp,GIT_HASH.txt,$(DESTDIR)/usr/lib/startos/GIT_HASH.txt) + $(call cp,VERSION.txt,$(DESTDIR)/usr/lib/startos/VERSION.txt) - $(call mkdir,$(DESTDIR)/usr/lib/embassy/container) - $(call cp,libs/target/aarch64-unknown-linux-musl/release/embassy_container_init,$(DESTDIR)/usr/lib/embassy/container/embassy_container_init.arm64) - $(call cp,libs/target/x86_64-unknown-linux-musl/release/embassy_container_init,$(DESTDIR)/usr/lib/embassy/container/embassy_container_init.amd64) + $(call mkdir,$(DESTDIR)/usr/lib/startos/container) + $(call cp,libs/target/aarch64-unknown-linux-musl/release/embassy_container_init,$(DESTDIR)/usr/lib/startos/container/embassy_container_init.arm64) + $(call cp,libs/target/x86_64-unknown-linux-musl/release/embassy_container_init,$(DESTDIR)/usr/lib/startos/container/embassy_container_init.amd64) - $(call mkdir,$(DESTDIR)/usr/lib/embassy/system-images) - $(call cp,system-images/compat/docker-images/$(ARCH).tar,$(DESTDIR)/usr/lib/embassy/system-images/compat.tar) - $(call cp,system-images/utils/docker-images/$(ARCH).tar,$(DESTDIR)/usr/lib/embassy/system-images/utils.tar) - $(call cp,system-images/binfmt/docker-images/$(ARCH).tar,$(DESTDIR)/usr/lib/embassy/system-images/binfmt.tar) + $(call mkdir,$(DESTDIR)/usr/lib/startos/system-images) + $(call cp,system-images/compat/docker-images/$(ARCH).tar,$(DESTDIR)/usr/lib/startos/system-images/compat.tar) + $(call cp,system-images/utils/docker-images/$(ARCH).tar,$(DESTDIR)/usr/lib/startos/system-images/utils.tar) + $(call cp,system-images/binfmt/docker-images/$(ARCH).tar,$(DESTDIR)/usr/lib/startos/system-images/binfmt.tar) -update-overlay: +update-overlay: $(ALL_TARGETS) @echo "\033[33m!!! THIS WILL ONLY REFLASH YOUR DEVICE IN MEMORY !!!\033[0m" @echo "\033[33mALL CHANGES WILL BE REVERTED IF YOU RESTART THE DEVICE\033[0m" @if [ -z "$(REMOTE)" ]; then >&2 echo "Must specify REMOTE" && false; fi - @if [ "`ssh $(REMOTE) 'cat /usr/lib/embassy/VERSION.txt'`" != "`cat ./VERSION.txt`" ]; then >&2 echo "StartOS requires migrations: update-overlay is unavailable." && false; fi + @if [ "`ssh $(REMOTE) 'cat /usr/lib/startos/VERSION.txt'`" != "`cat ./VERSION.txt`" ]; then >&2 echo "StartOS requires migrations: update-overlay is unavailable." && false; fi $(call ssh,"sudo systemctl stop startd") - $(MAKE) install REMOTE=$(REMOTE) SSHPASS=$(SSHPASS) OS_ARCH=$(OS_ARCH) + $(MAKE) install REMOTE=$(REMOTE) SSHPASS=$(SSHPASS) PLATFORM=$(PLATFORM) $(call ssh,"sudo systemctl start startd") wormhole: backend/target/$(ARCH)-unknown-linux-gnu/release/startbox - @wormhole send backend/target/$(ARCH)-unknown-linux-gnu/release/startbox 2>&1 | awk -Winteractive '/wormhole receive/ { printf "sudo /usr/lib/embassy/scripts/chroot-and-upgrade \"cd /usr/bin && rm startbox && wormhole receive --accept-file %s && chmod +x startbox\"\n", $$3 }' + @wormhole send backend/target/$(ARCH)-unknown-linux-gnu/release/startbox 2>&1 | awk -Winteractive '/wormhole receive/ { printf "sudo /usr/lib/startos/scripts/chroot-and-upgrade \"cd /usr/bin && rm startbox && wormhole receive --accept-file %s && chmod +x startbox\"\n", $$3 }' -update: +update: $(ALL_TARGETS) @if [ -z "$(REMOTE)" ]; then >&2 echo "Must specify REMOTE" && false; fi $(call ssh,"sudo rsync -a --delete --force --info=progress2 /media/embassy/embassyfs/current/ /media/embassy/next/") - $(MAKE) install REMOTE=$(REMOTE) SSHPASS=$(SSHPASS) DESTDIR=/media/embassy/next OS_ARCH=$(OS_ARCH) - $(call ssh,'sudo NO_SYNC=1 /media/embassy/next/usr/lib/embassy/scripts/chroot-and-upgrade "apt-get install -y $(shell cat ./build/lib/depends)"') + $(MAKE) install REMOTE=$(REMOTE) SSHPASS=$(SSHPASS) DESTDIR=/media/embassy/next PLATFORM=$(PLATFORM) + $(call ssh,'sudo NO_SYNC=1 /media/embassy/next/usr/lib/startos/scripts/chroot-and-upgrade "apt-get install -y $(shell cat ./build/lib/depends)"') -emulate-reflash: +emulate-reflash: $(ALL_TARGETS) @if [ -z "$(REMOTE)" ]; then >&2 echo "Must specify REMOTE" && false; fi $(call ssh,"sudo rsync -a --delete --force --info=progress2 /media/embassy/embassyfs/current/ /media/embassy/next/") - $(MAKE) install REMOTE=$(REMOTE) SSHPASS=$(SSHPASS) DESTDIR=/media/embassy/next OS_ARCH=$(OS_ARCH) + $(MAKE) install REMOTE=$(REMOTE) SSHPASS=$(SSHPASS) DESTDIR=/media/embassy/next PLATFORM=$(PLATFORM) $(call ssh,"sudo touch /media/embassy/config/upgrade && sudo rm -f /media/embassy/config/disk.guid && sudo sync && sudo reboot") -system-images/compat/docker-images/aarch64.tar system-images/compat/docker-images/x86_64.tar: $(COMPAT_SRC) backend/Cargo.lock - cd system-images/compat && make && touch docker-images/*.tar +build/lib/depends build/lib/conflicts: build/dpkg-deps/* + build/dpkg-deps/generate.sh -system-images/utils/docker-images/aarch64.tar system-images/utils/docker-images/x86_64.tar: $(UTILS_SRC) - cd system-images/utils && make && touch docker-images/*.tar +system-images/compat/docker-images/$(ARCH).tar: $(COMPAT_SRC) backend/Cargo.lock | docker-buildx + cd system-images/compat && make docker-images/$(ARCH).tar && touch docker-images/$(ARCH).tar -system-images/binfmt/docker-images/aarch64.tar system-images/binfmt/docker-images/x86_64.tar: $(BINFMT_SRC) - cd system-images/binfmt && make && touch docker-images/*.tar +system-images/utils/docker-images/$(ARCH).tar: $(UTILS_SRC) | docker-buildx + cd system-images/utils && make docker-images/$(ARCH).tar && touch docker-images/$(ARCH).tar + +system-images/binfmt/docker-images/$(ARCH).tar: $(BINFMT_SRC) | docker-buildx + cd system-images/binfmt && make docker-images/$(ARCH).tar && touch docker-images/$(ARCH).tar snapshots: libs/snapshot_creator/Cargo.toml cd libs/ && ./build-v8-snapshot.sh @@ -152,27 +181,23 @@ $(EMBASSY_BINS): $(BACKEND_SRC) $(ENVIRONMENT_FILE) $(GIT_HASH_FILE) frontend/pa frontend/node_modules: frontend/package.json npm --prefix frontend ci -frontend/dist/raw/ui: $(FRONTEND_UI_SRC) $(FRONTEND_SHARED_SRC) $(ENVIRONMENT_FILE) +frontend/dist/raw/ui: $(FRONTEND_UI_SRC) $(FRONTEND_SHARED_SRC) npm --prefix frontend run build:ui -frontend/dist/raw/setup-wizard: $(FRONTEND_SETUP_WIZARD_SRC) $(FRONTEND_SHARED_SRC) $(ENVIRONMENT_FILE) +frontend/dist/raw/setup-wizard: $(FRONTEND_SETUP_WIZARD_SRC) $(FRONTEND_SHARED_SRC) npm --prefix frontend run build:setup -frontend/dist/raw/diagnostic-ui: $(FRONTEND_DIAGNOSTIC_UI_SRC) $(FRONTEND_SHARED_SRC) $(ENVIRONMENT_FILE) +frontend/dist/raw/diagnostic-ui: $(FRONTEND_DIAGNOSTIC_UI_SRC) $(FRONTEND_SHARED_SRC) npm --prefix frontend run build:dui -frontend/dist/raw/install-wizard: $(FRONTEND_INSTALL_WIZARD_SRC) $(FRONTEND_SHARED_SRC) $(ENVIRONMENT_FILE) +frontend/dist/raw/install-wizard: $(FRONTEND_INSTALL_WIZARD_SRC) $(FRONTEND_SHARED_SRC) npm --prefix frontend run build:install-wiz -frontend/dist/static: $(EMBASSY_UIS) +frontend/dist/static: $(EMBASSY_UIS) $(ENVIRONMENT_FILE) ./compress-uis.sh frontend/config.json: $(GIT_HASH_FILE) frontend/config-sample.json - jq '.useMocks = false' frontend/config-sample.json > frontend/config.json - jq '.packageArch = "$(ARCH)"' frontend/config.json > frontend/config.json.tmp - jq '.osArch = "$(OS_ARCH)"' frontend/config.json.tmp > frontend/config.json - rm frontend/config.json.tmp - npm --prefix frontend run-script build-config + jq '.useMocks = false' frontend/config-sample.json | jq '.gitHash = "$(shell cat GIT_HASH.txt)"' > frontend/config.json frontend/patchdb-ui-seed.json: frontend/package.json jq '."ack-welcome" = $(shell yq '.version' frontend/package.json)' frontend/patchdb-ui-seed.json > ui-seed.tmp @@ -186,7 +211,7 @@ patch-db/client/dist: $(PATCH_DB_CLIENT_SRC) patch-db/client/node_modules npm --prefix frontend run build:deps # used by github actions -backend-$(ARCH).tar: $(EMBASSY_BINS) +compiled-$(ARCH).tar: $(COMPILED_TARGETS) $(ENVIRONMENT_FILE) $(GIT_HASH_FILE) $(VERSION_FILE) tar -cvf $@ $^ # this is a convenience step to build all frontends - it is not referenced elsewhere in this file @@ -195,9 +220,6 @@ frontends: $(EMBASSY_UIS) # this is a convenience step to build the UI ui: frontend/dist/raw/ui -# used by github actions -backend: $(EMBASSY_BINS) - cargo-deps/aarch64-unknown-linux-gnu/release/pi-beep: ARCH=aarch64 ./build-cargo-dep.sh pi-beep diff --git a/backend/Cargo.lock b/backend/Cargo.lock index ae5690b8d..c2b316f24 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -1896,28 +1896,6 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" -[[package]] -name = "git-version" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6b0decc02f4636b9ccad390dcbe77b722a77efedfa393caf8379a51d5c61899" -dependencies = [ - "git-version-macro", - "proc-macro-hack", -] - -[[package]] -name = "git-version-macro" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe69f1cbdb6e28af2bac214e943b99ce8a0a06b447d15d3e61161b0423139f3f" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "glob" version = "0.3.1" @@ -4938,7 +4916,6 @@ dependencies = [ "emver", "fd-lock-rs", "futures", - "git-version", "gpt", "helpers", "hex", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 84998b323..bd9b4e608 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -15,6 +15,7 @@ name = "start-os" readme = "README.md" repository = "https://github.com/Start9Labs/start-os" version = "0.3.5" +license = "MIT" [lib] name = "startos" @@ -31,7 +32,7 @@ cli = [] daemon = [] default = ["cli", "sdk", "daemon", "js_engine"] dev = [] -podman = [] +docker = [] sdk = [] unstable = ["console-subscriber", "tokio/tracing"] @@ -76,7 +77,6 @@ emver = { version = "0.1.7", git = "https://github.com/Start9Labs/emver-rs.git", ] } fd-lock-rs = "0.1.4" futures = "0.3.28" -git-version = "0.3.5" gpt = "3.1.0" helpers = { path = "../libs/helpers" } hex = "0.4.3" diff --git a/backend/build-prod.sh b/backend/build-prod.sh index c679fdf98..d6c64eec2 100755 --- a/backend/build-prod.sh +++ b/backend/build-prod.sh @@ -3,11 +3,6 @@ set -e shopt -s expand_aliases -if [ -z "$OS_ARCH" ]; then - >&2 echo '$OS_ARCH is required' - exit 1 -fi - if [ -z "$ARCH" ]; then ARCH=$(uname -m) fi @@ -23,27 +18,17 @@ if tty -s; then fi cd .. -FLAGS="" +FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')" RUSTFLAGS="" -if [[ "$ENVIRONMENT" =~ (^|-)podman($|-) ]]; then - FLAGS="podman,$FLAGS" -fi -if [[ "$ENVIRONMENT" =~ (^|-)unstable($|-) ]]; then - FLAGS="unstable,$FLAGS" - RUSTFLAGS="$RUSTFLAGS --cfg tokio_unstable" -fi -if [[ "$ENVIRONMENT" =~ (^|-)dev($|-) ]]; then - FLAGS="dev,$FLAGS" -fi -alias 'rust-gnu-builder'='docker run $USE_TTY --rm -e "OS_ARCH=$OS_ARCH" -e "RUSTFLAGS=$RUSTFLAGS" -v "$HOME/.cargo/registry":/usr/local/cargo/registry -v "$(pwd)":/home/rust/src -w /home/rust/src -P start9/rust-arm-cross:aarch64' -alias 'rust-musl-builder'='docker run $USE_TTY --rm -e "OS_ARCH=$OS_ARCH" -v "$HOME/.cargo/registry":/root/.cargo/registry -v "$(pwd)":/home/rust/src -P messense/rust-musl-cross:$ARCH-musl' +alias 'rust-gnu-builder'='docker run $USE_TTY --rm -e "RUSTFLAGS=$RUSTFLAGS" -v "$HOME/.cargo/registry":/usr/local/cargo/registry -v "$(pwd)":/home/rust/src -w /home/rust/src -P start9/rust-arm-cross:aarch64' +alias 'rust-musl-builder'='docker run $USE_TTY --rm -v "$HOME/.cargo/registry":/root/.cargo/registry -v "$(pwd)":/home/rust/src -P messense/rust-musl-cross:$ARCH-musl' set +e fail= -echo "FLAGS=\"$FLAGS\"" +echo "FEATURES=\"$FEATURES\"" echo "RUSTFLAGS=\"$RUSTFLAGS\"" -rust-gnu-builder sh -c "(cd backend && cargo build --release --features avahi-alias,$FLAGS --locked --target=$ARCH-unknown-linux-gnu)" +rust-gnu-builder sh -c "(cd backend && cargo build --release --features avahi-alias,$FEATURES --locked --target=$ARCH-unknown-linux-gnu)" if test $? -ne 0; then fail=true fi diff --git a/backend/install-sdk.sh b/backend/install-sdk.sh index 56edaa3dd..a5d9b31b6 100755 --- a/backend/install-sdk.sh +++ b/backend/install-sdk.sh @@ -11,8 +11,8 @@ fi frontend="../frontend/dist/static" [ -d "$frontend" ] || mkdir -p "$frontend" -if [ -z "$OS_ARCH" ]; then - export OS_ARCH=$(uname -m) +if [ -z "$PLATFORM" ]; then + export PLATFORM=$(uname -m) fi cargo install --path=. --no-default-features --features=js_engine,sdk,cli --locked diff --git a/backend/src/bins/start_deno.rs b/backend/src/bins/start_deno.rs index 1a68decfc..43c97485a 100644 --- a/backend/src/bins/start_deno.rs +++ b/backend/src/bins/start_deno.rs @@ -1,13 +1,9 @@ -use clap::Arg; -use rpc_toolkit::command; -use rpc_toolkit::run_cli; use rpc_toolkit::yajrc::RpcError; +use rpc_toolkit::{command, run_cli, Context}; use serde_json::Value; -use crate::context::CliContext; use crate::procedure::js_scripts::ExecuteArgs; use crate::s9pk::manifest::PackageId; -use crate::util::logger::EmbassyLogger; use crate::util::serde::{display_serializable, parse_stdin_deserializable}; use crate::version::{Current, VersionT}; use crate::Error; @@ -16,6 +12,9 @@ lazy_static::lazy_static! { static ref VERSION_STRING: String = Current::new().semver().to_string(); } +struct DenoContext; +impl Context for DenoContext {} + #[command(subcommands(execute, sandbox))] fn deno_api() -> Result<(), Error> { Ok(()) @@ -103,16 +102,8 @@ fn inner_main() -> Result<(), Error> { command: deno_api, app: app => app .name("StartOS Deno Executor") - .version(&**VERSION_STRING) - .arg( - clap::Arg::with_name("config") - .short('c') - .long("config") - .takes_value(true), - ), - context: matches => { - CliContext::init(matches)? - }, + .version(&**VERSION_STRING), + context: _m => DenoContext, exit: |e: RpcError| { match e.data { Some(Value::String(s)) => eprintln!("{}: {}", e.message, s), diff --git a/backend/src/bins/start_init.rs b/backend/src/bins/start_init.rs index a2b16cf78..0440e0ad6 100644 --- a/backend/src/bins/start_init.rs +++ b/backend/src/bins/start_init.rs @@ -17,7 +17,7 @@ use crate::net::web_server::WebServer; use crate::shutdown::Shutdown; use crate::sound::CHIME; use crate::util::Invoke; -use crate::{Error, ErrorKind, ResultExt, OS_ARCH}; +use crate::{Error, ErrorKind, ResultExt, PLATFORM}; #[instrument(skip_all)] async fn setup_or_init(cfg_path: Option) -> Result, Error> { @@ -30,19 +30,19 @@ async fn setup_or_init(cfg_path: Option) -> Result, Er Command::new("ln") .arg("-sf") - .arg("/usr/lib/embassy/scripts/fake-apt") + .arg("/usr/lib/startos/scripts/fake-apt") .arg("/usr/local/bin/apt") .invoke(crate::ErrorKind::OpenSsh) .await?; Command::new("ln") .arg("-sf") - .arg("/usr/lib/embassy/scripts/fake-apt") + .arg("/usr/lib/startos/scripts/fake-apt") .arg("/usr/local/bin/apt-get") .invoke(crate::ErrorKind::OpenSsh) .await?; Command::new("ln") .arg("-sf") - .arg("/usr/lib/embassy/scripts/fake-apt") + .arg("/usr/lib/startos/scripts/fake-apt") .arg("/usr/local/bin/aptitude") .invoke(crate::ErrorKind::OpenSsh) .await?; @@ -177,7 +177,7 @@ async fn run_script_if_exists>(path: P) { #[instrument(skip_all)] async fn inner_main(cfg_path: Option) -> Result, Error> { - if OS_ARCH == "raspberrypi" && tokio::fs::metadata(STANDBY_MODE_PATH).await.is_ok() { + if &*PLATFORM == "raspberrypi" && tokio::fs::metadata(STANDBY_MODE_PATH).await.is_ok() { tokio::fs::remove_file(STANDBY_MODE_PATH).await?; Command::new("sync").invoke(ErrorKind::Filesystem).await?; crate::sound::SHUTDOWN.play().await?; diff --git a/backend/src/config/spec.rs b/backend/src/config/spec.rs index 35512d47a..09f7ec91e 100644 --- a/backend/src/config/spec.rs +++ b/backend/src/config/spec.rs @@ -1,4 +1,4 @@ -use std::borrow::{Borrow, Cow}; +use std::borrow::{Cow}; use std::collections::{BTreeMap, BTreeSet}; use std::fmt; use std::fmt::Debug; @@ -105,7 +105,7 @@ where rng: &mut R, timeout: &Option, ) -> Result { - self.gen_with(self.default_spec().borrow(), rng, timeout) + self.gen_with(self.default_spec(), rng, timeout) } } diff --git a/backend/src/db/model.rs b/backend/src/db/model.rs index 86c9bbb42..2e8cf1ede 100644 --- a/backend/src/db/model.rs +++ b/backend/src/db/model.rs @@ -4,6 +4,7 @@ use std::sync::Arc; use chrono::{DateTime, Utc}; use emver::VersionRange; +use imbl_value::InternedString; use ipnet::{Ipv4Net, Ipv6Net}; use isocountry::CountryCode; use itertools::Itertools; @@ -23,6 +24,7 @@ use crate::s9pk::manifest::{Manifest, PackageId}; use crate::status::Status; use crate::util::Version; use crate::version::{Current, VersionT}; +use crate::{ARCH, PLATFORM}; #[derive(Debug, Deserialize, Serialize, HasModel)] #[serde(rename_all = "kebab-case")] @@ -38,6 +40,8 @@ impl Database { let lan_address = account.hostname.lan_address().parse().unwrap(); Database { server_info: ServerInfo { + arch: get_arch(), + platform: get_platform(), id: account.server_id.clone(), version: Current::new().semver().into(), hostname: account.hostname.no_dot_host_name(), @@ -87,10 +91,22 @@ impl Database { pub type DatabaseModel = Model; +fn get_arch() -> InternedString { + (*ARCH).into() +} + +fn get_platform() -> InternedString { + (&*PLATFORM).into() +} + #[derive(Debug, Deserialize, Serialize, HasModel)] #[serde(rename_all = "kebab-case")] #[model = "Model"] pub struct ServerInfo { + #[serde(default = "get_arch")] + pub arch: InternedString, + #[serde(default = "get_platform")] + pub platform: InternedString, pub id: String, pub hostname: String, pub version: Version, diff --git a/backend/src/firmware.rs b/backend/src/firmware.rs index 3ffb603fe..708ae2169 100644 --- a/backend/src/firmware.rs +++ b/backend/src/firmware.rs @@ -23,7 +23,7 @@ pub async fn update_firmware() -> Result { if product_name.is_empty() { return Ok(RequiresReboot(false)); } - let firmware_dir = Path::new("/usr/lib/embassy/firmware").join(&product_name); + let firmware_dir = Path::new("/usr/lib/startos/firmware").join(&product_name); if tokio::fs::metadata(&firmware_dir).await.is_ok() { let current_firmware = String::from_utf8( Command::new("dmidecode") diff --git a/backend/src/init.rs b/backend/src/init.rs index b98a23921..fdbc41212 100644 --- a/backend/src/init.rs +++ b/backend/src/init.rs @@ -263,6 +263,9 @@ pub async fn init(cfg: &RpcContextConfig) -> Result { tracing::info!("Mounted Logs"); let tmp_dir = cfg.datadir().join("package-data/tmp"); + if should_rebuild && tokio::fs::metadata(&tmp_dir).await.is_ok() { + tokio::fs::remove_dir_all(&tmp_dir).await?; + } if tokio::fs::metadata(&tmp_dir).await.is_err() { tokio::fs::create_dir_all(&tmp_dir).await?; } @@ -275,9 +278,6 @@ pub async fn init(cfg: &RpcContextConfig) -> Result { .datadir() .join(format!("package-data/tmp/{CONTAINER_TOOL}")); let tmp_docker_exists = tokio::fs::metadata(&tmp_docker).await.is_ok(); - if should_rebuild && tmp_docker_exists { - tokio::fs::remove_dir_all(&tmp_docker).await?; - } if CONTAINER_TOOL == "docker" { Command::new("systemctl") .arg("stop") @@ -309,7 +309,7 @@ pub async fn init(cfg: &RpcContextConfig) -> Result { } tracing::info!("Loading System Docker Images"); - crate::install::load_images("/usr/lib/embassy/system-images").await?; + crate::install::load_images("/usr/lib/startos/system-images").await?; tracing::info!("Loaded System Docker Images"); tracing::info!("Loading Package Docker Images"); diff --git a/backend/src/lib.rs b/backend/src/lib.rs index 986682252..67f34d785 100644 --- a/backend/src/lib.rs +++ b/backend/src/lib.rs @@ -5,12 +5,18 @@ pub const DEFAULT_MARKETPLACE: &str = "https://registry.start9.com"; pub const BUFFER_SIZE: usize = 1024; pub const HOST_IP: [u8; 4] = [172, 18, 0, 1]; pub const TARGET: &str = current_platform::CURRENT_PLATFORM; -pub const OS_ARCH: &str = env!("OS_ARCH"); lazy_static::lazy_static! { pub static ref ARCH: &'static str = { let (arch, _) = TARGET.split_once("-").unwrap(); arch }; + pub static ref PLATFORM: String = { + if let Ok(platform) = std::fs::read_to_string("/usr/lib/startos/PLATFORM.txt") { + platform + } else { + ARCH.to_string() + } + }; } pub mod account; diff --git a/backend/src/logs.rs b/backend/src/logs.rs index baacb2845..26463be35 100644 --- a/backend/src/logs.rs +++ b/backend/src/logs.rs @@ -145,7 +145,7 @@ pub struct JournalctlEntry { #[serde(rename = "__REALTIME_TIMESTAMP")] pub timestamp: String, #[serde(rename = "MESSAGE")] - #[serde(deserialize_with = "deserialize_string_or_utf8_array")] + #[serde(deserialize_with = "deserialize_log_message")] pub message: String, #[serde(rename = "__CURSOR")] pub cursor: String, @@ -164,7 +164,7 @@ impl JournalctlEntry { } } -fn deserialize_string_or_utf8_array<'de, D: serde::de::Deserializer<'de>>( +fn deserialize_log_message<'de, D: serde::de::Deserializer<'de>>( deserializer: D, ) -> std::result::Result { struct Visitor; @@ -177,13 +177,7 @@ fn deserialize_string_or_utf8_array<'de, D: serde::de::Deserializer<'de>>( where E: serde::de::Error, { - Ok(v.to_owned()) - } - fn visit_string(self, v: String) -> Result - where - E: serde::de::Error, - { - Ok(v) + Ok(v.trim().to_owned()) } fn visit_unit(self) -> Result where @@ -201,6 +195,7 @@ fn deserialize_string_or_utf8_array<'de, D: serde::de::Deserializer<'de>>( .flatten() .collect::, _>>()?, ) + .map(|s| s.trim().to_owned()) .map_err(serde::de::Error::custom) } } @@ -374,12 +369,12 @@ pub async fn journalctl( cmd.arg(format!("_COMM={}", SYSTEM_UNIT)); } LogSource::Container(id) => { - #[cfg(feature = "podman")] + #[cfg(not(feature = "docker"))] cmd.arg(format!( "SYSLOG_IDENTIFIER={}", DockerProcedure::container_name(&id, None) )); - #[cfg(not(feature = "podman"))] + #[cfg(feature = "docker")] cmd.arg(format!( "CONTAINER_NAME={}", DockerProcedure::container_name(&id, None) diff --git a/backend/src/procedure/docker.rs b/backend/src/procedure/docker.rs index 79f62039d..92d19d6c2 100644 --- a/backend/src/procedure/docker.rs +++ b/backend/src/procedure/docker.rs @@ -813,7 +813,7 @@ impl LongRunning { socket_path: &Path, ) -> Result { const INIT_EXEC: &str = "/start9/bin/embassy_container_init"; - const BIND_LOCATION: &str = "/usr/lib/embassy/container/"; + const BIND_LOCATION: &str = "/usr/lib/startos/container/"; tracing::trace!("setup_long_running_docker_cmd"); remove_container(container_name, true).await?; diff --git a/backend/src/registry/marketplace.rs b/backend/src/registry/marketplace.rs index 435350240..979733198 100644 --- a/backend/src/registry/marketplace.rs +++ b/backend/src/registry/marketplace.rs @@ -23,7 +23,7 @@ pub fn with_query_params(ctx: RpcContext, mut url: Url) -> Url { "os.compat", &crate::version::Current::new().compat().to_string(), ) - .append_pair("os.arch", crate::OS_ARCH) + .append_pair("os.arch", &*crate::PLATFORM) .append_pair("hardware.arch", &*crate::ARCH) .append_pair("hardware.ram", &ctx.hardware.ram.to_string()); diff --git a/backend/src/shutdown.rs b/backend/src/shutdown.rs index 98465f454..93e5cc3d2 100644 --- a/backend/src/shutdown.rs +++ b/backend/src/shutdown.rs @@ -9,7 +9,7 @@ use crate::init::{STANDBY_MODE_PATH, SYSTEM_REBUILD_PATH}; use crate::sound::SHUTDOWN; use crate::util::docker::CONTAINER_TOOL; use crate::util::{display_none, Invoke}; -use crate::{Error, OS_ARCH}; +use crate::{Error, PLATFORM}; #[derive(Debug, Clone)] pub struct Shutdown { @@ -60,7 +60,7 @@ impl Shutdown { tracing::debug!("{:?}", e); } } - if OS_ARCH != "raspberrypi" || self.restart { + if &*PLATFORM != "raspberrypi" || self.restart { if let Err(e) = SHUTDOWN.play().await { tracing::error!("Error Playing Shutdown Song: {}", e); tracing::debug!("{:?}", e); @@ -68,7 +68,7 @@ impl Shutdown { } }); drop(rt); - if OS_ARCH == "raspberrypi" { + if &*PLATFORM == "raspberrypi" { if !self.restart { std::fs::write(STANDBY_MODE_PATH, "").unwrap(); Command::new("sync").spawn().unwrap().wait().unwrap(); diff --git a/backend/src/update/mod.rs b/backend/src/update/mod.rs index 814a27b1d..4ce57a8d1 100644 --- a/backend/src/update/mod.rs +++ b/backend/src/update/mod.rs @@ -25,7 +25,7 @@ use crate::sound::{ }; use crate::update::latest_information::LatestInformation; use crate::util::Invoke; -use crate::{Error, ErrorKind, ResultExt, OS_ARCH}; +use crate::{Error, ErrorKind, ResultExt, PLATFORM}; mod latest_information; @@ -231,7 +231,7 @@ impl EosUrl { .host_str() .ok_or_else(|| Error::new(eyre!("Could not get host of base"), ErrorKind::ParseUrl))?; let version: &Version = &self.version; - Ok(format!("{host}::{version}/{OS_ARCH}/") + Ok(format!("{host}::{version}/{}/", &*PLATFORM) .parse() .map_err(|_| Error::new(eyre!("Could not parse path"), ErrorKind::ParseUrl))?) } @@ -297,7 +297,7 @@ async fn sync_boot() -> Result<(), Error> { .await? .wait() .await?; - if OS_ARCH != "raspberrypi" { + if &*PLATFORM != "raspberrypi" { let dev_mnt = MountGuard::mount(&Bind::new("/dev"), "/media/embassy/next/dev", ReadWrite).await?; let sys_mnt = diff --git a/backend/src/util/docker.rs b/backend/src/util/docker.rs index e6c4d3db6..fb6bc15f4 100644 --- a/backend/src/util/docker.rs +++ b/backend/src/util/docker.rs @@ -7,14 +7,14 @@ use tokio::process::Command; use crate::util::Invoke; -#[cfg(not(feature = "podman"))] +#[cfg(feature = "docker")] pub const CONTAINER_TOOL: &str = "docker"; -#[cfg(feature = "podman")] +#[cfg(not(feature = "docker"))] pub const CONTAINER_TOOL: &str = "podman"; -#[cfg(not(feature = "podman"))] +#[cfg(feature = "docker")] pub const CONTAINER_DATADIR: &str = "/var/lib/docker"; -#[cfg(feature = "podman")] +#[cfg(not(feature = "docker"))] pub const CONTAINER_DATADIR: &str = "/var/lib/containers"; pub struct DockerImageSha(String); diff --git a/backend/src/version/mod.rs b/backend/src/version/mod.rs index e0651642d..ebc895f8e 100644 --- a/backend/src/version/mod.rs +++ b/backend/src/version/mod.rs @@ -182,8 +182,7 @@ pub async fn init(db: &PatchDb, secrets: &PgPool) -> Result<(), Error> { Ok(()) } -pub const COMMIT_HASH: &str = - git_version::git_version!(args = ["--always", "--abbrev=40", "--dirty=-modified"]); +pub const COMMIT_HASH: &str = include_str!("../../../GIT_HASH.txt"); #[command(rename = "git-info", local, metadata(authenticated = false))] pub fn git_info() -> Result<&'static str, Error> { diff --git a/backend/test/js_action_execute/package-data/scripts/test-package/0.3.0.3/embassy.js b/backend/test/js_action_execute/package-data/scripts/test-package/0.3.0.3/embassy.js index 31734a92d..86565053e 100644 --- a/backend/test/js_action_execute/package-data/scripts/test-package/0.3.0.3/embassy.js +++ b/backend/test/js_action_execute/package-data/scripts/test-package/0.3.0.3/embassy.js @@ -857,7 +857,7 @@ export const action = { }, /** * Created this test because of issue - * https://github.com/Start9Labs/embassy-os/issues/1737 + * https://github.com/Start9Labs/start-os/issues/1737 * which that we couldn't create a dir that was deeply nested, and the parents where * not created yet. Found this out during the migrations, where the parent would die. * @param {*} effects @@ -933,7 +933,7 @@ export const action = { }, /** * Created this test because of issue - * https://github.com/Start9Labs/embassy-os/issues/2121 + * https://github.com/Start9Labs/start-os/issues/2121 * That the empty in the create dies * @param {*} effects * @param {*} _input diff --git a/backend/update-sqlx-data.sh b/backend/update-sqlx-data.sh index 1b00498a2..83ec111f0 100755 --- a/backend/update-sqlx-data.sh +++ b/backend/update-sqlx-data.sh @@ -15,7 +15,7 @@ docker run -d --rm --name=tmp_postgres -e POSTGRES_PASSWORD=password -v $TMP_DIR PG_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' tmp_postgres) DATABASE_URL=postgres://postgres:password@$PG_IP/postgres cargo sqlx migrate run - DATABASE_URL=postgres://postgres:password@$PG_IP/postgres OS_ARCH=$(uname -m) cargo sqlx prepare -- --lib --profile=test + DATABASE_URL=postgres://postgres:password@$PG_IP/postgres PLATFORM=$(uname -m) cargo sqlx prepare -- --lib --profile=test ) docker stop tmp_postgres diff --git a/basename.sh b/basename.sh new file mode 100755 index 000000000..17eb62623 --- /dev/null +++ b/basename.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +cd "$(dirname "${BASH_SOURCE[0]}")" + +PLATFORM=$(if [ -f ./PLATFORM.txt ]; then cat ./PLATFORM.txt; else echo unknown; fi) +VERSION="$(cat ./VERSION.txt)" +GIT_HASH="$(cat ./GIT_HASH.txt)" +if [[ "$GIT_HASH" =~ ^@ ]]; then + GIT_HASH=unknown +else + GIT_HASH="$(echo -n "$GIT_HASH" | head -c 7)" +fi +STARTOS_ENV="$(cat ./ENVIRONMENT.txt)" +VERSION_FULL="${VERSION}-${GIT_HASH}" +if [ -n "$STARTOS_ENV" ]; then + VERSION_FULL="$VERSION_FULL~${STARTOS_ENV}" +fi + +echo -n "startos-${VERSION_FULL}_${PLATFORM}" \ No newline at end of file diff --git a/build-cargo-dep.sh b/build-cargo-dep.sh index f4ad4c951..f3cb8e969 100755 --- a/build-cargo-dep.sh +++ b/build-cargo-dep.sh @@ -4,7 +4,7 @@ set -e shopt -s expand_aliases if [ "$0" != "./build-cargo-dep.sh" ]; then - >&2 echo "Must be run from embassy-os directory" + >&2 echo "Must be run from start-os directory" exit 1 fi diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 000000000..357c0e49f --- /dev/null +++ b/build/.gitignore @@ -0,0 +1,2 @@ +lib/depends +lib/conflicts \ No newline at end of file diff --git a/build/lib/conflicts b/build/dpkg-deps/conflicts similarity index 51% rename from build/lib/conflicts rename to build/dpkg-deps/conflicts index 536950a42..12a2f73b2 100644 --- a/build/lib/conflicts +++ b/build/dpkg-deps/conflicts @@ -1,5 +1,5 @@ -openresolv dhcpcd5 firewalld nginx -nginx-common \ No newline at end of file +nginx-common +openresolv \ No newline at end of file diff --git a/build/lib/depends b/build/dpkg-deps/depends similarity index 88% rename from build/lib/depends rename to build/dpkg-deps/depends index 263a7d65d..a712d4a52 100644 --- a/build/lib/depends +++ b/build/dpkg-deps/depends @@ -6,21 +6,15 @@ bmon btrfs-progs ca-certificates cifs-utils -containerd.io cryptsetup curl dmidecode -docker-ce -docker-ce-cli -docker-compose-plugin dosfstools e2fsprogs ecryptfs-utils exfatprogs flashrom -gdb grub-common -heaptrack htop httpdirfs iotop diff --git a/build/dpkg-deps/docker.depends b/build/dpkg-deps/docker.depends new file mode 100644 index 000000000..dd78be8a1 --- /dev/null +++ b/build/dpkg-deps/docker.depends @@ -0,0 +1,5 @@ ++ containerd.io ++ docker-ce ++ docker-ce-cli ++ docker-compose-plugin +- podman \ No newline at end of file diff --git a/build/dpkg-deps/generate.sh b/build/dpkg-deps/generate.sh new file mode 100755 index 000000000..53a7b87e5 --- /dev/null +++ b/build/dpkg-deps/generate.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -e + +cd "$(dirname "${BASH_SOURCE[0]}")" + +IFS="-" read -ra FEATURES <<< "$ENVIRONMENT" + +feature_file_checker=' +/^#/ { next } +/^\+ [a-z0-9]+$/ { next } +/^- [a-z0-9]+$/ { next } +{ exit 1 } +' + +for type in conflicts depends; do + pkgs=() + for feature in ${FEATURES[@]}; do + file="$feature.$type" + if [ -f $file ]; then + # TODO check for syntax errrors + cat $file | awk "$feature_file_checker" + for pkg in $(cat $file | awk '/^\+/ {print $2}'); do + pkgs+=($pkg) + done + fi + done + for pkg in $(cat $type); do + SKIP= + for feature in ${FEATURES[@]}; do + file="$feature.$type" + if [ -f $file ]; then + if grep "^- $pkg$" $file; then + SKIP=1 + fi + fi + done + if [ -z $SKIP ]; then + pkgs+=($pkg) + fi + done + (IFS=$'\n'; echo "${pkgs[*]}") | sort -u > ../lib/$type +done diff --git a/build/dpkg-deps/unstable.depends b/build/dpkg-deps/unstable.depends new file mode 100644 index 000000000..fe5dee256 --- /dev/null +++ b/build/dpkg-deps/unstable.depends @@ -0,0 +1,2 @@ ++ gdb ++ heaptrack \ No newline at end of file diff --git a/build/lib/motd b/build/lib/motd index 25c83a8a4..5de21ec53 100755 --- a/build/lib/motd +++ b/build/lib/motd @@ -11,8 +11,8 @@ cat << "ASCII" ASCII printf " %s (%s %s)\n" "$(uname -o)" "$(uname -r)" "$(uname -m)" printf " $(start-cli --version | sed 's/StartOS CLI /StartOS v/g') - $(start-cli git-info)" -if [ -n "$(cat /usr/lib/embassy/ENVIRONMENT.txt)" ]; then - printf " ~ $(cat /usr/lib/embassy/ENVIRONMENT.txt)\n" +if [ -n "$(cat /usr/lib/startos/ENVIRONMENT.txt)" ]; then + printf " ~ $(cat /usr/lib/startos/ENVIRONMENT.txt)\n" else printf "\n" fi diff --git a/build/lib/scripts/enable-kiosk b/build/lib/scripts/enable-kiosk index d07fc29b3..ad7cd4bf3 100755 --- a/build/lib/scripts/enable-kiosk +++ b/build/lib/scripts/enable-kiosk @@ -72,7 +72,7 @@ user_pref("messaging-system.rsexperimentloader.enabled", false); user_pref("network.allow-experiments", false); user_pref("network.captive-portal-service.enabled", false); user_pref("network.connectivity-service.enabled", false); -user_pref("network.proxy.autoconfig_url", "file:///usr/lib/embassy/proxy.pac"); +user_pref("network.proxy.autoconfig_url", "file:///usr/lib/startos/proxy.pac"); user_pref("network.proxy.socks_remote_dns", true); user_pref("network.proxy.type", 2); user_pref("signon.rememberSignons", false); @@ -91,11 +91,11 @@ EOT while ! curl "http://localhost" > /dev/null; do sleep 1 done -while ! /usr/lib/embassy/scripts/check-monitor; do +while ! /usr/lib/startos/scripts/check-monitor; do sleep 15 done ( - while /usr/lib/embassy/scripts/check-monitor; do + while /usr/lib/startos/scripts/check-monitor; do sleep 15 done killall firefox-esr diff --git a/build/lib/scripts/fake-apt b/build/lib/scripts/fake-apt index 378320c53..8f23c213a 100755 --- a/build/lib/scripts/fake-apt +++ b/build/lib/scripts/fake-apt @@ -13,7 +13,7 @@ fi >&2 echo ' sudo rm /usr/local/bin/apt' >&2 echo >&2 echo 'Otherwise, what you probably want to do is run:' ->&2 echo ' sudo /usr/lib/embassy/scripts/chroot-and-upgrade' +>&2 echo ' sudo /usr/lib/startos/scripts/chroot-and-upgrade' >&2 echo 'You can run apt in this context to add packages to your system.' >&2 echo 'When you are done with your changes, type "exit" and the device will reboot into a system with the changes applied.' >&2 echo 'This is still NOT RECOMMENDED if you don'"'"'t know what you are doing, but at least isn'"'"'t guaranteed to break things.' diff --git a/build/lib/scripts/persist-apt-install b/build/lib/scripts/persist-apt-install index 3ed5c24b1..974833ca3 100755 --- a/build/lib/scripts/persist-apt-install +++ b/build/lib/scripts/persist-apt-install @@ -14,7 +14,7 @@ while [ -n "$1" ]; do done if [ ${#TO_INSTALL[@]} -ne 0 ]; then -/usr/lib/embassy/scripts/chroot-and-upgrade << EOF +/usr/lib/startos/scripts/chroot-and-upgrade << EOF apt-get update && apt-get install -y ${TO_INSTALL[@]} EOF fi \ No newline at end of file diff --git a/build/raspberrypi/make-image.sh b/build/raspberrypi/make-image.sh index 2c58fc079..3b07cb3a8 100755 --- a/build/raspberrypi/make-image.sh +++ b/build/raspberrypi/make-image.sh @@ -60,12 +60,12 @@ sudo mount `partition_for ${OUTPUT_DEVICE} 2` $TMPDIR sudo mkdir $TMPDIR/boot sudo mount `partition_for ${OUTPUT_DEVICE} 1` $TMPDIR/boot sudo unsquashfs -f -d $TMPDIR startos.raspberrypi.squashfs -REAL_GIT_HASH=$(cat $TMPDIR/usr/lib/embassy/GIT_HASH.txt) -REAL_VERSION=$(cat $TMPDIR/usr/lib/embassy/VERSION.txt) -REAL_ENVIRONMENT=$(cat $TMPDIR/usr/lib/embassy/ENVIRONMENT.txt) -sudo sed -i 's| boot=embassy| init=/usr/lib/embassy/scripts/init_resize\.sh|' $TMPDIR/boot/cmdline.txt +REAL_GIT_HASH=$(cat $TMPDIR/usr/lib/startos/GIT_HASH.txt) +REAL_VERSION=$(cat $TMPDIR/usr/lib/startos/VERSION.txt) +REAL_ENVIRONMENT=$(cat $TMPDIR/usr/lib/startos/ENVIRONMENT.txt) +sudo sed -i 's| boot=embassy| init=/usr/lib/startos/scripts/init_resize\.sh|' $TMPDIR/boot/cmdline.txt sudo cp ./build/raspberrypi/fstab $TMPDIR/etc/ -sudo cp ./build/raspberrypi/init_resize.sh $TMPDIR/usr/lib/embassy/scripts/init_resize.sh +sudo cp ./build/raspberrypi/init_resize.sh $TMPDIR/usr/lib/startos/scripts/init_resize.sh sudo umount $TMPDIR/boot sudo umount $TMPDIR sudo losetup -d $OUTPUT_DEVICE diff --git a/check-git-hash.sh b/check-git-hash.sh index 8c286840d..874dcc8bf 100755 --- a/check-git-hash.sh +++ b/check-git-hash.sh @@ -1,6 +1,10 @@ #!/bin/bash -GIT_HASH="$(git describe --always --abbrev=40 --dirty=-modified)" +if [ "$GIT_BRANCH_AS_HASH" != 1 ]; then + GIT_HASH="$(git describe --always --abbrev=40 --dirty=-modified)" +else + GIT_HASH="@$(git rev-parse --abbrev-ref HEAD)" +fi if ! [ -f ./GIT_HASH.txt ] || [ "$(cat ./GIT_HASH.txt)" != "$GIT_HASH" ]; then echo -n "$GIT_HASH" > ./GIT_HASH.txt diff --git a/check-platform.sh b/check-platform.sh new file mode 100755 index 000000000..aebb0fc5f --- /dev/null +++ b/check-platform.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if ! [ -f ./PLATFORM.txt ] || [ "$(cat ./PLATFORM.txt)" != "$PLATFORM" ] && [ -n "$PLATFORM" ]; then + >&2 echo "Updating PLATFORM.txt to \"$PLATFORM\"" + echo -n "$PLATFORM" > ./PLATFORM.txt +fi + +echo -n ./PLATFORM.txt diff --git a/build/lib/scripts/postinst b/debian/postinst similarity index 81% rename from build/lib/scripts/postinst rename to debian/postinst index 171924a9c..2254e02e1 100755 --- a/build/lib/scripts/postinst +++ b/debian/postinst @@ -8,10 +8,10 @@ fi if [ -f /usr/sbin/grub-probe ]; then mv /usr/sbin/grub-probe /usr/sbin/grub-probe-default - ln -s /usr/lib/embassy/scripts/grub-probe-eos /usr/sbin/grub-probe + ln -s /usr/lib/startos/scripts/grub-probe-eos /usr/sbin/grub-probe fi -cp /usr/lib/embassy/scripts/embassy-initramfs-module /etc/initramfs-tools/scripts/embassy +cp /usr/lib/startos/scripts/embassy-initramfs-module /etc/initramfs-tools/scripts/embassy if ! grep overlay /etc/initramfs-tools/modules > /dev/null; then echo overlay >> /etc/initramfs-tools/modules @@ -46,6 +46,7 @@ dns=systemd-resolved [ifupdown] managed=true EOF +$SYSTEMCTL enable startd.service $SYSTEMCTL enable systemd-resolved.service $SYSTEMCTL enable systemd-networkd-wait-online.service $SYSTEMCTL enable ssh.service @@ -70,20 +71,20 @@ fi sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config sed -i 's/Restart=on-failure/Restart=always/g' /lib/systemd/system/tor@default.service -sed -i 's/ExecStart=\/usr\/bin\/dockerd/ExecStart=\/usr\/bin\/dockerd --exec-opt native.cgroupdriver=systemd/g' /lib/systemd/system/docker.service sed -i '/\(^\|#\)entries-per-entry-group-max=/c\entries-per-entry-group-max=128' /etc/avahi/avahi-daemon.conf sed -i '/\(^\|#\)Storage=/c\Storage=persistent' /etc/systemd/journald.conf sed -i '/\(^\|#\)Compress=/c\Compress=yes' /etc/systemd/journald.conf sed -i '/\(^\|#\)SystemMaxUse=/c\SystemMaxUse=1G' /etc/systemd/journald.conf sed -i '/\(^\|#\)ForwardToSyslog=/c\ForwardToSyslog=no' /etc/systemd/journald.conf sed -i '/^\s*#\?\s*issue_discards\s*=\s*/c\issue_discards = 1' /etc/lvm/lvm.conf -mkdir -p /etc/docker -cat > /etc/docker/daemon.json << EOF -{ - "storage-driver": "overlay2" -} -EOF -podman network create -d bridge --subnet 172.18.0.1/24 --opt com.docker.network.bridge.name=br-start9 start9 + +if cat /usr/lib/startos/ENVIRONMENT.txt | grep '(^|-)docker(-|$)'; then + sed -i 's/ExecStart=\/usr\/bin\/dockerd/ExecStart=\/usr\/bin\/dockerd --exec-opt native.cgroupdriver=systemd/g' /lib/systemd/system/docker.service + mkdir -p /etc/docker + echo '{ "storage-driver": "overlay2" }' > /etc/docker/daemon.json +else + podman network create -d bridge --subnet 172.18.0.1/24 --opt com.docker.network.bridge.name=br-start9 start9 +fi mkdir -p /etc/nginx/ssl # fix to suppress docker warning, fixed in 21.xx release of docker cli: https://github.com/docker/cli/pull/2934 @@ -100,7 +101,7 @@ CookieAuthentication 1 EOF rm -rf /var/lib/tor/* -ln -sf /usr/lib/embassy/scripts/tor-check.sh /usr/bin/tor-check +ln -sf /usr/lib/startos/scripts/tor-check.sh /usr/bin/tor-check echo "fs.inotify.max_user_watches=1048576" > /etc/sysctl.d/97-embassy.conf @@ -113,9 +114,9 @@ dpkg-reconfigure --frontend noninteractive locales groupadd embassy -ln -s /usr/lib/embassy/scripts/dhclient-exit-hook /etc/dhcp/dhclient-exit-hooks.d/embassy +ln -s /usr/lib/startos/scripts/dhclient-exit-hook /etc/dhcp/dhclient-exit-hooks.d/embassy rm -f /etc/motd -ln -sf /usr/lib/embassy/motd /etc/update-motd.d/00-embassy +ln -sf /usr/lib/startos/motd /etc/update-motd.d/00-embassy chmod -x /etc/update-motd.d/* chmod +x /etc/update-motd.d/00-embassy diff --git a/dpkg-build.sh b/dpkg-build.sh new file mode 100755 index 000000000..e8ffdb0ac --- /dev/null +++ b/dpkg-build.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +set -e + +cd "$(dirname "${BASH_SOURCE[0]}")" + +BASENAME=$(./basename.sh) +VERSION=$(cat ./VERSION.txt) +if [ "$PLATFORM" = "x86_64" ] || [ "$PLATFORM" = "x86_64-nonfree" ]; then + DEB_ARCH=amd64 +elif [ "$PLATFORM" = "aarch64" ] || [ "$PLATFORM" = "aarch64-nonfree" ] || [ "$PLATFORM" = "raspberrypi" ]; then + DEB_ARCH=arm64 +else + DEB_ARCH="$PLATFORM" +fi + +rm -rf dpkg-workdir/$BASENAME +mkdir -p dpkg-workdir/$BASENAME + +make install DESTDIR=dpkg-workdir/$BASENAME + +DEPENDS=$(cat dpkg-workdir/$BASENAME/usr/lib/startos/depends | tr $'\n' ',' | sed 's/,,\+/,/g' | sed 's/,$//') +CONFLICTS=$(cat dpkg-workdir/$BASENAME/usr/lib/startos/conflicts | tr $'\n' ',' | sed 's/,,\+/,/g' | sed 's/,$//') + +cp -r debian dpkg-workdir/$BASENAME/DEBIAN +cat > dpkg-workdir/$BASENAME/DEBIAN/control << EOF +Package: startos +Version: ${VERSION} +Section: unknown +Priority: required +Maintainer: Aiden McClelland +Homepage: https://start9.com +Architecture: ${DEB_ARCH} +Multi-Arch: foreign +Depends: ${DEPENDS} +Conflicts: ${CONFLICTS} +Description: StartOS Debian Package +EOF + +cd dpkg-workdir/$BASENAME +find . -type f -not -path "./DEBIAN/*" -exec md5sum {} \; | sort -k 2 | sed 's/\.\/\(.*\)/\1/' > DEBIAN/md5sums +cd ../.. + +cd dpkg-workdir +dpkg-deb --root-owner-group -b $BASENAME +mkdir -p ../results +mv $BASENAME.deb ../results/$BASENAME.deb +rm -rf $BASENAME \ No newline at end of file diff --git a/frontend/config-sample.json b/frontend/config-sample.json index 4d2bd94dd..37d5ea038 100644 --- a/frontend/config-sample.json +++ b/frontend/config-sample.json @@ -1,8 +1,6 @@ { "useMocks": true, "enableWidgets": false, - "packageArch": "aarch64", - "osArch": "raspberrypi", "ui": { "api": { "url": "rpc", diff --git a/frontend/projects/shared/src/types/workspace-config.ts b/frontend/projects/shared/src/types/workspace-config.ts index 8394ac95f..101af40fd 100644 --- a/frontend/projects/shared/src/types/workspace-config.ts +++ b/frontend/projects/shared/src/types/workspace-config.ts @@ -1,6 +1,4 @@ export type WorkspaceConfig = { - packageArch: 'aarch64' | 'x86_64' - osArch: 'aarch64' | 'x86_64' | 'raspberrypi' gitHash: string useMocks: boolean enableWidgets: boolean diff --git a/frontend/projects/ui/src/app/pages/server-routes/server-logs/server-logs.page.html b/frontend/projects/ui/src/app/pages/server-routes/server-logs/server-logs.page.html index e9501c2b9..c41ab6461 100644 --- a/frontend/projects/ui/src/app/pages/server-routes/server-logs/server-logs.page.html +++ b/frontend/projects/ui/src/app/pages/server-routes/server-logs/server-logs.page.html @@ -1,7 +1,7 @@ + +# Build image +./run-local-build.sh +``` + +In order for the build to work properly, you will need debspawn >= 0.5.1, the +build may fail with prior versions. diff --git a/image-recipe/build.sh b/image-recipe/build.sh new file mode 100755 index 000000000..88374ff2b --- /dev/null +++ b/image-recipe/build.sh @@ -0,0 +1,324 @@ +#!/bin/bash +set -e + +MAX_IMG_SECTORS=8388608 # 4GB + +echo "==== StartOS Image Build ====" + +echo "Building for architecture: $IB_TARGET_ARCH" + +base_dir="$(dirname "$(readlink -f "$0")")" +prep_results_dir="$base_dir/images-prep" +if systemd-detect-virt -qc; then + RESULTS_DIR="/srv/artifacts" +else + RESULTS_DIR="$base_dir/results" +fi +echo "Saving results in: $RESULTS_DIR" + +IMAGE_BASENAME=startos-${VERSION_FULL}_${IB_TARGET_PLATFORM} + +mkdir -p $prep_results_dir + +cd $prep_results_dir + +QEMU_ARCH=${IB_TARGET_ARCH} +BOOTLOADERS=grub-efi,syslinux +if [ "$QEMU_ARCH" = 'amd64' ]; then + QEMU_ARCH=x86_64 +elif [ "$QEMU_ARCH" = 'arm64' ]; then + QEMU_ARCH=aarch64 + BOOTLOADERS=grub-efi +fi +NON_FREE= +if [[ "${IB_TARGET_PLATFORM}" =~ -nonfree$ ]] || [ "${IB_TARGET_PLATFORM}" = "raspberrypi" ]; then + NON_FREE=1 +fi +IMAGE_TYPE=iso +if [ "${IB_TARGET_PLATFORM}" = "raspberrypi" ] || [ "${IB_TARGET_PLATFORM}" = "rockchip64" ]; then + IMAGE_TYPE=img +fi + +ARCHIVE_AREAS="main contrib" +if [ "$NON_FREE" = 1 ]; then + if [ "$IB_SUITE" = "bullseye" ]; then + ARCHIVE_AREAS="$ARCHIVE_AREAS non-free" + elif [ "$IB_SUITE" = "bookworm" ]; then + ARCHIVE_AREAS="$ARCHIVE_AREAS non-free-firmware" + fi +fi + +PLATFORM_CONFIG_EXTRAS= +if [ "${IB_TARGET_PLATFORM}" = "raspberrypi" ]; then + PLATFORM_CONFIG_EXTRAS="$PLATFORM_CONFIG_EXTRAS --firmware-binary false" + PLATFORM_CONFIG_EXTRAS="$PLATFORM_CONFIG_EXTRAS --firmware-chroot false" + # BEGIN stupid ugly hack + # The actual name of the package is `raspberrypi-kernel` + # live-build determines thte name of the package for the kernel by combining the `linux-packages` flag, with the `linux-flavours` flag + # the `linux-flavours` flag defaults to the architecture, so there's no way to remove the suffix. + # So we're doing this, cause thank the gods our package name contains a hypen. Cause if it didn't we'd be SOL + PLATFORM_CONFIG_EXTRAS="$PLATFORM_CONFIG_EXTRAS --linux-packages raspberrypi" + PLATFORM_CONFIG_EXTRAS="$PLATFORM_CONFIG_EXTRAS --linux-flavours kernel" + # END stupid ugly hack +elif [ "${IB_TARGET_PLATFORM}" = "rockchip64" ]; then + PLATFORM_CONFIG_EXTRAS="$PLATFORM_CONFIG_EXTRAS --linux-flavours rockchip64" +fi + +cat > /etc/wgetrc << EOF +retry_connrefused = on +tries = 100 +EOF +lb config \ + --iso-application "StartOS v${VERSION_FULL} ${IB_TARGET_ARCH}" \ + --iso-volume "StartOS v${VERSION} ${IB_TARGET_ARCH}" \ + --iso-preparer "START9 LABS; HTTPS://START9.COM" \ + --iso-publisher "START9 LABS; HTTPS://START9.COM" \ + --backports true \ + --bootappend-live "boot=live noautologin" \ + --bootloaders $BOOTLOADERS \ + --mirror-bootstrap "https://deb.debian.org/debian/" \ + --mirror-chroot "https://deb.debian.org/debian/" \ + --mirror-chroot-security "https://security.debian.org/debian-security" \ + -d ${IB_SUITE} \ + -a ${IB_TARGET_ARCH} \ + --bootstrap-qemu-arch ${IB_TARGET_ARCH} \ + --bootstrap-qemu-static /usr/bin/qemu-${QEMU_ARCH}-static \ + --archive-areas "${ARCHIVE_AREAS}" \ + $PLATFORM_CONFIG_EXTRAS + +# Overlays + +mkdir -p config/includes.chroot/deb +cp $base_dir/deb/${IMAGE_BASENAME}.deb config/includes.chroot/deb/ + +if [ "${IB_TARGET_PLATFORM}" = "raspberrypi" ]; then + cp -r $base_dir/raspberrypi/squashfs/* config/includes.chroot/ +fi + +mkdir -p config/includes.chroot/etc +echo start > config/includes.chroot/etc/hostname +cat > config/includes.chroot/etc/hosts << EOT +127.0.0.1 localhost start +::1 localhost start ip6-localhost ip6-loopback +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters +EOT + +# Bootloaders + +rm -rf config/bootloaders +cp -r /usr/share/live/build/bootloaders config/bootloaders + +cat > config/bootloaders/syslinux/syslinux.cfg << EOF +include menu.cfg +default vesamenu.c32 +prompt 0 +timeout 50 +EOF + +cat > config/bootloaders/isolinux/isolinux.cfg << EOF +include menu.cfg +default vesamenu.c32 +prompt 0 +timeout 50 +EOF + +rm config/bootloaders/syslinux_common/splash.svg +cp $base_dir/splash.png config/bootloaders/syslinux_common/splash.png +cp $base_dir/splash.png config/bootloaders/isolinux/splash.png +cp $base_dir/splash.png config/bootloaders/grub-pc/splash.png + +sed -i -e '2i set timeout=5' config/bootloaders/grub-pc/config.cfg + +# Archives + +mkdir -p config/archives + +if [ "${IB_TARGET_PLATFORM}" = "raspberrypi" ]; then + curl -fsSL https://archive.raspberrypi.org/debian/raspberrypi.gpg.key | gpg --dearmor -o config/archives/raspi.key + echo "deb https://archive.raspberrypi.org/debian/ bullseye main" > config/archives/raspi.list +fi + +if [ "${IB_SUITE}" = "bullseye" ]; then + cat > config/archives/backports.pref <<- EOF + Package: * + Pin: release a=bullseye-backports + Pin-Priority: 500 + EOF +fi + +if [ "${IB_TARGET_PLATFORM}" = "rockchip64" ]; then + curl -fsSL https://apt.armbian.com/armbian.key | gpg --dearmor -o config/archives/armbian.key + echo "deb https://apt.armbian.com/ ${IB_SUITE} main" > config/archives/armbian.list +fi + +curl -fsSL https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc > config/archives/tor.key +echo "deb [arch=${IB_TARGET_ARCH} signed-by=/etc/apt/trusted.gpg.d/tor.key.gpg] https://deb.torproject.org/torproject.org ${IB_SUITE} main" > config/archives/tor.list + +curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o config/archives/docker.key +echo "deb [arch=${IB_TARGET_ARCH} signed-by=/etc/apt/trusted.gpg.d/docker.key.gpg] https://download.docker.com/linux/debian ${IB_SUITE} stable" > config/archives/docker.list + +curl -fsSL https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/Debian_Testing/Release.key | gpg --dearmor -o config/archives/podman.key +echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/trusted.gpg.d/podman.key.gpg] https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/Debian_Testing/ /" > config/archives/podman.list + +# Dependencies + +## Base dependencies +dpkg-deb --fsys-tarfile $base_dir/deb/${IMAGE_BASENAME}.deb | tar --to-stdout -xvf - ./usr/lib/startos/depends > config/package-lists/embassy-depends.list.chroot + +## Firmware +if [ "$NON_FREE" = 1 ]; then + echo 'firmware-iwlwifi firmware-misc-nonfree firmware-brcm80211 firmware-realtek firmware-atheros firmware-libertas firmware-amd-graphics' > config/package-lists/nonfree.list.chroot +fi + +if [ "${IB_TARGET_PLATFORM}" = "raspberrypi" ]; then + echo 'raspberrypi-bootloader rpi-update parted' > config/package-lists/bootloader.list.chroot +else + echo 'grub-efi grub2-common' > config/package-lists/bootloader.list.chroot +fi +if [ "${IB_TARGET_ARCH}" = "amd64" ] || [ "${IB_TARGET_ARCH}" = "i386" ]; then + echo 'grub-pc-bin' >> config/package-lists/bootloader.list.chroot +fi + +cat > config/hooks/normal/9000-install-startos.hook.chroot << EOF +#!/bin/bash + +set -e + +apt-get install -y /deb/${IMAGE_BASENAME}.deb +rm -rf /deb + +if [ "${IB_SUITE}" = bookworm ]; then + echo 'deb https://deb.debian.org/debian/ bullseye main' > /etc/apt/sources.list.d/bullseye.list + apt-get update + apt-get install -y postgresql-13 + rm /etc/apt/sources.list.d/bullseye.list + apt-get update +fi + +if [ "${IB_TARGET_PLATFORM}" = "raspberrypi" ]; then + for f in /usr/lib/modules/*; do + v=\${f#/usr/lib/modules/} + echo "Configuring raspi kernel '\$v'" + extract-ikconfig "/usr/lib/modules/\$v/kernel/kernel/configs.ko.xz" > /boot/config-\$v + update-initramfs -c -k \$v + done + ln -sf /usr/bin/pi-beep /usr/local/bin/beep +fi + +useradd --shell /bin/bash -G embassy -m start9 +echo start9:embassy | chpasswd +usermod -aG sudo start9 + +echo "start9 ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee "/etc/sudoers.d/010_start9-nopasswd" + +if [ "${IB_TARGET_PLATFORM}" != "raspberrypi" ]; then + /usr/lib/startos/scripts/enable-kiosk +fi + +if ! [[ "${IB_OS_ENV}" =~ (^|-)dev($|-) ]]; then + passwd -l start9 +fi + +EOF + +SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date '+%s')}" + +lb bootstrap +lb chroot +lb installer +lb binary_chroot +lb chroot_prep install all mode-apt-install-binary mode-archives-chroot +ln -sf /run/systemd/resolve/stub-resolv.conf chroot/chroot/etc/resolv.conf +lb binary_rootfs + +cp $prep_results_dir/binary/live/filesystem.squashfs $RESULTS_DIR/$IMAGE_BASENAME.squashfs + +if [ "${IMAGE_TYPE}" = iso ]; then + + lb binary_manifest + lb binary_package-lists + lb binary_linux-image + lb binary_memtest + lb binary_grub-legacy + lb binary_grub-pc + lb binary_grub_cfg + lb binary_syslinux + lb binary_disk + lb binary_loadlin + lb binary_win32-loader + lb binary_includes + lb binary_grub-efi + lb binary_hooks + lb binary_checksums + find binary -newermt "$(date -d@${SOURCE_DATE_EPOCH} '+%Y-%m-%d %H:%M:%S')" -printf "%y %p\n" -exec touch '{}' -d@${SOURCE_DATE_EPOCH} --no-dereference ';' > binary.modified_timestamps + lb binary_iso + lb binary_onie + lb binary_netboot + lb binary_tar + lb binary_hdd + lb binary_zsync + lb chroot_prep remove all mode-archives-chroot + lb source + + mv $prep_results_dir/live-image-${IB_TARGET_ARCH}.hybrid.iso $RESULTS_DIR/$IMAGE_BASENAME.iso + +elif [ "${IMAGE_TYPE}" = img ]; then + + function partition_for () { + if [[ "$1" =~ [0-9]+$ ]]; then + echo "$1p$2" + else + echo "$1$2" + fi + } + + ROOT_PART_END=7217792 + TARGET_NAME=$prep_results_dir/${IMAGE_BASENAME}.img + TARGET_SIZE=$[($ROOT_PART_END+1)*512] + truncate -s $TARGET_SIZE $TARGET_NAME + ( + echo o + echo x + echo i + echo "0xcb15ae4d" + echo r + echo n + echo p + echo 1 + echo 2048 + echo 526335 + echo t + echo c + echo n + echo p + echo 2 + echo 526336 + echo $ROOT_PART_END + echo a + echo 1 + echo w + ) | fdisk $TARGET_NAME + OUTPUT_DEVICE=$(losetup --show -fP $TARGET_NAME) + mkfs.ext4 `partition_for ${OUTPUT_DEVICE} 2` + mkfs.vfat `partition_for ${OUTPUT_DEVICE} 1` + + TMPDIR=$(mktemp -d) + + mount `partition_for ${OUTPUT_DEVICE} 2` $TMPDIR + mkdir $TMPDIR/boot + mount `partition_for ${OUTPUT_DEVICE} 1` $TMPDIR/boot + unsquashfs -f -d $TMPDIR $prep_results_dir/binary/live/filesystem.squashfs + + if [ "${IB_TARGET_PLATFORM}" = "raspberrypi" ]; then + sed -i 's| boot=embassy| init=/usr/lib/startos/scripts/init_resize\.sh|' $TMPDIR/boot/cmdline.txt + rsync -a $base_dir/raspberrypi/img/ $TMPDIR/ + fi + + umount $TMPDIR/boot + umount $TMPDIR + losetup -d $OUTPUT_DEVICE + + mv $prep_results_dir/${IMAGE_BASENAME}.img $RESULTS_DIR/$IMAGE_BASENAME.iso + +fi \ No newline at end of file diff --git a/image-recipe/prepare.sh b/image-recipe/prepare.sh new file mode 100755 index 000000000..1c6779608 --- /dev/null +++ b/image-recipe/prepare.sh @@ -0,0 +1,24 @@ +#!/bin/sh +set -e +set -x + +export DEBIAN_FRONTEND=noninteractive +apt-get install -yq \ + live-build \ + procps \ + systemd \ + binfmt-support \ + qemu-utils \ + qemu-user-static \ + qemu-system-x86 \ + qemu-system-aarch64 \ + xorriso \ + isolinux \ + ca-certificates \ + curl \ + gpg \ + fdisk \ + dosfstools \ + e2fsprogs \ + squashfs-tools \ + rsync diff --git a/build/raspberrypi/fstab b/image-recipe/raspberrypi/img/etc/fstab similarity index 100% rename from build/raspberrypi/fstab rename to image-recipe/raspberrypi/img/etc/fstab diff --git a/build/raspberrypi/init_resize.sh b/image-recipe/raspberrypi/img/usr/lib/startos/scripts/init_resize.sh similarity index 98% rename from build/raspberrypi/init_resize.sh rename to image-recipe/raspberrypi/img/usr/lib/startos/scripts/init_resize.sh index 401d83978..931649897 100755 --- a/build/raspberrypi/init_resize.sh +++ b/image-recipe/raspberrypi/img/usr/lib/startos/scripts/init_resize.sh @@ -114,7 +114,7 @@ mount / -o remount,ro beep if main; then - sed -i 's| init=/usr/lib/embassy/scripts/init_resize\.sh| boot=embassy|' /boot/cmdline.txt + sed -i 's| init=/usr/lib/startos/scripts/init_resize\.sh| boot=embassy|' /boot/cmdline.txt echo "Resized root filesystem. Rebooting in 5 seconds..." sleep 5 else diff --git a/image-recipe/raspberrypi/squashfs/boot/cmdline.txt b/image-recipe/raspberrypi/squashfs/boot/cmdline.txt new file mode 100644 index 000000000..02de34729 --- /dev/null +++ b/image-recipe/raspberrypi/squashfs/boot/cmdline.txt @@ -0,0 +1 @@ +usb-storage.quirks=152d:0562:u,14cd:121c:u,0781:cfcb:u console=serial0,115200 console=tty1 root=PARTUUID=cb15ae4d-02 rootfstype=ext4 fsck.repair=yes rootwait cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory quiet boot=embassy \ No newline at end of file diff --git a/image-recipe/raspberrypi/squashfs/boot/config.txt b/image-recipe/raspberrypi/squashfs/boot/config.txt new file mode 100644 index 000000000..17bd5dc4e --- /dev/null +++ b/image-recipe/raspberrypi/squashfs/boot/config.txt @@ -0,0 +1,86 @@ +# For more options and information see +# http://rpf.io/configtxt +# Some settings may impact device functionality. See link above for details + +# uncomment if you get no picture on HDMI for a default "safe" mode +#hdmi_safe=1 + +# uncomment the following to adjust overscan. Use positive numbers if console +# goes off screen, and negative if there is too much border +#overscan_left=16 +#overscan_right=16 +#overscan_top=16 +#overscan_bottom=16 + +# uncomment to force a console size. By default it will be display's size minus +# overscan. +#framebuffer_width=1280 +#framebuffer_height=720 + +# uncomment if hdmi display is not detected and composite is being output +#hdmi_force_hotplug=1 + +# uncomment to force a specific HDMI mode (this will force VGA) +#hdmi_group=1 +#hdmi_mode=1 + +# uncomment to force a HDMI mode rather than DVI. This can make audio work in +# DMT (computer monitor) modes +#hdmi_drive=2 + +# uncomment to increase signal to HDMI, if you have interference, blanking, or +# no display +#config_hdmi_boost=4 + +# uncomment for composite PAL +#sdtv_mode=2 + +#uncomment to overclock the arm. 700 MHz is the default. +#arm_freq=800 + +# Uncomment some or all of these to enable the optional hardware interfaces +#dtparam=i2c_arm=on +#dtparam=i2s=on +#dtparam=spi=on + +# Uncomment this to enable infrared communication. +#dtoverlay=gpio-ir,gpio_pin=17 +#dtoverlay=gpio-ir-tx,gpio_pin=18 + +# Additional overlays and parameters are documented /boot/overlays/README + +# Enable audio (loads snd_bcm2835) +dtparam=audio=on + +# Automatically load overlays for detected cameras +camera_auto_detect=1 + +# Automatically load overlays for detected DSI displays +display_auto_detect=1 + +# Enable DRM VC4 V3D driver +dtoverlay=vc4-kms-v3d +max_framebuffers=2 + +# Run in 64-bit mode +arm_64bit=1 + +# Disable compensation for displays with overscan +disable_overscan=1 + +[cm4] +# Enable host mode on the 2711 built-in XHCI USB controller. +# This line should be removed if the legacy DWC2 controller is required +# (e.g. for USB device mode) or if USB support is not required. +otg_mode=1 + +[all] + +[pi4] +# Run as fast as firmware / board allows +arm_boost=1 + +[all] +gpu_mem=16 +dtoverlay=pwm-2chan,disable-bt +initramfs initrd.img-6.1.21-v8+ diff --git a/image-recipe/raspberrypi/squashfs/etc/embassy/config.yaml b/image-recipe/raspberrypi/squashfs/etc/embassy/config.yaml new file mode 100644 index 000000000..7c81ad513 --- /dev/null +++ b/image-recipe/raspberrypi/squashfs/etc/embassy/config.yaml @@ -0,0 +1,6 @@ +os-partitions: + boot: /dev/mmcblk0p1 + root: /dev/mmcblk0p2 +ethernet-interface: end0 +wifi-interface: wlan0 +disable-encryption: true diff --git a/image-recipe/raspberrypi/squashfs/etc/modprobe.d/cfg80211.conf b/image-recipe/raspberrypi/squashfs/etc/modprobe.d/cfg80211.conf new file mode 100644 index 000000000..d2abd4efb --- /dev/null +++ b/image-recipe/raspberrypi/squashfs/etc/modprobe.d/cfg80211.conf @@ -0,0 +1 @@ +options cfg80211 ieee80211_regdom=US diff --git a/image-recipe/raspberrypi/squashfs/usr/bin/extract-ikconfig b/image-recipe/raspberrypi/squashfs/usr/bin/extract-ikconfig new file mode 100755 index 000000000..8df33e7d6 --- /dev/null +++ b/image-recipe/raspberrypi/squashfs/usr/bin/extract-ikconfig @@ -0,0 +1,69 @@ +#!/bin/sh +# ---------------------------------------------------------------------- +# extract-ikconfig - Extract the .config file from a kernel image +# +# This will only work when the kernel was compiled with CONFIG_IKCONFIG. +# +# The obscure use of the "tr" filter is to work around older versions of +# "grep" that report the byte offset of the line instead of the pattern. +# +# (c) 2009,2010 Dick Streefland +# Licensed under the terms of the GNU General Public License. +# ---------------------------------------------------------------------- + +cf1='IKCFG_ST\037\213\010' +cf2='0123456789' + +dump_config() +{ + if pos=`tr "$cf1\n$cf2" "\n$cf2=" < "$1" | grep -abo "^$cf2"` + then + pos=${pos%%:*} + tail -c+$(($pos+8)) "$1" | zcat > $tmp1 2> /dev/null + if [ $? != 1 ] + then # exit status must be 0 or 2 (trailing garbage warning) + cat $tmp1 + exit 0 + fi + fi +} + +try_decompress() +{ + for pos in `tr "$1\n$2" "\n$2=" < "$img" | grep -abo "^$2"` + do + pos=${pos%%:*} + tail -c+$pos "$img" | $3 > $tmp2 2> /dev/null + dump_config $tmp2 + done +} + +# Check invocation: +me=${0##*/} +img=$1 +if [ $# -ne 1 -o ! -s "$img" ] +then + echo "Usage: $me " >&2 + exit 2 +fi + +# Prepare temp files: +tmp1=/tmp/ikconfig$$.1 +tmp2=/tmp/ikconfig$$.2 +trap "rm -f $tmp1 $tmp2" 0 + +# Initial attempt for uncompressed images or objects: +dump_config "$img" + +# That didn't work, so retry after decompression. +try_decompress '\037\213\010' xy gunzip +try_decompress '\3757zXZ\000' abcde unxz +try_decompress 'BZh' xy bunzip2 +try_decompress '\135\0\0\0' xxx unlzma +try_decompress '\211\114\132' xy 'lzop -d' +try_decompress '\002\041\114\030' xyy 'lz4 -d -l' +try_decompress '\050\265\057\375' xxx unzstd + +# Bail out: +echo "$me: Cannot find kernel config." >&2 +exit 1 diff --git a/image-recipe/run-local-build.sh b/image-recipe/run-local-build.sh new file mode 100755 index 000000000..7f7ecd3d4 --- /dev/null +++ b/image-recipe/run-local-build.sh @@ -0,0 +1,88 @@ +#!/bin/bash +set -e + +DEB_PATH="$(realpath $1)" + +cd "$(dirname "${BASH_SOURCE[0]}")"/.. + +BASEDIR="$(pwd -P)" + +VERSION="$(dpkg-deb --fsys-tarfile $DEB_PATH | tar --to-stdout -xvf - ./usr/lib/startos/VERSION.txt)" +GIT_HASH="$(dpkg-deb --fsys-tarfile $DEB_PATH | tar --to-stdout -xvf - ./usr/lib/startos/GIT_HASH.txt)" +if [[ "$GIT_HASH" =~ ^@ ]]; then + GIT_HASH="unknown" +else + GIT_HASH="$(echo -n "$GIT_HASH" | head -c 7)" +fi +STARTOS_ENV="$(dpkg-deb --fsys-tarfile $DEB_PATH | tar --to-stdout -xvf - ./usr/lib/startos/ENVIRONMENT.txt)" +PLATFORM="$(dpkg-deb --fsys-tarfile $DEB_PATH | tar --to-stdout -xvf - ./usr/lib/startos/PLATFORM.txt)" + +if [ -z "$1" ]; then + PLATFORM="$(uname -m)" +fi +if [ "$PLATFORM" = "x86_64" ] || [ "$PLATFORM" = "x86_64-nonfree" ]; then + ARCH=amd64 + QEMU_ARCH=x86_64 +elif [ "$PLATFORM" = "aarch64" ] || [ "$PLATFORM" = "aarch64-nonfree" ] || [ "$PLATFORM" = "raspberrypi" ] || [ "$PLATFORM" = "rockchip64" ]; then + ARCH=arm64 + QEMU_ARCH=aarch64 +else + ARCH="$PLATFORM" + QEMU_ARCH="$PLATFORM" +fi + +SUITE=bookworm + +debspawn list | grep $SUITE || debspawn create $SUITE + +VERSION_FULL="${VERSION}-${GIT_HASH}" +if [ -n "$STARTOS_ENV" ]; then + VERSION_FULL="$VERSION_FULL~${STARTOS_ENV}" +fi + +if [ -z "$DSNAME" ]; then + DSNAME="$SUITE" +fi + +if [ "$QEMU_ARCH" != "$(uname -m)" ]; then + sudo update-binfmts --import qemu-$QEMU_ARCH +fi + +imgbuild_fname="$(mktemp /tmp/exec-mkimage.XXXXXX)" +cat > $imgbuild_fname <4f92?wjaMTu^b5;2@mv~({2msTRvUm*`FJH3IIxf=N<;4 zO1Yx|Ams!A0Tj*wP{8^Y00WBS0dC-q7(@VgqXv}%4A3wGAd2+=Jn%G?$nQ5-Qe+X% zc`o8~ABb8!0oaMl=LFsj_$=mmI%HwIDOiwgq4WFS=55QfY0lW(5JrZvs7~O|ftlYk z$(C0DVqn+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F1*p%FLc`RK5$bO>qm^q`W(s%U(@ubD+8o`RCqiNId+; zqe%hq_~cvfXo9*V{w*=(6R06iIUX0gwMxl2Hag^KnjVr80BypABZZ+O#;730XEsnv z!q9w7E_$}E+M5jSVm*+6ui-Qai)!ON0}OW8C#0&9&og0#c7bphVD%u3ZU${JcsSn^Kcs04u4ELNP69#4&l!dGn~m zHvx#$lXtXN%I!Y!`3un%(Y-heyCtufx2#1fd`C4@9C}$jM2{cNz(suKPx>a015@Cm3D3Qf&jp|#3ms3DPm&smX|P@rgs%PG7;)BL)sSRQ z9+98&#RI7%zYc49%ew!9*V?hKneVG@9^tp?H+I#nWm#})eWaM#l#c4gFg>s;>L zM+-5eMIv8QN>NL0F@oo=X?K3bQSDBtci* z&e&ZXt0`iwq`72kzCi9l&FZUxM+d!+a8lO(-|&g6JQo(vKCOBUnOvFb>{V-IF)}=J zGkk`wAU9Mfsj56EjPOcXO<$%WfU9h&Jalz&4`VoqPIDZlf&RAlz@vufNvpDadVo;^ z*{*14mPhws&nCJZ)(*qpWI_r_X$Bb>;aL7ZR9e>W4#pBXGEC6H+P8t11aO|4N*VR_ zJvTUD+h{pCa=}WP+(o$i{bH)UQ@?=yl4 ziz*E-DN>?~0)7%1@^JjO;g}*F!CXrIk4rKxj9_J^4Zmyuxy~`3qy{Xi1=7Pz-$(Kw z?{+)_{b^SHM5wo6UQCcC%ic^is;hT4u6Kq7mx3!>!%WDw4PNGa9bXttY@YGLkaQ zJASrkPpnHJ@*?n|EQRpI_|Ai{);h^|d}jtboV&2 echo '$OS_ARCH is required' - exit 1 +if [ -z "$ARCH" ]; then + ARCH=$(uname -m) fi if [ "$0" != "./build.sh" ]; then @@ -18,12 +17,10 @@ if tty -s; then USE_TTY="-it" fi -alias 'rust-arm64-musl-builder'='docker run $USE_TTY --rm -e "OS_ARCH=$OS_ARCH" -v "$HOME"/.cargo/registry:/root/.cargo/registry -v "$(pwd)":/home/rust/src messense/rust-musl-cross:aarch64-musl' -alias 'rust-x86_64-musl-builder'='docker run $USE_TTY --rm -e "OS_ARCH=$OS_ARCH" -v "$HOME"/.cargo/registry:/root/.cargo/registry -v "$(pwd)":/home/rust/src messense/rust-musl-cross:x86_64-musl' +alias 'rust-musl-builder'='docker run $USE_TTY --rm -v "$HOME"/.cargo/registry:/root/.cargo/registry -v "$(pwd)":/home/rust/src messense/rust-musl-cross:${ARCH}-musl' cd ../.. -rust-arm64-musl-builder sh -c "(git config --global --add safe.directory '*'; cd system-images/compat && cargo build --release --target=aarch64-unknown-linux-musl --no-default-features)" -rust-x86_64-musl-builder sh -c "(git config --global --add safe.directory '*'; cd system-images/compat && cargo build --release --target=x86_64-unknown-linux-musl --no-default-features)" +rust-musl-builder sh -c "(git config --global --add safe.directory '*'; cd system-images/compat && cargo build --release --target=${ARCH}-unknown-linux-musl --no-default-features)" cd system-images/compat sudo chown -R $USER target