Skip to content

Commit

Permalink
fix some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
korewaChino committed Sep 23, 2023
1 parent be2f174 commit 51bb185
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/arm-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
grub2 \
parted \
util-linux-core \
systemd-container \
grub2-efi \
uboot-images-armv8 \
uboot-tools \
Expand Down
28 changes: 17 additions & 11 deletions src/creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ const DEFAULT_DNF: &str = "dnf5";
const DEFAULT_BOOTLOADER: &str = "limine";
const UBOOT_DATA: &str = "/usr/share/uboot";

#[derive(Debug, Clone)]
pub struct ImageLayout {
pub efi_dev: Option<String>,
pub root_dev: String,
pub boot_dev: String,
}

pub trait ImageCreator {
/// src, dest, required
const EFI_FILES: &'static [(&'static str, &'static str, bool)];
Expand Down Expand Up @@ -168,7 +175,7 @@ pub trait ImageCreator {
self.instpkgs()?;
// self.dracut()?;
// self.rootpw()?;
// self.postinst_script()?;
self.postinst_script()?;

// self.squashfs()?;
// self.liveos()?;
Expand Down Expand Up @@ -314,16 +321,16 @@ pub trait ImageCreator {
let dest = root.join(name);
debug!(?script, ?dest, "Copying postinst script");
std::fs::copy(script, &dest)?;
debug!("Mounting /dev, /proc, /sys");
prepare_chroot(rootname)?;
// debug!("Mounting /dev, /proc, /sys");
// prepare_chroot(rootname)?;
info!(?script, "Running postinst script");
// TODO: use unshare
run!(~"chroot", &rootname, &*format!("/{name}"))
run!(~"unshare","-R", &rootname, &*format!("/{name}"))
.map_err(|e| e.wrap_err("postinst script failed"))?;
debug!(?dest, "Removing postinst script");
std::fs::remove_file(dest)?;
debug!("Unmounting /dev, /proc, /sys");
unmount_chroot(rootname)?;
// debug!("Unmounting /dev, /proc, /sys");
// unmount_chroot(rootname)?;
Ok(())
}
Expand Down Expand Up @@ -396,7 +403,9 @@ pub trait ImageCreator {
info!("Mounting disk image to loop device");
let loop_dev = cmd_lib::run_fun!(losetup -f)?;
// The reason we run this command instead of just losetup -f is
// because rustfmt messes up the formatting of the command
let loop_dev = cmd_lib::run_fun!(bash -c "losetup -f")?;
debug!("Found loop device: {loop_dev:?}");
Expand Down Expand Up @@ -480,10 +489,7 @@ pub trait ImageCreator {
info!("Mounting partitions");
let instroot = &cfg
.instroot
.to_str()
.unwrap_or_default();
let instroot = &cfg.instroot.to_str().unwrap_or_default();
cmd_lib::run_cmd!(
mkdir -p $instroot;
Expand Down
2 changes: 1 addition & 1 deletion tests/init.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -x
set -x
echo init moment
echo "Initializing chroot and repos"

mkdir -p ./etc/yum.repos.d ./etc/dnf

Expand Down
5 changes: 5 additions & 0 deletions tests/katsudon-arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ packages:
- NetworkManager
- mkpasswd
- polkit
- bcm283x-firmware
- bcm283x-overlays
- chrony
- dracut-config-generic
- "@arm-tools"

disk:
bootloader: true
Expand Down
16 changes: 14 additions & 2 deletions tests/postinst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,20 @@ echo defaultyes=True >> /etc/dnf/dnf.conf

systemd-sysusers

cp -P /usr/share/uboot/rpi_3/u-boot.bin /boot/efi/rpi3-u-boot.bin
cp -P /usr/share/uboot/rpi_4/u-boot.bin /boot/efi/rpi4-u-boot.bin
rm -f /var/lib/systemd/random-seed
rm -f /etc/NetworkManager/system-connections/*.nmconnection
dnf -y remove dracut-config-generic

rm -f /etc/machine-id
touch /etc/machine-id

rm -f /var/lib/rpm/__db*

echo "Fixing SELinux labels"

fixfiles -Ra restore
fixfiles -vRa restore


dnf5 up -y # for downloading keys
dnf up -y # for downloading keys

0 comments on commit 51bb185

Please sign in to comment.