Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build fixes #2275

Merged
merged 3 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/startos-iso.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ jobs:
with:
name: raspberrypi.squashfs

- run: mv *_raspberrypi.squashfs eos.raspberrypi.squashfs
- run: mv startos-*_raspberrypi.squashfs startos.raspberrypi.squashfs

- name: Build image
run: make eos_raspberrypi.img
run: make startos_raspberrypi.img

- uses: actions/upload-artifact@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ endif

.DELETE_ON_ERROR:

.PHONY: all gzip install clean format sdk snapshots frontends ui backend reflash eos_raspberrypi.img sudo
.PHONY: all gzip install clean format sdk snapshots frontends ui backend reflash startos_raspberrypi.img sudo

all: $(ALL_TARGETS)

Expand Down Expand Up @@ -65,7 +65,7 @@ format:
sdk:
cd backend/ && ./install-sdk.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
startos_raspberrypi.img: $(BUILD_SRC) startos.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
Expand Down
22 changes: 19 additions & 3 deletions backend/src/bin/embassy-init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ use tracing::instrument;

#[instrument(skip_all)]
async fn setup_or_init(cfg_path: Option<PathBuf>) -> Result<(), Error> {
Command::new("ln")
.arg("-sf")
.arg("/usr/lib/embassy/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/local/bin/apt-get")
.invoke(crate::ErrorKind::OpenSsh)
.await?;
Command::new("ln")
.arg("-sf")
.arg("/usr/lib/embassy/scripts/fake-apt")
.arg("/usr/local/bin/aptitude")
.invoke(crate::ErrorKind::OpenSsh)
.await?;

if tokio::fs::metadata("/run/live/medium").await.is_ok() {
Command::new("sed")
.arg("-i")
Expand All @@ -31,7 +50,6 @@ async fn setup_or_init(cfg_path: Option<PathBuf>) -> Result<(), Error> {
.arg("ssh")
.invoke(crate::ErrorKind::OpenSsh)
.await?;
embassy::hostname::sync_hostname(&embassy::hostname::Hostname("start".into())).await?;

let ctx = InstallContext::init(cfg_path).await?;

Expand All @@ -55,8 +73,6 @@ async fn setup_or_init(cfg_path: Option<PathBuf>) -> Result<(), Error> {
.await
.is_err()
{
embassy::hostname::sync_hostname(&embassy::hostname::Hostname("start".into())).await?;

let ctx = SetupContext::init(cfg_path).await?;

let server = WebServer::setup(([0, 0, 0, 0], 80).into(), ctx.clone()).await?;
Expand Down
6 changes: 6 additions & 0 deletions backend/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ pub async fn init(cfg: &RpcContextConfig) -> Result<InitResult, Error> {
.await?;
}

Command::new("make-ssl-cert")
.arg("generate-default-snakeoil")
.arg("--force-overwrite")
.invoke(crate::ErrorKind::OpenSsl)
.await?;

let secret_store = cfg.secret_store().await?;
tracing::info!("Opened Postgres");

Expand Down
19 changes: 0 additions & 19 deletions backend/src/os_install/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,32 +217,13 @@ pub async fn execute(
.invoke(crate::ErrorKind::Systemd)
.await?;

Command::new("chroot")
.arg(&current)
.arg("make-ssl-cert")
.arg("generate-default-snakeoil")
.arg("--force-overwrite")
.invoke(crate::ErrorKind::OpenSsl)
.await?;

Command::new("chroot")
.arg(&current)
.arg("ssh-keygen")
.arg("-A")
.invoke(crate::ErrorKind::OpenSsh)
.await?;

tokio::fs::write(current.join("etc/hostname"), "start\n").await?;

Command::new("chroot")
.arg(&current)
.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?;
Expand Down
8 changes: 2 additions & 6 deletions build/lib/scripts/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if ! [ -f /run/systemd/resolve/stub-resolv.conf ]; then
mkdir -p /run/systemd/resolve
cp /etc/resolv.conf /run/systemd/resolve/stub-resolv.conf
fi
ln -rsf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
cat << EOF > /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile
Expand Down Expand Up @@ -117,8 +117,4 @@ ln -s /usr/lib/embassy/scripts/dhclient-exit-hook /etc/dhcp/dhclient-exit-hooks.
rm -f /etc/motd
ln -sf /usr/lib/embassy/motd /etc/update-motd.d/00-embassy
chmod -x /etc/update-motd.d/*
chmod +x /etc/update-motd.d/00-embassy

ln -sf /usr/lib/embassy/scripts/fake-apt /usr/local/bin/apt
ln -sf /usr/lib/embassy/scripts/fake-apt /usr/local/bin/apt-get
ln -sf /usr/lib/embassy/scripts/fake-apt /usr/local/bin/aptitude
chmod +x /etc/update-motd.d/00-embassy
9 changes: 1 addition & 8 deletions build/raspberrypi/init_resize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,12 @@ main () {
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

echo embassy > /etc/hostname

ln -sf /usr/lib/embassy/scripts/fake-apt /usr/local/bin/apt-get
echo start > /etc/hostname

return 0
}
Expand Down
10 changes: 5 additions & 5 deletions build/raspberrypi/make-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if [ -n "$ENVIRONMENT" ]; then
VERSION_FULL="$VERSION_FULL~$ENVIRONMENT"
fi

TARGET_NAME=eos-${VERSION_FULL}-${DATE}_raspberrypi.img
TARGET_NAME=startos-${VERSION_FULL}-${DATE}_raspberrypi.img
TARGET_SIZE=$[(6817791+1)*512]

rm -f $TARGET_NAME
Expand Down Expand Up @@ -57,7 +57,7 @@ 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
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)
Expand All @@ -74,15 +74,15 @@ 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"
>&2 echo "startos.raspberrypi.squashfs GIT_HASH.txt mismatch"
exit 1
fi
if [ "$(cat VERSION.txt)" != "$REAL_VERSION" ]; then
>&2 echo "eos.raspberrypi.squashfs VERSION.txt mismatch"
>&2 echo "startos.raspberrypi.squashfs VERSION.txt mismatch"
exit 1
fi
if [ "$(cat ENVIRONMENT.txt)" != "$REAL_ENVIRONMENT" ]; then
>&2 echo "eos.raspberrypi.squashfs ENVIRONMENT.txt mismatch"
>&2 echo "startos.raspberrypi.squashfs ENVIRONMENT.txt mismatch"
exit 1
fi
fi