Add optional script to transform source after patches, add more recipes

This commit is contained in:
Jeremy Soller 2020-05-21 11:40:08 -06:00
parent 2ea2a056ed
commit 94d85accd3
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
9 changed files with 96 additions and 10 deletions

View File

@ -0,0 +1,14 @@
[source]
git = "https://gitlab.redox-os.org/redox-os/bootloader.git"
[build]
template = "custom"
script = """
ARCH="$(echo "${TARGET}" | cut -d - -f1)"
nasm \
-f bin \
-o "${COOKBOOK_STAGE}/bootloader" \
-D "ARCH_${ARCH}" \
-i"${COOKBOOK_SOURCE}/${ARCH}/" \
"${COOKBOOK_SOURCE}/${ARCH}/disk.asm"
"""

View File

@ -0,0 +1,27 @@
[source]
git = "https://gitlab.redox-os.org/redox-os/drivers.git"
[build]
template = "custom"
script = """
redoxer build --release \
--manifest-path "${COOKBOOK_SOURCE}/Cargo.toml" \
--workspace
mkdir -pv "${COOKBOOK_STAGE}/bin"
find "target/${TARGET}/release" \
-maxdepth 1 \
-executable \
-type f \
-exec cp -v {} "${COOKBOOK_STAGE}/bin/" ';'
mkdir -pv "${COOKBOOK_STAGE}/etc/pcid"
cp -v "${COOKBOOK_SOURCE}/initfs.toml" "${COOKBOOK_STAGE}/etc/pcid/initfs.toml"
mkdir -pv "${COOKBOOK_STAGE}/etc/pcid.d"
find "${COOKBOOK_SOURCE}" -maxdepth 2 -type f -name 'config.toml' | while read conf
do
driver="$(basename "$(dirname "$conf")")"
cp -v "$conf" "${COOKBOOK_STAGE}/etc/pcid.d/$driver.toml"
done
"""

View File

@ -0,0 +1,14 @@
[source]
tar = "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz"
patches = [
"01_redox.patch"
]
[build]
template = "custom"
script = """
COOKBOOK_CONFIGURE_FLAGS+=(
ac_cv_have_decl_program_invocation_name=no
)
cookbook_configure
"""

View File

@ -0,0 +1,5 @@
[source]
tar = "http://ijg.org/files/jpegsrc.v9c.tar.gz"
[build]
template = "configure"

View File

@ -0,0 +1,10 @@
[source]
git = "https://gitlab.redox-os.org/redox-os/liborbital.git"
[build]
template = "custom"
script = """
rsync -av --delete "${COOKBOOK_SOURCE}/" ./
"${COOKBOOK_CARGO}" build --release
"${COOKBOOK_MAKE}" install HOST="${TARGET}" DESTDIR="${COOKBOOK_STAGE}"
"""

View File

@ -0,0 +1,9 @@
[source]
tar = "https://github.com/jedisct1/libsodium/archive/1.0.16.tar.gz"
patches = [
"random.patch"
]
script = "./autogen.sh"
[build]
template = "configure"

View File

@ -5,20 +5,16 @@ patches = [
"02-o_noctty.patch",
"03-no-signals.patch"
]
script = """
./autogen.sh
chmod +w build-aux/config.sub
wget -O build-aux/config.sub http://git.savannah.gnu.org/cgit/config.git/plain/config.sub
"""
[build]
template = "custom"
script = """
#TODO: simpler recipe
rsync -av --delete "${COOKBOOK_SOURCE}/" ./
./autogen.sh
chmod +w build-aux/config.sub
wget -O build-aux/config.sub http://git.savannah.gnu.org/cgit/config.git/plain/config.sub
export CFLAGS="-static"
COOKBOOK_CONFIGURE="./configure"
COOKBOOK_CONFIGURE_FLAGS=(
--host="${TARGET}"
--prefix=""

View File

@ -173,7 +173,7 @@ fn fetch(recipe_dir: &Path, source: &SourceRecipe) -> Result<PathBuf, String> {
command.arg("submodule").arg("update").arg("--init").arg("--recursive");
run_command(command)?;
},
SourceRecipe::Tar { tar, blake3, sha256, patches } => {
SourceRecipe::Tar { tar, blake3, sha256, patches, script } => {
if ! source_dir.is_dir() {
// Download tar
//TODO: replace wget
@ -266,6 +266,14 @@ fn fetch(recipe_dir: &Path, source: &SourceRecipe) -> Result<PathBuf, String> {
run_command_stdin(command, patch.as_bytes())?;
}
// Run source script
if let Some(script) = script {
let mut command = Command::new("bash");
command.arg("-ex");
command.current_dir(&source_dir_tmp);
run_command_stdin(command, script.as_bytes())?;
}
// Move source.tmp to source atomically
rename(&source_dir_tmp, &source_dir)?;
}

View File

@ -29,6 +29,8 @@ pub enum SourceRecipe {
/// A list of patch files to apply to the source
#[serde(default)]
patches: Vec<String>,
/// Optional script to run to prepare the source, such as ./autogen.sh
script: Option<String>,
},
}
@ -129,6 +131,7 @@ mod tests {
blake3: None,
sha256: Some("4f3fc6178a533d392064f14776b23c397ed4b9f48f5de297aba73b643f955c08".to_string()),
patches: Vec::new(),
script: None,
},
build: BuildRecipe {
kind: BuildKind::Custom {