diff --git a/.github/workflows/debian.yaml b/.github/workflows/debian.yaml deleted file mode 100644 index 4a114f7a0..000000000 --- a/.github/workflows/debian.yaml +++ /dev/null @@ -1,63 +0,0 @@ -name: Debian Package - -on: - workflow_call: - workflow_dispatch: - -env: - NODEJS_VERSION: '16.11.0' - ENVIRONMENT: "dev" - -jobs: - dpkg: - name: Build dpkg - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - repository: Start9Labs/embassy-os-deb - - - uses: actions/checkout@v3 - with: - submodules: recursive - path: embassyos-0.3.x - - run: | - cp -r debian embassyos-0.3.x/ - VERSION=0.3.x ./control.sh - cp embassyos-0.3.x/backend/embassyd.service embassyos-0.3.x/debian/embassyos.embassyd.service - cp embassyos-0.3.x/backend/embassy-init.service embassyos-0.3.x/debian/embassyos.embassy-init.service - - - 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/frontend.yaml b/.github/workflows/frontend.yaml index 071f6e00f..239bf0a5a 100644 --- a/.github/workflows/frontend.yaml +++ b/.github/workflows/frontend.yaml @@ -5,7 +5,7 @@ on: workflow_dispatch: env: - NODEJS_VERSION: '16.11.0' + NODEJS_VERSION: '18.15.0' ENVIRONMENT: "dev" jobs: diff --git a/.github/workflows/product.yaml b/.github/workflows/product.yaml deleted file mode 100644 index 40e3aa3fd..000000000 --- a/.github/workflows/product.yaml +++ /dev/null @@ -1,129 +0,0 @@ -name: Build Pipeline - -on: - workflow_dispatch: - push: - branches: - - master - - next - pull_request: - branches: - - master - - next - -env: - ENVIRONMENT: "dev" - -jobs: - compat: - uses: ./.github/workflows/reusable-workflow.yaml - with: - build_command: make system-images/compat/docker-images/aarch64.tar - artifact_name: compat.tar - artifact_path: system-images/compat/docker-images/aarch64.tar - - utils: - uses: ./.github/workflows/reusable-workflow.yaml - with: - build_command: make system-images/utils/docker-images/aarch64.tar - artifact_name: utils.tar - artifact_path: system-images/utils/docker-images/aarch64.tar - - binfmt: - uses: ./.github/workflows/reusable-workflow.yaml - with: - build_command: make system-images/binfmt/docker-images/aarch64.tar - artifact_name: binfmt.tar - artifact_path: system-images/binfmt/docker-images/aarch64.tar - - backend: - uses: ./.github/workflows/backend.yaml - - frontend: - uses: ./.github/workflows/frontend.yaml - - image: - name: Build image - runs-on: ubuntu-latest - timeout-minutes: 60 - needs: [compat,utils,binfmt,backend,frontend] - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Download compat.tar artifact - uses: actions/download-artifact@v3 - with: - name: compat.tar - path: system-images/compat/docker-images/ - - - name: Download utils.tar artifact - uses: actions/download-artifact@v3 - with: - name: utils.tar - path: system-images/utils/docker-images/ - - - name: Download binfmt.tar artifact - uses: actions/download-artifact@v3 - with: - name: binfmt.tar - path: system-images/binfmt/docker-images/ - - - name: Download js_snapshot artifact - uses: actions/download-artifact@v3 - with: - name: js_snapshot - path: libs/js_engine/src/artifacts/ - - - name: Download arm_js_snapshot artifact - uses: actions/download-artifact@v3 - with: - name: arm_js_snapshot - path: libs/js_engine/src/artifacts/ - - - name: Download backend artifact - uses: actions/download-artifact@v3 - with: - name: backend-aarch64 - - - name: 'Extract backend' - run: - tar -mxvf backend-aarch64.tar - - - name: Download frontend artifact - uses: actions/download-artifact@v3 - with: - name: frontend - - - name: Skip frontend build - run: | - mkdir frontend/node_modules - mkdir frontend/dist - mkdir patch-db/client/node_modules - mkdir patch-db/client/dist - - - name: 'Extract frontend' - run: | - tar -mxvf frontend.tar frontend/config.json - tar -mxvf frontend.tar frontend/dist - tar -xvf frontend.tar GIT_HASH.txt - tar -xvf frontend.tar ENVIRONMENT.txt - tar -xvf frontend.tar VERSION.txt - rm frontend.tar - - - name: Cache raspiOS - id: cache-raspios - uses: actions/cache@v3 - with: - path: raspios.img - key: cache-raspios - - - name: Build image - run: | - make V=1 eos_raspberrypi-uninit.img --debug - - - uses: actions/upload-artifact@v3 - with: - name: image - path: eos_raspberrypi-uninit.img diff --git a/.github/workflows/pureos-iso.yaml b/.github/workflows/pureos-iso.yaml deleted file mode 100644 index b04c12f19..000000000 --- a/.github/workflows/pureos-iso.yaml +++ /dev/null @@ -1,70 +0,0 @@ -name: PureOS Based ISO - -on: - workflow_call: - workflow_dispatch: - push: - branches: - - master - - next - pull_request: - branches: - - master - - next - -env: - ENVIRONMENT: "dev" - -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.1-1_all.deb - sha256sum ./debspawn_0.6.1-1_all.deb | grep fb8a3f588438ff9ef51e713ec1d83306db893f0aa97447565e28bbba9c6e90c6 - sudo apt-get install -y ./debspawn_0.6.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/.github/workflows/startos-iso.yaml b/.github/workflows/startos-iso.yaml new file mode 100644 index 000000000..34e4be867 --- /dev/null +++ b/.github/workflows/startos-iso.yaml @@ -0,0 +1,171 @@ +name: Debian-based ISO and SquashFS + +on: + workflow_call: + workflow_dispatch: + inputs: + environment: + type: choice + description: Environment + options: + - "" + - dev + - unstable + - dev-unstable + push: + branches: + - master + - next + pull_request: + branches: + - master + - next + +env: + NODEJS_VERSION: '18.15.0' + ENVIRONMENT: '${{ fromJson(format(''["{0}", ""]'', github.event.inputs.environment || ''dev''))[github.event.inputs.environment == ''''] }}' + +jobs: + dpkg: + name: Build dpkg + strategy: + fail-fast: false + matrix: + platform: [x86_64, x86_64-nonfree, aarch64, aarch64-nonfree, raspberrypi] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + with: + repository: Start9Labs/embassy-os-deb + + - uses: actions/checkout@v3 + with: + submodules: recursive + path: embassyos-0.3.x + - run: | + cp -r debian embassyos-0.3.x/ + VERSION=0.3.x ./control.sh + cp embassyos-0.3.x/backend/embassyd.service embassyos-0.3.x/debian/embassyos.embassyd.service + cp embassyos-0.3.x/backend/embassy-init.service embassyos-0.3.x/debian/embassyos.embassy-init.service + + - 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 \ + 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 build + run: "make VERSION=0.3.x TAG=${{ github.ref_name }}" + env: + OS_ARCH: ${{ matrix.platform }} + + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.platform }}.deb + path: embassyos_0.3.x-1_*.deb + + iso: + name: Build iso + strategy: + fail-fast: false + matrix: + platform: [x86_64, x86_64-nonfree, aarch64, aarch64-nonfree, raspberrypi] + runs-on: ubuntu-22.04 + needs: [dpkg] + steps: + - uses: actions/checkout@v3 + with: + repository: Start9Labs/startos-image-recipes + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y qemu-user-static + wget http://ftp.us.debian.org/debian/pool/main/d/debspawn/debspawn_0.6.1-1_all.deb + sha256sum ./debspawn_0.6.1-1_all.deb | grep fb8a3f588438ff9ef51e713ec1d83306db893f0aa97447565e28bbba9c6e90c6 + sudo apt-get install -y ./debspawn_0.6.1-1_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-bullseye + + - name: Make build container + run: "debspawn list | grep bullseye || debspawn create bullseye" + + - run: "mkdir -p overlays/deb" + + - name: Download dpkg + uses: actions/download-artifact@v3 + with: + name: ${{ matrix.platform }}.deb + path: overlays/deb + + - name: Run build + run: | + ./run-local-build.sh ${{ matrix.platform }} + + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.platform }}.squashfs + path: results/*.squashfs + + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.platform }}.iso + path: results/*.iso + if: ${{ matrix.platform != 'raspberrypi' }} + + image: + name: Build image + runs-on: ubuntu-22.04 + timeout-minutes: 60 + needs: [iso] + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Download raspberrypi.squashfs artifact + uses: actions/download-artifact@v3 + with: + name: raspberrypi.squashfs + + - run: mv *_raspberrypi.squashfs eos.raspberrypi.squashfs + + - name: Build image + run: make eos_raspberrypi.img + + - uses: actions/upload-artifact@v3 + with: + name: raspberrypi.img + path: eos-*_raspberrypi.img diff --git a/Makefile b/Makefile index ab602b173..c90cc76ee 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ -RASPI_TARGETS := eos_raspberrypi-uninit.img eos_raspberrypi-uninit.tar.gz -OS_ARCH := $(shell if echo $(RASPI_TARGETS) | grep -qw "$(MAKECMDGOALS)"; then echo raspberrypi; else uname -m; fi) -ARCH := $(shell if [ "$(OS_ARCH)" = "raspberrypi" ]; then echo aarch64; else echo $(OS_ARCH); fi) +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) @@ -43,12 +42,6 @@ sudo: sudo true clean: - rm -f 2022-01-28-raspios-bullseye-arm64-lite.zip - rm -f raspios.img - rm -f eos_raspberrypi-uninit.img - rm -f eos_raspberrypi-uninit.tar.gz - rm -f ubuntu.img - rm -f product_key.txt rm -f system-images/**/*.tar rm -rf system-images/compat/target rm -rf backend/target @@ -72,17 +65,8 @@ format: sdk: cd backend/ && ./install-sdk.sh -eos_raspberrypi-uninit.img: $(ALL_TARGETS) raspios.img cargo-deps/aarch64-unknown-linux-gnu/release/nc-broadcast cargo-deps/aarch64-unknown-linux-gnu/release/pi-beep | sudo - ! test -f eos_raspberrypi-uninit.img || rm eos_raspberrypi-uninit.img - ./build/raspberry-pi/make-image.sh - -lite-upgrade.img: raspios.img cargo-deps/aarch64-unknown-linux-gnu/release/nc-broadcast cargo-deps/aarch64-unknown-linux-gnu/release/pi-beep $(BUILD_SRC) eos.raspberrypi.squashfs - ! test -f lite-upgrade.img || rm lite-upgrade.img - ./build/raspberry-pi/make-upgrade-image.sh - -eos_raspberrypi.img: raspios.img $(BUILD_SRC) eos.raspberrypi.squashfs $(VERSION_FILE) $(ENVIRONMENT_FILE) $(GIT_HASH_FILE) | sudo - ! test -f eos_raspberrypi.img || rm eos_raspberrypi.img - ./build/raspberry-pi/make-initialized-image.sh +eos_raspberrypi.img: $(BUILD_SRC) eos.raspberrypi.squashfs $(VERSION_FILE) $(ENVIRONMENT_FILE) $(GIT_HASH_FILE) cargo-deps/aarch64-unknown-linux-gnu/release/pi-beep | sudo + ./build/raspberrypi/make-image.sh # For creating os images. DO NOT USE install: $(ALL_TARGETS) @@ -183,7 +167,7 @@ frontend/config.json: $(GIT_HASH_FILE) frontend/config-sample.json npm --prefix frontend run-script build-config 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 + jq '."ack-welcome" = $(shell yq '.version' frontend/package.json)' frontend/patchdb-ui-seed.json > ui-seed.tmp mv ui-seed.tmp frontend/patchdb-ui-seed.json patch-db/client/node_modules: patch-db/client/package.json diff --git a/backend/build-prod.sh b/backend/build-prod.sh index 3f43ca01e..075360e8c 100755 --- a/backend/build-prod.sh +++ b/backend/build-prod.sh @@ -3,6 +3,11 @@ 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 @@ -17,8 +22,8 @@ if tty -s; then USE_TTY="-it" fi -alias 'rust-gnu-builder'='docker run $USE_TTY --rm -v "$HOME/.cargo/registry":/root/.cargo/registry -v "$(pwd)":/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' +alias 'rust-gnu-builder'='docker run $USE_TTY --rm -e "OS_ARCH=$OS_ARCH" -v "$HOME/.cargo/registry":/root/.cargo/registry -v "$(pwd)":/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' cd .. FLAGS="" diff --git a/backend/src/bin/embassy-init.rs b/backend/src/bin/embassy-init.rs index 93cbf5960..d58bf7c80 100644 --- a/backend/src/bin/embassy-init.rs +++ b/backend/src/bin/embassy-init.rs @@ -13,13 +13,26 @@ use embassy::shutdown::Shutdown; use embassy::sound::CHIME; use embassy::util::logger::EmbassyLogger; use embassy::util::Invoke; -use embassy::{Error, ErrorKind, ResultExt, IS_RASPBERRY_PI}; +use embassy::{Error, ErrorKind, ResultExt, OS_ARCH}; use tokio::process::Command; use tracing::instrument; #[instrument(skip_all)] async fn setup_or_init(cfg_path: Option) -> Result<(), Error> { - if tokio::fs::metadata("/cdrom").await.is_ok() { + if tokio::fs::metadata("/run/live/medium").await.is_ok() { + Command::new("sed") + .arg("-i") + .arg("s/PasswordAuthentication no/PasswordAuthentication yes/g") + .arg("/etc/ssh/sshd_config") + .invoke(crate::ErrorKind::Filesystem) + .await?; + Command::new("systemctl") + .arg("reload") + .arg("ssh") + .invoke(crate::ErrorKind::OpenSsh) + .await?; + embassy::hostname::sync_hostname(&embassy::hostname::Hostname("embassy".into())).await?; + let ctx = InstallContext::init(cfg_path).await?; let server = WebServer::install(([0, 0, 0, 0], 80).into(), ctx.clone()).await?; @@ -119,7 +132,7 @@ async fn run_script_if_exists>(path: P) { #[instrument(skip_all)] async fn inner_main(cfg_path: Option) -> Result, Error> { - if *IS_RASPBERRY_PI && tokio::fs::metadata(STANDBY_MODE_PATH).await.is_ok() { + if OS_ARCH == "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?; embassy::sound::SHUTDOWN.play().await?; diff --git a/backend/src/bin/embassyd.rs b/backend/src/bin/embassyd.rs index fdf636c25..ad245e9ca 100644 --- a/backend/src/bin/embassyd.rs +++ b/backend/src/bin/embassyd.rs @@ -25,7 +25,7 @@ async fn inner_main(cfg_path: Option) -> Result, Error ), ) .await?; - embassy::hostname::sync_hostname(&*rpc_ctx.account.read().await).await?; + embassy::hostname::sync_hostname(&rpc_ctx.account.read().await.hostname).await?; let server = WebServer::main(([0, 0, 0, 0], 80).into(), rpc_ctx.clone()).await?; let mut shutdown_recv = rpc_ctx.shutdown.subscribe(); diff --git a/backend/src/disk/mod.rs b/backend/src/disk/mod.rs index 517b2cc6c..485d2570e 100644 --- a/backend/src/disk/mod.rs +++ b/backend/src/disk/mod.rs @@ -22,6 +22,7 @@ pub const REPAIR_DISK_PATH: &str = "/media/embassy/config/repair-disk"; #[serde(rename_all = "kebab-case")] pub struct OsPartitionInfo { pub efi: Option, + pub bios: Option, pub boot: PathBuf, pub root: PathBuf, } @@ -31,6 +32,11 @@ impl OsPartitionInfo { .as_ref() .map(|p| p == logicalname.as_ref()) .unwrap_or(false) + || self + .bios + .as_ref() + .map(|p| p == logicalname.as_ref()) + .unwrap_or(false) || &*self.boot == logicalname.as_ref() || &*self.root == logicalname.as_ref() } diff --git a/backend/src/hostname.rs b/backend/src/hostname.rs index ec5789910..d2004a338 100644 --- a/backend/src/hostname.rs +++ b/backend/src/hostname.rs @@ -65,8 +65,8 @@ pub async fn set_hostname(hostname: &Hostname) -> Result<(), Error> { } #[instrument(skip_all)] -pub async fn sync_hostname(account: &AccountInfo) -> Result<(), Error> { - set_hostname(&account.hostname).await?; +pub async fn sync_hostname(hostname: &Hostname) -> Result<(), Error> { + set_hostname(hostname).await?; Command::new("systemctl") .arg("restart") .arg("avahi-daemon") diff --git a/backend/src/lib.rs b/backend/src/lib.rs index 0e76a6d90..ae445b538 100644 --- a/backend/src/lib.rs +++ b/backend/src/lib.rs @@ -5,14 +5,12 @@ 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 IS_RASPBERRY_PI: bool = { - *ARCH == "aarch64" - }; } pub mod account; diff --git a/backend/src/net/dns.rs b/backend/src/net/dns.rs index ad9736468..a8910f698 100644 --- a/backend/src/net/dns.rs +++ b/backend/src/net/dns.rs @@ -11,6 +11,7 @@ use models::PackageId; use tokio::net::{TcpListener, UdpSocket}; use tokio::process::Command; use tokio::sync::RwLock; +use tracing::instrument; use trust_dns_server::authority::MessageResponseBuilder; use trust_dns_server::client::op::{Header, ResponseCode}; use trust_dns_server::client::rr::{Name, Record, RecordType}; @@ -147,6 +148,7 @@ impl RequestHandler for Resolver { } impl DnsController { + #[instrument(skip_all)] pub async fn init(bind: &[SocketAddr]) -> Result { let services = Arc::new(RwLock::new(BTreeMap::new())); @@ -161,10 +163,16 @@ impl DnsController { ); server.register_socket(UdpSocket::bind(bind).await.with_kind(ErrorKind::Network)?); - Command::new("systemd-resolve") - .arg("--set-dns=127.0.0.1") - .arg("--interface=br-start9") - .arg("--set-domain=embassy") + Command::new("resolvectl") + .arg("dns") + .arg("br-start9") + .arg("127.0.0.1") + .invoke(ErrorKind::Network) + .await?; + Command::new("resolvectl") + .arg("domain") + .arg("br-start9") + .arg("embassy") .invoke(ErrorKind::Network) .await?; diff --git a/backend/src/net/mdns.rs b/backend/src/net/mdns.rs index 1ce2432b0..21054241d 100644 --- a/backend/src/net/mdns.rs +++ b/backend/src/net/mdns.rs @@ -5,6 +5,7 @@ use std::sync::{Arc, Weak}; use color_eyre::eyre::eyre; use tokio::process::{Child, Command}; use tokio::sync::Mutex; +use tracing::instrument; use crate::util::Invoke; use crate::{Error, ResultExt}; @@ -51,6 +52,7 @@ pub struct MdnsControllerInner { } impl MdnsControllerInner { + #[instrument(skip_all)] async fn init() -> Result { let mut res = MdnsControllerInner { alias_cmd: None, @@ -59,6 +61,7 @@ impl MdnsControllerInner { res.sync().await?; Ok(res) } + #[instrument(skip_all)] async fn sync(&mut self) -> Result<(), Error> { if let Some(mut cmd) = self.alias_cmd.take() { cmd.kill().await.with_kind(crate::ErrorKind::Network)?; diff --git a/backend/src/os_install/gpt.rs b/backend/src/os_install/gpt.rs index 414b05ac6..8d69ed83b 100644 --- a/backend/src/os_install/gpt.rs +++ b/backend/src/os_install/gpt.rs @@ -1,3 +1,5 @@ +use std::path::Path; + use color_eyre::eyre::eyre; use gpt::disk::LogicalBlockSize; use gpt::GptConfig; @@ -8,7 +10,7 @@ use crate::os_install::partition_for; use crate::Error; pub async fn partition(disk: &DiskInfo, overwrite: bool) -> Result { - { + let efi = { let disk = disk.clone(); tokio::task::spawn_blocking(move || { let mut device = Box::new( @@ -63,7 +65,19 @@ pub async fn partition(disk: &DiskInfo, overwrite: bool) -> Result Result Result Result, Error> { Command::new("grub-probe-default") .arg("-t") .arg("disk") - .arg("/cdrom") + .arg("/run/live/medium") .invoke(crate::ErrorKind::Grub) .await?, )? @@ -93,13 +93,7 @@ pub fn partition_for(disk: impl AsRef, idx: usize) -> PathBuf { async fn partition(disk: &mut DiskInfo, overwrite: bool) -> Result { let partition_type = match (overwrite, disk.partition_table) { - (true, _) | (_, None) => { - if tokio::fs::metadata("/sys/firmware/efi").await.is_ok() { - PartitionTable::Gpt - } else { - PartitionTable::Mbr - } - } + (true, _) | (_, None) => PartitionTable::Gpt, (_, Some(t)) => t, }; disk.partition_table = Some(partition_type); @@ -188,7 +182,7 @@ pub async fn execute( .arg("-f") .arg("-d") .arg(¤t) - .arg("/cdrom/casper/filesystem.squashfs") + .arg("/run/live/medium/live/filesystem.squashfs") .invoke(crate::ErrorKind::Filesystem) .await?; @@ -223,6 +217,14 @@ pub async fn execute( .invoke(crate::ErrorKind::Systemd) .await?; + Command::new("chroot") + .arg(¤t) + .arg("make-ssl-cert") + .arg("generate-default-snakeoil") + .arg("--force-overwrite") + .invoke(crate::ErrorKind::OpenSsl) + .await?; + Command::new("chroot") .arg(¤t) .arg("ssh-keygen") @@ -230,10 +232,19 @@ pub async fn execute( .invoke(crate::ErrorKind::OpenSsh) .await?; + Command::new("chroot") + .arg(¤t) + .arg("ln") + .arg("-sf") + .arg("/usr/lib/embassy/scripts/fake-apt") + .arg("/usr/local/bin/apt-get") + .invoke(crate::ErrorKind::OpenSsh) + .await?; + let dev = MountGuard::mount(&Bind::new("/dev"), current.join("dev"), ReadWrite).await?; let proc = MountGuard::mount(&Bind::new("/proc"), current.join("proc"), ReadWrite).await?; let sys = MountGuard::mount(&Bind::new("/sys"), current.join("sys"), ReadWrite).await?; - let efivarfs = if let Some(efi) = &part_info.efi { + let efivarfs = if tokio::fs::metadata("/sys/firmware/efi").await.is_ok() { Some( MountGuard::mount( &EfiVarFs, @@ -246,14 +257,9 @@ pub async fn execute( None }; - Command::new("chroot") - .arg(¤t) - .arg("update-grub") - .invoke(crate::ErrorKind::Grub) - .await?; let mut install = Command::new("chroot"); install.arg(¤t).arg("grub-install"); - if part_info.efi.is_none() { + if tokio::fs::metadata("/sys/firmware/efi").await.is_err() { install.arg("--target=i386-pc"); } else { match *ARCH { @@ -267,6 +273,12 @@ pub async fn execute( .invoke(crate::ErrorKind::Grub) .await?; + Command::new("chroot") + .arg(¤t) + .arg("update-grub2") + .invoke(crate::ErrorKind::Grub) + .await?; + dev.unmount(false).await?; if let Some(efivarfs) = efivarfs { efivarfs.unmount(false).await?; diff --git a/backend/src/shutdown.rs b/backend/src/shutdown.rs index 4ee259222..47dc3c432 100644 --- a/backend/src/shutdown.rs +++ b/backend/src/shutdown.rs @@ -8,7 +8,7 @@ use crate::disk::main::export; use crate::init::{STANDBY_MODE_PATH, SYSTEM_REBUILD_PATH}; use crate::sound::SHUTDOWN; use crate::util::{display_none, Invoke}; -use crate::{Error, ErrorKind, IS_RASPBERRY_PI}; +use crate::{Error, ErrorKind, OS_ARCH}; #[derive(Debug, Clone)] pub struct Shutdown { @@ -58,7 +58,7 @@ impl Shutdown { tracing::debug!("{:?}", e); } } - if !*IS_RASPBERRY_PI || self.restart { + if OS_ARCH != "raspberrypi" || self.restart { if let Err(e) = SHUTDOWN.play().await { tracing::error!("Error Playing Shutdown Song: {}", e); tracing::debug!("{:?}", e); @@ -66,7 +66,7 @@ impl Shutdown { } }); drop(rt); - if *IS_RASPBERRY_PI { + if OS_ARCH == "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 f3922e79e..4618d49d5 100644 --- a/backend/src/update/mod.rs +++ b/backend/src/update/mod.rs @@ -26,7 +26,7 @@ use crate::sound::{ use crate::update::latest_information::LatestInformation; use crate::util::Invoke; use crate::version::{Current, VersionT}; -use crate::{Error, ErrorKind, ResultExt, IS_RASPBERRY_PI}; +use crate::{Error, ErrorKind, ResultExt, OS_ARCH}; mod latest_information; @@ -81,16 +81,11 @@ async fn maybe_do_update( marketplace_url: Url, ) -> Result>, Error> { let mut db = ctx.db.handle(); - let arch = if *IS_RASPBERRY_PI { - "raspberrypi" - } else { - *crate::ARCH - }; let latest_version: Version = reqwest::get(format!( "{}/eos/v0/latest?eos-version={}&arch={}", marketplace_url, Current::new().semver(), - arch, + OS_ARCH, )) .await .with_kind(ErrorKind::Network)? @@ -241,12 +236,7 @@ impl EosUrl { .host_str() .ok_or_else(|| Error::new(eyre!("Could not get host of base"), ErrorKind::ParseUrl))?; let version: &Version = &self.version; - let arch = if *IS_RASPBERRY_PI { - "raspberrypi" - } else { - *crate::ARCH - }; - Ok(format!("{host}::{version}/{arch}/") + Ok(format!("{host}::{version}/{OS_ARCH}/") .parse() .map_err(|_| Error::new(eyre!("Could not parse path"), ErrorKind::ParseUrl))?) } @@ -312,7 +302,7 @@ async fn sync_boot() -> Result<(), Error> { .await? .wait() .await?; - if !*IS_RASPBERRY_PI { + if OS_ARCH != "raspberrypi" { let dev_mnt = MountGuard::mount(&Bind::new("/dev"), "/media/embassy/next/dev", ReadWrite).await?; let sys_mnt = @@ -323,7 +313,7 @@ async fn sync_boot() -> Result<(), Error> { MountGuard::mount(&Bind::new("/boot"), "/media/embassy/next/boot", ReadWrite).await?; Command::new("chroot") .arg("/media/embassy/next") - .arg("update-grub") + .arg("update-grub2") .invoke(ErrorKind::MigrationFailed) .await?; boot_mnt.unmount(false).await?; diff --git a/backend/src/version/v0_3_4.rs b/backend/src/version/v0_3_4.rs index 4cff1b01f..40f8c8228 100644 --- a/backend/src/version/v0_3_4.rs +++ b/backend/src/version/v0_3_4.rs @@ -79,7 +79,7 @@ impl VersionT for Version { .unwrap_or_else(generate_hostname); account.server_id = server_info.id; account.save(secrets).await?; - sync_hostname(&account).await?; + sync_hostname(&account.hostname).await?; let parsed_url = Some(COMMUNITY_URL.parse().unwrap()); let mut ui = crate::db::DatabaseModel::new().ui().get_mut(db).await?; diff --git a/build/lib/depends b/build/lib/depends index 46b21caa8..885500e3b 100644 --- a/build/lib/depends +++ b/build/lib/depends @@ -1,35 +1,44 @@ -tor avahi-daemon avahi-utils -iotop +bash-completion +beep bmon -lvm2 -htop -cryptsetup -exfat-utils -sqlite3 -wireless-tools -net-tools -ecryptfs-utils +ca-certificates cifs-utils -samba-common-bin -network-manager -vim -jq -ncdu -postgresql -pgloader -openssh-server +containerd.io +curl +cryptsetup docker-ce docker-ce-cli -containerd.io docker-compose-plugin -beep +dosfstools +e2fsprogs +ecryptfs-utils +exfat-utils +htop httpdirfs +iotop iw -squashfs-tools -rsync -systemd-timesyncd +jq +libavahi-client3 +lvm2 magic-wormhole +ncdu +net-tools +network-manager nyx -bash-completion \ No newline at end of file +openssh-server +pgloader +postgresql +psmisc +rsync +samba-common-bin +sqlite3 +squashfs-tools +systemd +systemd-resolved +systemd-sysv +systemd-timesyncd +tor +vim +wireless-tools diff --git a/build/lib/scripts/install b/build/lib/scripts/install deleted file mode 100755 index 553ca19c0..000000000 --- a/build/lib/scripts/install +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/bash - -set -e - -function partition_for () { - if [[ "$1" =~ [0-9]+$ ]]; then - echo "$1p$2" - else - echo "$1$2" - fi -} - -OSDISK=$1 -if [ -z "$OSDISK" ]; then - >&2 echo "usage: $0 " - exit 1 -fi - -WIFI_IFACE= -for IFACE in $(ls /sys/class/net); do - if [ -d /sys/class/net/$IFACE/wireless ]; then - WIFI_IFACE=$IFACE - break - fi -done - -ETH_IFACE= -for IFACE in $(ls /sys/class/net); do - if ! [ -d /sys/class/net/$IFACE/wireless ] && [ -d /sys/class/net/$IFACE/device ]; then - ETH_IFACE=$IFACE - break - fi -done -if [ -z "$ETH_IFACE" ]; then - >&2 echo 'Could not detect ethernet interface' - exit 1 -fi - -( - echo o # MBR - echo n # New Partition - echo p # Primary - echo 1 # Index #1 - echo # Default Starting Position - echo '+1G' # 1GB - echo t # Change Type - echo 0b # W95 FAT32 - echo a # Set Bootable - echo n # New Partition - echo p # Primary - echo 2 # Index #2 - echo # Default Starting Position - echo '+15G' # 15GB - echo n # New Partition - echo p # Primary - echo 3 # Index #3 - echo # Default Starting Position - echo # Use Full Remaining - echo t # Change Type - echo 3 # (Still Index #3) - echo 8e # Linux LVM - echo w # Write Changes -) | fdisk $OSDISK - -BOOTPART=`partition_for $OSDISK 1` -ROOTPART=`partition_for $OSDISK 2` - -mkfs.vfat $BOOTPART -fatlabel $BOOTPART boot - -mkfs.ext4 $ROOTPART -e2label $ROOTPART rootfs - -mount $ROOTPART /mnt -mkdir /mnt/config -mkdir /mnt/current -mkdir /mnt/next - -mkdir /mnt/current/boot -mount $BOOTPART /mnt/current/boot - -unsquashfs -f -d /mnt/current /cdrom/casper/filesystem.squashfs - -cat > /mnt/config/config.yaml << EOF -os-partitions: - boot: $BOOTPART - root: $ROOTPART -ethernet-interface: $ETH_IFACE -EOF - -if [ -n "$WIFI_IFACE" ]; then - echo "wifi-interface: $WIFI_IFACE" >> /mnt/config/config.yaml -fi - -# gen fstab -cat > /mnt/current/etc/fstab << EOF -$BOOTPART /boot vfat defaults 0 2 -$ROOTPART / ext4 defaults 0 1 -EOF - -# gen machine-id -chroot /mnt/current systemd-machine-id-setup - -# gen ssh host keys -chroot /mnt/current ssh-keygen -A - -mount --bind /dev /mnt/current/dev -mount --bind /sys /mnt/current/sys -mount --bind /proc /mnt/current/proc - -chroot /mnt/current update-grub -chroot /mnt/current grub-install $OSDISK - -umount /mnt/current/dev -umount /mnt/current/sys -umount /mnt/current/proc - -umount /mnt/current/boot - -umount /mnt diff --git a/build/lib/scripts/postinst b/build/lib/scripts/postinst index a999b8c9b..2d3caa351 100755 --- a/build/lib/scripts/postinst +++ b/build/lib/scripts/postinst @@ -29,6 +29,10 @@ ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime # switch to systemd-resolved & network-manager echo "#" > /etc/network/interfaces +if ! [ -f /etc/resolv.conf ]; then + rm -f /etc/resolv.conf + echo "nameserver 8.8.8.8" > /etc/resolv.conf # Google DNS Fallback +fi if ! [ -f /run/systemd/resolve/stub-resolv.conf ]; then mkdir -p /run/systemd/resolve cp /etc/resolv.conf /run/systemd/resolve/stub-resolv.conf @@ -44,6 +48,7 @@ managed=true EOF $SYSTEMCTL enable systemd-resolved.service $SYSTEMCTL enable systemd-networkd-wait-online.service +$SYSTEMCTL enable ssh.service $SYSTEMCTL disable wpa_supplicant.service $SYSTEMCTL disable docker.service @@ -63,6 +68,7 @@ if which gsettings > /dev/null; then gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout '0' 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 diff --git a/build/raspberry-pi/033-upgrade.service b/build/raspberry-pi/033-upgrade.service deleted file mode 100644 index 09affcae4..000000000 --- a/build/raspberry-pi/033-upgrade.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Boot process for system initialization. -After=network-online.target systemd-time-wait-sync.service - -[Service] -Type=oneshot -ExecStart=/usr/local/bin/033-upgrade.sh -RemainAfterExit=true -StandardOutput=append:/var/log/initialization.log - -[Install] -WantedBy=multi-user.target diff --git a/build/raspberry-pi/033-upgrade.sh b/build/raspberry-pi/033-upgrade.sh deleted file mode 100755 index cfe256167..000000000 --- a/build/raspberry-pi/033-upgrade.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash - -set -e - -( - while true; do - beep -r 2 -l 80 -d 20 - sleep 60 - done -) & - -if grep 'cb15ae4d-03' /boot/cmdline.txt; then - echo Transfer files across - e2fsck -f -y /dev/mmcblk0p4 - while ! resize2fs /dev/mmcblk0p4; do - e2fsck -f -y /dev/mmcblk0p4 - done - mkdir -p /media/origin - mkdir -p /media/dest - mount -r /dev/mmcblk0p3 /media/origin - mount -w /dev/mmcblk0p4 /media/dest - rsync -acvAXUH --info=progress2 --delete --force /media/origin/ /media/dest/ - umount /media/origin - umount /media/dest - rm -rf /media/origin - rm -rf /media/dest - - echo Setting up boot to use other partition - sed -i 's/PARTUUID=cb15ae4d-03/PARTUUID=cb15ae4d-04/g' /boot/cmdline.txt - sync - reboot -fi - -mkdir -p /media/root-rw -mkfs.ext4 /dev/mmcblk0p3 -mount /dev/mmcblk0p3 /media/root-rw - -mkdir -p /embassy-os -mount /dev/mmcblk0p2 /embassy-os - -mkdir -p /media/root-rw/config -mkdir -p /media/root-rw/current -mkdir -p /media/root-rw/next -rsync -acvAXUH --info=progress2 /embassy-os/ /media/root-rw/config/ -rsync -acvAXUH --info=progress2 /update/ /media/root-rw/current/ -rsync -acvAXUH --info=progress2 /media/root-rw/current/boot/ /boot/ -cp /etc/machine-id /media/root-rw/current/etc/machine-id -cp /etc/ssh/ssh_host_rsa_key /media/root-rw/current/etc/ssh/ssh_host_rsa_key -cp /etc/ssh/ssh_host_rsa_key.pub /media/root-rw/current/etc/ssh/ssh_host_rsa_key.pub -cp /etc/ssh/ssh_host_ecdsa_key /media/root-rw/current/etc/ssh/ssh_host_ecdsa_key -cp /etc/ssh/ssh_host_ecdsa_key.pub /media/root-rw/current/etc/ssh/ssh_host_ecdsa_key.pub -cp /etc/ssh/ssh_host_ed25519_key /media/root-rw/current/etc/ssh/ssh_host_ed25519_key -cp /etc/ssh/ssh_host_ed25519_key.pub /media/root-rw/current/etc/ssh/ssh_host_ed25519_key.pub - -sync - -umount /embassy-os -umount /media/root-rw - -fatlabel /dev/mmcblk0p1 boot -e2label /dev/mmcblk0p3 rootfs - -( - echo d - echo 1 - echo d - echo 2 - echo n - echo p - echo 1 - echo - echo - echo d - echo 3 - echo d - echo 4 - echo n - echo p - echo 2 - echo - echo - echo t - echo 1 - echo c - echo w -) | fdisk /dev/mmcblk0 - -reboot \ No newline at end of file diff --git a/build/raspberry-pi/init-with-sound.sh b/build/raspberry-pi/init-with-sound.sh deleted file mode 100755 index f6f475ef8..000000000 --- a/build/raspberry-pi/init-with-sound.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -function flatline { - echo -n "0" > /sys/class/pwm/pwmchip0/export - sleep 0.5 - echo -n "2272727" > /sys/class/pwm/pwmchip0/pwm0/period - echo -n "1136364" > /sys/class/pwm/pwmchip0/pwm0/duty_cycle - echo -n "1" > /sys/class/pwm/pwmchip0/pwm0/enable - sleep 30 - echo -n "0" > /sys/class/pwm/pwmchip0/pwm0/enable -} - -initialization.sh -STATUS=$? -if [ $STATUS -ne 0 ]; then - flatline - exit $STATUS -fi \ No newline at end of file diff --git a/build/raspberry-pi/initialization.service b/build/raspberry-pi/initialization.service deleted file mode 100644 index e756eae00..000000000 --- a/build/raspberry-pi/initialization.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Boot process for system initialization. -After=network-online.target systemd-time-wait-sync.service - -[Service] -Type=oneshot -ExecStart=/usr/local/bin/init-with-sound.sh -RemainAfterExit=true -StandardOutput=append:/var/log/initialization.log - -[Install] -WantedBy=multi-user.target diff --git a/build/raspberry-pi/initialization.sh b/build/raspberry-pi/initialization.sh deleted file mode 100755 index 95608a24b..000000000 --- a/build/raspberry-pi/initialization.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash -set -e - -# introduce start9 username and embassy as default password -if ! awk -F: '{ print $1 }' /etc/passwd | grep start9 -then - usermod -l start9 -d /home/start9 -m pi - groupmod --new-name start9 pi - echo start9:embassy | chpasswd -fi - -START=$(date +%s) -while ! ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null; do - >&2 echo "Waiting for internet connection..." - sleep 1 - if [ "$[$START + 60]" -lt $(date +%s) ]; then - >&2 echo "Timed out waiting for internet connection..." - exit 1 - fi -done -echo "Connected to network" - -# Convert all repos to use https:// before apt update -sed -i "s/http:/https:/g" /etc/apt/sources.list /etc/apt/sources.list.d/*.list - -. /usr/lib/embassy/scripts/add-apt-sources - -KERN=$(dpkg -s raspberrypi-kernel | grep Version | awk '{print $2}') -apt-get update - -# TODO remove in 0.4.0 -if [ "$KERN" != "1:1.20221104-1" ]; then - wget https://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/raspberrypi-kernel_1.20221104-1_arm64.deb - sha256sum raspberrypi-kernel_1.20221104-1_arm64.deb | grep 9de9fe61e17eab351b6d4c8ee42d836c16b066f3593a4a9626283df6df718e42 - apt-get install -y --allow-change-held-packages --allow-downgrades ./raspberrypi-kernel_1.20221104-1_arm64.deb - rm ./raspberrypi-kernel_1.20221104-1_arm64.deb -fi -apt-mark hold raspberrypi-bootloader -apt-mark hold raspberrypi-kernel - -apt-get upgrade -y -if [ "$KERN" != "$(dpkg -s raspberrypi-kernel | grep Version | awk '{print $2}')" ]; then - echo "Kernel updated, restarting..." - sync - reboot -fi - -apt-get install -y $(cat /usr/lib/embassy/depends) -apt-get remove --purge -y $(cat /usr/lib/embassy/conflicts) beep -apt-get autoremove -y - -systemctl stop tor - -. /usr/lib/embassy/scripts/postinst - -usermod -aG embassy start9 - -systemctl enable embassyd.service embassy-init.service - -# . /usr/lib/embassy/scripts/enable-kiosk - -sed -i 's/^/usb-storage.quirks=152d:0562:u,14cd:121c:u,0781:cfcb:u /g' /boot/cmdline.txt - -# making that *sudo docker stats* command fulfil its purpose by displaying all metrics -sed -i 's/rootwait quiet.*/rootwait cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory quiet/g' /boot/cmdline.txt - -systemctl disable nc-broadcast.service -systemctl disable initialization.service - -update-initramfs -c -k "$(uname -r)" - -sed -i /boot/config.txt -e "/initramfs.*/d" -echo initramfs "initrd.img-$(uname -r)" >> /boot/config.txt - -sed -i /boot/cmdline.txt -e "s/^/boot=embassy /" - -passwd -l start9 - -sync - -reboot - diff --git a/build/raspberry-pi/make-image.sh b/build/raspberry-pi/make-image.sh deleted file mode 100755 index 19142a9d1..000000000 --- a/build/raspberry-pi/make-image.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -set -e - -function partition_for () { - if [[ "$1" =~ [0-9]+$ ]]; then - echo "$1p$2" - else - echo "$1$2" - fi -} - -TARGET_NAME=eos_raspberrypi-uninit.img -TARGET_SIZE=2400000000 - -cp raspios.img $TARGET_NAME -truncate -s $TARGET_SIZE $TARGET_NAME -( - echo d - echo 2 - echo n - echo p - echo 2 - echo 532480 - echo - echo w -) | sudo fdisk $TARGET_NAME -export OUTPUT_DEVICE=$(sudo losetup --show -fP $TARGET_NAME) -sudo e2fsck -f -y `partition_for ${OUTPUT_DEVICE} 2` -sudo resize2fs `partition_for ${OUTPUT_DEVICE} 2` -./build/raspberry-pi/write-image.sh -sudo e2fsck -f -y `partition_for ${OUTPUT_DEVICE} 2` -sudo resize2fs -M `partition_for ${OUTPUT_DEVICE} 2` -sudo losetup -d $OUTPUT_DEVICE diff --git a/build/raspberry-pi/make-initialized-image.sh b/build/raspberry-pi/make-initialized-image.sh deleted file mode 100755 index 574d2b2f9..000000000 --- a/build/raspberry-pi/make-initialized-image.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash - -set -e - -function partition_for () { - if [[ "$1" =~ [0-9]+$ ]]; then - echo "$1p$2" - else - echo "$1$2" - fi -} - -VERSION=$(cat VERSION.txt) -ENVIRONMENT=$(cat ENVIRONMENT.txt) -GIT_HASH=$(cat GIT_HASH.txt | head -c 7) -DATE=$(date +%Y%m%d) - -VERSION_FULL="$VERSION-$GIT_HASH" - -if [ -n "$ENVIRONMENT" ]; then - VERSION_FULL="$VERSION_FULL~$ENVIRONMENT" -fi - -TARGET_NAME=eos-${VERSION_FULL}-${DATE}_raspberrypi.img -TARGET_SIZE=$[(31116287+1)*512] - -rm -f $TARGET_NAME -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 1050623 - echo t - echo c - echo n - echo p - echo 2 - echo 1050624 - echo 31116287 - echo a - echo 1 - echo w -) | fdisk $TARGET_NAME -OUTPUT_DEVICE=$(sudo losetup --show -fP $TARGET_NAME) -sudo mkfs.ext4 `partition_for ${OUTPUT_DEVICE} 2` -sudo mkfs.vfat `partition_for ${OUTPUT_DEVICE} 1` - -TMPDIR=$(mktemp -d) - -sudo mount `partition_for ${OUTPUT_DEVICE} 2` $TMPDIR -sudo mkdir -p $TMPDIR/config -sudo mkdir -p $TMPDIR/next -sudo mkdir -p $TMPDIR/current/boot -sudo mount `partition_for ${OUTPUT_DEVICE} 1` $TMPDIR/current/boot -sudo unsquashfs -f -d $TMPDIR/current eos.raspberrypi.squashfs -sudo umount $TMPDIR/current/boot -sudo umount $TMPDIR -sudo losetup -d $OUTPUT_DEVICE \ No newline at end of file diff --git a/build/raspberry-pi/make-upgrade-image.sh b/build/raspberry-pi/make-upgrade-image.sh deleted file mode 100755 index 79943e5be..000000000 --- a/build/raspberry-pi/make-upgrade-image.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -set -e - -function partition_for () { - if [[ "$1" =~ [0-9]+$ ]]; then - echo "$1p$2" - else - echo "$1$2" - fi -} - -TARGET_NAME=lite-upgrade.img -TARGET_SIZE=7000000000 - -LOOPDEV=$(sudo losetup --show -fP raspios.img) -sudo cat `partition_for ${LOOPDEV} 2` > $TARGET_NAME -sudo losetup -d $LOOPDEV -truncate -s $TARGET_SIZE $TARGET_NAME -sudo e2fsck -f -y $TARGET_NAME -sudo resize2fs $TARGET_NAME - -TMPDIR=$(mktemp -d) - -sudo mount $TARGET_NAME $TMPDIR/ - -sudo mkdir -p $TMPDIR/update -sudo unsquashfs -f -d $TMPDIR/update eos.raspberrypi.squashfs -sudo cp ./cargo-deps/aarch64-unknown-linux-gnu/release/pi-beep $TMPDIR/usr/local/bin/beep -sudo cp ./build/raspberry-pi/033-upgrade.sh $TMPDIR/usr/local/bin/033-upgrade.sh -sudo cp ./build/raspberry-pi/033-upgrade.service $TMPDIR/etc/systemd/system/033-upgrade.service -sudo ln -s /etc/systemd/system/033-upgrade.service $TMPDIR/etc/systemd/system/multi-user.target.wants/033-upgrade.service -sudo cp ./cargo-deps/aarch64-unknown-linux-gnu/release/nc-broadcast $TMPDIR/usr/local/bin -sudo cp ./build/raspberry-pi/nc-broadcast.service $TMPDIR/etc/systemd/system/nc-broadcast.service -sudo ln -s /etc/systemd/system/nc-broadcast.service $TMPDIR/etc/systemd/system/multi-user.target.wants/nc-broadcast.service - -sudo umount $TMPDIR/ - -sudo e2fsck -f -y $TARGET_NAME -sudo resize2fs -M $TARGET_NAME -BLOCK_INFO=$(sudo dumpe2fs $TARGET_NAME) -BLOCK_COUNT=$(echo "$BLOCK_INFO" | grep "Block count:" | sed 's/Block count:\s\+//g') -BLOCK_SIZE=$(echo "$BLOCK_INFO" | grep "Block size:" | sed 's/Block size:\s\+//g') -FS_SIZE=$[$BLOCK_COUNT*$BLOCK_SIZE] -truncate -s $FS_SIZE $TARGET_NAME \ No newline at end of file diff --git a/build/raspberry-pi/nc-broadcast.service b/build/raspberry-pi/nc-broadcast.service deleted file mode 100644 index 3c6b09eca..000000000 --- a/build/raspberry-pi/nc-broadcast.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Writes initialization logs to network -Requires=initialization.service - -[Service] -Type=oneshot -Restart=on-failure -RestartSec=5s -ExecStart=/usr/local/bin/nc-broadcast --input=/var/log/initialization.log --tee 0.0.0.0:8080 -RemainAfterExit=true - -[Install] -WantedBy=multi-user.target diff --git a/build/raspberry-pi/rip-image.sh b/build/raspberry-pi/rip-image.sh deleted file mode 100755 index 390b7cba7..000000000 --- a/build/raspberry-pi/rip-image.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -set -e - -TMPDIR=$(mktemp -d) - -ROOT_PARTITION=$(readlink -f /dev/disk/by-label/rootfs) -BOOT_PARTITION=$(readlink -f /dev/disk/by-label/boot) - -if [[ "$ROOT_PARTITION" =~ ^/dev/loop ]] || [[ "$BOOT_PARTITION" =~ ^/dev/loop ]]; then - >&2 echo 'You are currently ripping from a loop device.' - >&2 echo 'This is probably a mistake, and usually means you failed to detach a .img file.' - read -p "Continue anyway? [y/N]" -n 1 -r - echo - if ! [[ "$REPLY" =~ ^[Yy]$ ]]; then - exit 1 - fi -fi - -sudo mount $ROOT_PARTITION $TMPDIR/ -sudo mount $BOOT_PARTITION $TMPDIR/current/boot/ -sudo sed -i 's/PARTUUID=[a-f0-9]\+/PARTUUID=cb15ae4d/g' $TMPDIR/current/etc/fstab -sudo sed -i 's/PARTUUID=[a-f0-9]\+/PARTUUID=cb15ae4d/g' $TMPDIR/current/boot/cmdline.txt -rm -f eos.raspberrypi.squashfs -sudo mksquashfs $TMPDIR/current/ eos.raspberrypi.squashfs - -sudo umount $TMPDIR/current/boot/ -sudo umount $TMPDIR/ - -rm -rf $TMPDIR diff --git a/build/raspberry-pi/write-image.sh b/build/raspberry-pi/write-image.sh deleted file mode 100755 index 87b301e59..000000000 --- a/build/raspberry-pi/write-image.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -set -e - -function partition_for () { - if [[ "$1" =~ [0-9]+$ ]]; then - echo "$1p$2" - else - echo "$1$2" - fi -} - -# Mount the boot partition and config -TMPDIR=$(mktemp -d) -sudo mount `partition_for ${OUTPUT_DEVICE} 1` $TMPDIR - -cat $TMPDIR/config.txt | grep -v "dtoverlay=" | sudo tee $TMPDIR/config.txt.tmp > /dev/null -echo "dtoverlay=pwm-2chan,disable-bt" | sudo tee -a $TMPDIR/config.txt.tmp > /dev/null -echo "gpu_mem=16" | sudo tee -a $TMPDIR/config.txt.tmp > /dev/null -sudo mv $TMPDIR/config.txt.tmp $TMPDIR/config.txt -sudo touch $TMPDIR/ssh - -sudo umount $TMPDIR - -sudo mount `partition_for ${OUTPUT_DEVICE} 2` $TMPDIR - -sudo mkdir $TMPDIR/media/embassy/ -sudo ENVIRONMENT=$ENVIRONMENT make V=1 install ARCH=aarch64 OS_ARCH=raspberrypi DESTDIR=$TMPDIR --debug -sudo sed -i 's/raspberrypi/embassy/g' $TMPDIR/etc/hostname -sudo sed -i 's/raspberrypi/embassy/g' $TMPDIR/etc/hosts -sudo cp ./cargo-deps/aarch64-unknown-linux-gnu/release/pi-beep $TMPDIR/usr/local/bin/beep -sudo cp cargo-deps/aarch64-unknown-linux-gnu/release/nc-broadcast $TMPDIR/usr/local/bin -sudo cp backend/*.service $TMPDIR/etc/systemd/system/ -sudo mkdir -p $TMPDIR/etc/embassy -sudo cp build/raspberry-pi/config.yaml $TMPDIR/etc/embassy/config.yaml - -# Make the .ssh directory for UID 1000 user -sudo mkdir -p $TMPDIR/home/$(awk -v val=1000 -F ":" '$3==val{print $1}' $TMPDIR/etc/passwd)/.ssh -sudo mv $TMPDIR/etc/sudoers.d/010_pi-nopasswd $TMPDIR/etc/sudoers.d/010_start9-nopasswd -sudo sed -i 's/pi/start9/g' $TMPDIR/etc/sudoers.d/010_start9-nopasswd -sudo sed -i 's/ pi / start9 /g' $TMPDIR/etc/systemd/system/autologin@.service - -if [[ "$ENVIRONMENT" =~ (^|-)dev($|-) ]]; then - cat ./build/raspberry-pi/initialization.sh | grep -v "passwd -l start9" | sudo tee $TMPDIR/usr/local/bin/initialization.sh > /dev/null - sudo chmod +x $TMPDIR/usr/local/bin/initialization.sh -else - sudo cp ./build/raspberry-pi/initialization.sh $TMPDIR/usr/local/bin -fi -sudo cp ./build/raspberry-pi/init-with-sound.sh $TMPDIR/usr/local/bin - -sudo cp ./build/raspberry-pi/initialization.service $TMPDIR/etc/systemd/system/initialization.service -sudo ln -s /etc/systemd/system/initialization.service $TMPDIR/etc/systemd/system/multi-user.target.wants/initialization.service -sudo cp ./build/raspberry-pi/nc-broadcast.service $TMPDIR/etc/systemd/system/nc-broadcast.service -sudo ln -s /etc/systemd/system/nc-broadcast.service $TMPDIR/etc/systemd/system/multi-user.target.wants/nc-broadcast.service - -sudo umount $TMPDIR diff --git a/build/raspberrypi/cmdline.txt b/build/raspberrypi/cmdline.txt new file mode 100644 index 000000000..430b56802 --- /dev/null +++ b/build/raspberrypi/cmdline.txt @@ -0,0 +1 @@ +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 init=/usr/lib/embassy/scripts/init_resize.sh \ No newline at end of file diff --git a/build/raspberrypi/config.txt b/build/raspberrypi/config.txt new file mode 100644 index 000000000..17bd5dc4e --- /dev/null +++ b/build/raspberrypi/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/build/raspberry-pi/config.yaml b/build/raspberrypi/config.yaml similarity index 76% rename from build/raspberry-pi/config.yaml rename to build/raspberrypi/config.yaml index f512f294c..cd242269f 100644 --- a/build/raspberry-pi/config.yaml +++ b/build/raspberrypi/config.yaml @@ -1,5 +1,5 @@ os-partitions: boot: /dev/mmcblk0p1 root: /dev/mmcblk0p2 -ethernet-interface: eth0 +ethernet-interface: end0 wifi-interface: wlan0 \ No newline at end of file diff --git a/build/raspberrypi/fstab b/build/raspberrypi/fstab new file mode 100644 index 000000000..816b32bcd --- /dev/null +++ b/build/raspberrypi/fstab @@ -0,0 +1,2 @@ +/dev/mmcblk0p1 /boot vfat umask=0077 0 2 +/dev/mmcblk0p2 / ext4 defaults 0 1 diff --git a/build/raspberrypi/init_resize.sh b/build/raspberrypi/init_resize.sh new file mode 100755 index 000000000..b2ec58f86 --- /dev/null +++ b/build/raspberrypi/init_resize.sh @@ -0,0 +1,134 @@ +#!/bin/bash + +get_variables () { + ROOT_PART_DEV=$(findmnt / -o source -n) + ROOT_PART_NAME=$(echo "$ROOT_PART_DEV" | cut -d "/" -f 3) + ROOT_DEV_NAME=$(echo /sys/block/*/"${ROOT_PART_NAME}" | cut -d "/" -f 4) + ROOT_DEV="/dev/${ROOT_DEV_NAME}" + ROOT_PART_NUM=$(cat "/sys/block/${ROOT_DEV_NAME}/${ROOT_PART_NAME}/partition") + + BOOT_PART_DEV=$(findmnt /boot -o source -n) + BOOT_PART_NAME=$(echo "$BOOT_PART_DEV" | cut -d "/" -f 3) + BOOT_DEV_NAME=$(echo /sys/block/*/"${BOOT_PART_NAME}" | cut -d "/" -f 4) + BOOT_PART_NUM=$(cat "/sys/block/${BOOT_DEV_NAME}/${BOOT_PART_NAME}/partition") + + OLD_DISKID=$(fdisk -l "$ROOT_DEV" | sed -n 's/Disk identifier: 0x\([^ ]*\)/\1/p') + + ROOT_DEV_SIZE=$(cat "/sys/block/${ROOT_DEV_NAME}/size") + if [ "$ROOT_DEV_SIZE" -le 67108864 ]; then + TARGET_END=$((ROOT_DEV_SIZE - 1)) + else + TARGET_END=$((33554432 - 1)) + DATA_PART_START=33554432 + DATA_PART_END=$((ROOT_DEV_SIZE - 1)) + fi + + PARTITION_TABLE=$(parted -m "$ROOT_DEV" unit s print | tr -d 's') + + LAST_PART_NUM=$(echo "$PARTITION_TABLE" | tail -n 1 | cut -d ":" -f 1) + + ROOT_PART_LINE=$(echo "$PARTITION_TABLE" | grep -e "^${ROOT_PART_NUM}:") + ROOT_PART_START=$(echo "$ROOT_PART_LINE" | cut -d ":" -f 2) + ROOT_PART_END=$(echo "$ROOT_PART_LINE" | cut -d ":" -f 3) +} + +check_variables () { + if [ "$BOOT_DEV_NAME" != "$ROOT_DEV_NAME" ]; then + FAIL_REASON="Boot and root partitions are on different devices" + return 1 + fi + + if [ "$ROOT_PART_NUM" -ne "$LAST_PART_NUM" ]; then + FAIL_REASON="Root partition should be last partition" + return 1 + fi + + if [ "$ROOT_PART_END" -gt "$TARGET_END" ]; then + FAIL_REASON="Root partition runs past the end of device" + return 1 + fi + + if [ ! -b "$ROOT_DEV" ] || [ ! -b "$ROOT_PART_DEV" ] || [ ! -b "$BOOT_PART_DEV" ] ; then + FAIL_REASON="Could not determine partitions" + return 1 + fi +} + +main () { + get_variables + + if ! check_variables; then + return 1 + fi + +# if [ "$ROOT_PART_END" -eq "$TARGET_END" ]; then +# reboot_pi +# fi + + if ! echo Yes | parted -m --align=optimal "$ROOT_DEV" ---pretend-input-tty u s resizepart "$ROOT_PART_NUM" "$TARGET_END" ; then + FAIL_REASON="Root partition resize failed" + return 1 + fi + + if [ -n "$DATA_PART_START" ]; then + if ! parted -ms --align=optimal "$ROOT_DEV" u s mkpart primary "$DATA_PART_START" "$DATA_PART_END"; then + FAIL_REASON="Data partition creation failed" + return 1 + fi + fi + + ( + echo x + echo i + echo "0xcb15ae4d" + echo r + echo w + ) | fdisk $ROOT_DEV + + mount / -o remount,rw + + resize2fs $ROOT_PART_DEV + + if ! systemd-machine-id-setup; then + FAIL_REASON="systemd-machine-id-setup failed" + return 1 + fi + + if ! make-ssl-cert generate-default-snakeoil --force-overwrite; then + FAIL_REASON="snakeoil cert generation failed" + return 1 + fi + + if ! ssh-keygen -A; then + FAIL_REASON="ssh host key generation failed" + return 1 + fi + + ln -sf /usr/lib/embassy/scripts/fake-apt /usr/local/bin/apt-get + + return 0 +} + +mount -t proc proc /proc +mount -t sysfs sys /sys +mount -t tmpfs tmp /run +mkdir -p /run/systemd +mount /boot +mount / -o remount,ro + +beep + +if main; then + sed -i 's| init=/usr/lib/embassy/scripts/init_resize\.sh| boot=embassy|' /boot/cmdline.txt + echo "Resized root filesystem. Rebooting in 5 seconds..." + sleep 5 +else + echo -e "Could not expand filesystem.\n${FAIL_REASON}" + sleep 5 +fi + +sync + +umount /boot + +reboot -f diff --git a/build/raspberrypi/make-image.sh b/build/raspberrypi/make-image.sh new file mode 100755 index 000000000..7e9128c4c --- /dev/null +++ b/build/raspberrypi/make-image.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +set -e + +function partition_for () { + if [[ "$1" =~ [0-9]+$ ]]; then + echo "$1p$2" + else + echo "$1$2" + fi +} + +VERSION=$(cat VERSION.txt) +ENVIRONMENT=$(cat ENVIRONMENT.txt) +GIT_HASH=$(cat GIT_HASH.txt | head -c 7) +DATE=$(date +%Y%m%d) + +VERSION_FULL="$VERSION-$GIT_HASH" + +if [ -n "$ENVIRONMENT" ]; then + VERSION_FULL="$VERSION_FULL~$ENVIRONMENT" +fi + +TARGET_NAME=eos-${VERSION_FULL}-${DATE}_raspberrypi.img +TARGET_SIZE=$[(6817791+1)*512] + +rm -f $TARGET_NAME +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 6817791 + echo a + echo 1 + echo w +) | fdisk $TARGET_NAME +OUTPUT_DEVICE=$(sudo losetup --show -fP $TARGET_NAME) +sudo mkfs.ext4 `partition_for ${OUTPUT_DEVICE} 2` +sudo mkfs.vfat `partition_for ${OUTPUT_DEVICE} 1` + +TMPDIR=$(mktemp -d) + +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 eos.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 cp ./build/raspberrypi/cmdline.txt $TMPDIR/boot/ +sudo cp ./build/raspberrypi/config.txt $TMPDIR/boot/ +sudo cp ./build/raspberrypi/fstab $TMPDIR/etc/ +sudo mkdir -p $TMPDIR/etc/embassy +sudo cp ./build/raspberrypi/config.yaml $TMPDIR/etc/embassy +sudo cp ./build/raspberrypi/init_resize.sh $TMPDIR//usr/lib/embassy/scripts/init_resize.sh +sudo cp ./cargo-deps/aarch64-unknown-linux-gnu/release/pi-beep $TMPDIR/usr/local/bin/beep +sudo umount $TMPDIR/boot +sudo umount $TMPDIR +sudo losetup -d $OUTPUT_DEVICE + +if [ "$ALLOW_VERSION_MISMATCH" != 1 ]; then + if [ "$(cat GIT_HASH.txt)" != "$REAL_GIT_HASH" ]; then + >&2 echo "eos.raspberrypi.squashfs GIT_HASH.txt mismatch" + exit 1 + fi + if [ "$(cat VERSION.txt)" != "$REAL_VERSION" ]; then + >&2 echo "eos.raspberrypi.squashfs VERSION.txt mismatch" + exit 1 + fi + if [ "$(cat ENVIRONMENT.txt)" != "$REAL_ENVIRONMENT" ]; then + >&2 echo "eos.raspberrypi.squashfs ENVIRONMENT.txt mismatch" + exit 1 + fi +fi \ No newline at end of file diff --git a/check-environment.sh b/check-environment.sh index 0871b39fb..2a8a669cc 100755 --- a/check-environment.sh +++ b/check-environment.sh @@ -1,7 +1,7 @@ #!/bin/bash if ! [ -f ./ENVIRONMENT.txt ] || [ "$(cat ./ENVIRONMENT.txt)" != "$ENVIRONMENT" ]; then - >&2 echo "Updating ENVIRONMENT.txt to $ENVIRONMENT" + >&2 echo "Updating ENVIRONMENT.txt to \"$ENVIRONMENT\"" echo -n "$ENVIRONMENT" > ./ENVIRONMENT.txt fi diff --git a/system-images/compat/build.sh b/system-images/compat/build.sh index 52f07475d..f81cb30b5 100755 --- a/system-images/compat/build.sh +++ b/system-images/compat/build.sh @@ -3,6 +3,11 @@ set -e shopt -s expand_aliases +if [ -z "$OS_ARCH" ]; then + >&2 echo '$OS_ARCH is required' + exit 1 +fi + if [ "$0" != "./build.sh" ]; then >&2 echo "Must be run from compat directory" exit 1 @@ -13,8 +18,8 @@ if tty -s; then USE_TTY="-it" fi -alias 'rust-arm64-musl-builder'='docker run $USE_TTY --rm -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 -v "$HOME"/.cargo/registry:/root/.cargo/registry -v "$(pwd)":/home/rust/src messense/rust-musl-cross:x86_64-musl' +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' 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)"