Skip to content

Commit

Permalink
add clang-devel on the right place
Browse files Browse the repository at this point in the history
  • Loading branch information
korewaChino committed Oct 1, 2023
1 parent b8e5fba commit 3156b59
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
cargo \
systemd-devel \
mkpasswd \
clang-devel \
moby-engine
- name: Set up QEMU
Expand Down
19 changes: 11 additions & 8 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ pub fn run_scripts(scripts: Vec<Script>, chroot: &PathBuf, in_chroot: bool) -> R

info!("Running script: {script}", script = script.name.as_ref().unwrap_or(&"<Untitled>".to_string()));
info!("Script ID: {id}", id = script.id.as_ref().unwrap_or(&"<NULL>".to_string()));


let script_name = format!("script-{}", script.id.as_ref().unwrap_or(&"untitled".to_string()));
// check if data has shebang
if !data.starts_with("#!") {
// if not, add one
Expand All @@ -121,31 +122,33 @@ pub fn run_scripts(scripts: Vec<Script>, chroot: &PathBuf, in_chroot: bool) -> R
}
// write data to chroot
let fpath = if in_chroot {
chroot.join("tmp/script")
chroot.join("tmp").join(&script_name)
} else {
PathBuf::from("katsu-work/tmp-script")
PathBuf::from(format!("katsu-work/{}", &script_name))
};
let mut file = fs::File::create(fpath)?;
file.write_all(data.as_bytes())?;
file.flush()?;
drop(file);


// now add execute bit
if in_chroot {
util::run_with_chroot(&chroot, || -> color_eyre::Result<()> {
cmd_lib::run_cmd!(
chmod +x ${chroot}/tmp/script;
chroot ${chroot} /tmp/script;
rm -f ${chroot}/tmp/script;
chmod +x ${chroot}/tmp/${script_name};
chroot ${chroot} /tmp/${script_name};
rm -f ${chroot}/tmp/${script_name};
)?;
Ok(())
})?;
} else {
// export envar
std::env::set_var("CHROOT", chroot);
cmd_lib::run_cmd!(
chmod +x katsu-work/tmp-script;
/usr/bin/env CHROOT=${chroot} katsu-work/tmp-script;
chmod +x katsu-work/${script_name};
/usr/bin/env CHROOT=${chroot} katsu-work/${script_name};
rm -f katsu-work/${script_name};
)?;
}

Expand Down

0 comments on commit 3156b59

Please sign in to comment.