Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • fabiao/cookbook
  • redox-os/cookbook
  • stratact/cookbook
  • carrot93/cookbook
  • microcolonel/cookbook
  • feliwir/cookbook
  • xTibor/cookbook
  • jD91mZM2/cookbook
  • mpajkowski/cookbook
  • rw_van/cookbook
  • athei/cookbook
  • kblobr/cookbook
  • VitalyAnkh/cookbook
  • sajattack/cookbook
  • sainath14/cookbook
  • ackxolotl/cookbook
  • AdminXVII/cookbook
  • coolreader18/cookbook
  • deepaksirone/cookbook
  • smckay/cookbook
  • 4lDO2/cookbook
  • tomasritter/cookbook
  • alfredoyang/cookbook
  • samuela/cookbook
  • andrewdavidmackenzie/cookbook
  • uuuvn/cookbook
  • josh_williams/cookbook
  • bjorn3/cookbook
  • ids1024/cookbook
  • Chocimier/cookbook
  • bpisch/cookbook
  • willnode/cookbook
  • grnmeira/cookbook
  • andrey.turkin/cookbook
  • cameronbraid/cookbook
  • kamirr/cookbook
  • freewilll/cookbook
  • kivimango/cookbook
  • rukai/cookbook
  • mattmadeofpasta/cookbook
  • jordan_mccallum/cookbook
  • dahc/cookbook
  • Forest0923/cookbook
  • LLeny/cookbook
  • doriancodes/cookbook
  • ashton/cookbook
  • gmacd/cookbook
  • mojo/cookbook
  • wt/cookbook
  • red15/cookbook
  • hasheddan/cookbook
  • dimymark/cookbook
  • andypython/cookbook
  • enygmator/cookbook
  • Ivan/cookbook
  • argslc/cookbook
  • adi-g15/cookbook
  • tfinnegan937/cookbook
  • raffaeleragni/cookbook
  • Lekkit/cookbook
  • bitstr0m/cookbook
  • josh/cookbook
  • zhaozhao/cookbook
  • blueskyson/cookbook
  • Xunjin/cookbook
  • StaringAtEditor/cookbook
66 results
Show changes
Showing with 304 additions and 88 deletions
......@@ -24,6 +24,7 @@ dependencies = [
"zlib",
]
script = """
DYNAMIC_INIT
export CFLAGS="${CFLAGS} -I${COOKBOOK_SYSROOT}/include -I${COOKBOOK_SYSROOT}/include/SDL2"
export CXXFLAGS="${CXXFLAGS} -I${COOKBOOK_SYSROOT}/include -I${COOKBOOK_SYSROOT}/include/SDL2"
......@@ -77,3 +78,12 @@ COOKBOOK_CONFIGURE_FLAGS=(
mkdir -pv "${COOKBOOK_STAGE}/usr/bin"
cp -v love "${COOKBOOK_STAGE}/usr/bin/love"
"""
[package]
shared-deps = [
"libgcc",
"liborbital",
"libpng",
"luajit",
"zlib",
]
#TODO not compiled or tested
[source]
git = "https://github.com/TornaxO7/vibe"
[build]
template = "cargo"
dependencies = [
"libxkbcommon",
"libwayland",
"libalsa",
]
#TODO maybe wrong template
# build instructions - https://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=INSTALL;h=a2427e072bcaf951addc3e1db1fccccf44f3b59b;hb=HEAD
[source]
tar = "http://www.alsa-project.org/files/pub/lib/alsa-lib-1.2.13.tar.bz2"
[build]
template = "configure"
......@@ -2,7 +2,7 @@
[source]
tar = "https://openal-soft.org/openal-releases/openal-soft-1.24.1.tar.bz2"
blake3 = "8aeaa8307d3e14331ad20761c537ffebe70975cb7c3343e8d5c0c0ed7bc16eab"
patch = [
patches = [
"redox.patch"
]
......
......@@ -4,7 +4,7 @@ tar = "https://github.com/libsndfile/libsndfile/releases/download/1.2.0/libsndfi
[build]
template = "configure"
dependencies = [
"libflac",
#TODO "libflac",
"libogg",
"libvorbis",
]
#TODO missing script for gradlew
#TODO determine the dependencies
[source]
git = "https://github.com/hamza-algohary/Coulomb"
rev = "6617d4817dd153ae5e5645d427cdb746c146ccee"
[build]
template = "custom"
#TODO not compiled or tested
[source]
git = "https://github.com/bragefuglseth/fretboard"
[build]
template = "cargo"
dependencies = [
"gtk4",
"libadwaita",
]
#TODO not compiled or tested
[source]
git = "https://github.com/bragefuglseth/keypunch"
[build]
template = "cargo"
dependencies = [
"gtk4",
"libadwaita",
]
#TODO not compiled or tested
# build instructions - https://github.com/flxzt/rnote/blob/main/BUILDING.md#build-with-meson
[source]
git = "https://github.com/flxzt/rnote"
[build]
template = "custom"
dependencies = [
"glib",
"libadwaita",
"glib",
"libalsa",
"libpoppler",
]
script = """
cookbook_cargo_packages rnote
"""
#TODO missing script for go
#TODO determine dependencies
# build instructions - https://gitlab.com/imatt-foss/clipqr#build
[source]
git = "https://gitlab.com/imatt-foss/clipqr"
rev = "400a98c302aead3f2b1b81ec6dc45d654c8bf209"
[build]
template = "custom"
......@@ -27,6 +27,9 @@ then
recipes="$(target/release/list_recipes)"
fi
# All $recipes that are in the new TOML format.
toml_recipes=""
for recipe in $recipes
do
recipe_path=`target/release/find_recipe $recipe`
......@@ -39,6 +42,7 @@ do
if [ -e "${COOKBOOK_RECIPE}/recipe.toml" ]
then
toml_recipes+=" $recipe"
target/release/cook "$recipe"
continue
fi
......@@ -89,6 +93,16 @@ mkdir -p "$REPO"
APPSTREAM_SOURCES=()
# Currently, we only support runtime dependencies for recipes in the new TOML
# format. Runtime dependencies include both `[package.dependencies]` and
# [`package.shared_deps`].
#
# The following adds the package dependencies of the recipes to the repo as
# well.
#
# TODO(?): All of this script can be moved into `cook.rs`.
recipes="$recipes $(target/release/runtime_deps_of $toml_recipes)"
for recipe in $recipes
do
recipe_path=`target/release/find_recipe $recipe`
......
use cookbook::blake3::blake3_progress;
use cookbook::recipe::{BuildKind, PackageRecipe, Recipe, SourceRecipe};
use cookbook::recipe::{BuildKind, CookRecipe, PackageRecipe, Recipe, SourceRecipe};
use cookbook::recipe_find::recipe_find;
use std::{
env, fs,
......@@ -14,7 +14,11 @@ use walkdir::{DirEntry, WalkDir};
fn should_build_shared() -> bool {
use std::sync::OnceLock;
static YES: OnceLock<bool> = OnceLock::new();
*YES.get_or_init(|| env::var("COOKBOOK_PREFER_STATIC").expect("COOKBOOK_PREFER_STATIC").is_empty())
*YES.get_or_init(|| {
env::var("COOKBOOK_PREFER_STATIC")
.expect("COOKBOOK_PREFER_STATIC")
.is_empty()
})
}
fn remove_all(path: &Path) -> Result<(), String> {
......@@ -52,6 +56,11 @@ fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()>
Ok(())
}
fn symlink(original: impl AsRef<Path>, link: impl AsRef<Path>) -> Result<(), String> {
std::os::unix::fs::symlink(&original, &link)
.map_err(|err| format!("failed to symlink '{}' to '{}': {}\n{:?}", original.as_ref().display(), link.as_ref().display(), err, err))
}
fn modified(path: &Path) -> Result<SystemTime, String> {
let metadata = fs::metadata(path).map_err(|err| {
format!(
......@@ -192,7 +201,7 @@ function DYNAMIC_INIT {
COOKBOOK_CONFIGURE_FLAGS=(
--host="${GNU_TARGET}"
--prefix=""
--prefix="/usr"
--enable-shared
--disable-static
)
......@@ -228,7 +237,7 @@ fn fetch(recipe_dir: &Path, source: &Option<SourceRecipe>) -> Result<PathBuf, St
}
}
Some(SourceRecipe::Path { path }) => {
if modified_dir(Path::new(path))? > modified_dir(&source_dir)? {
if !source_dir.is_dir() || modified_dir(Path::new(path))? > modified_dir(&source_dir)? {
eprintln!("[DEBUG]: {} is newer than {}", path, source_dir.display());
copy_dir_all(path, &source_dir).map_err(|e| {
format!(
......@@ -245,6 +254,8 @@ fn fetch(recipe_dir: &Path, source: &Option<SourceRecipe>) -> Result<PathBuf, St
upstream,
branch,
rev,
patches,
script,
}) => {
//TODO: use libgit?
if !source_dir.is_dir() {
......@@ -322,6 +333,14 @@ fi"#,
run_command(command)?;
}
if !patches.is_empty() || script.is_some() {
// Hard reset
let mut command = Command::new("git");
command.arg("-C").arg(&source_dir);
command.arg("reset").arg("--hard");
run_command(command)?;
}
// Sync submodules URL
let mut command = Command::new("git");
command.arg("-C").arg(&source_dir);
......@@ -337,6 +356,41 @@ fi"#,
.arg("--init")
.arg("--recursive");
run_command(command)?;
// Apply patches
for patch_name in patches {
let patch_file = recipe_dir.join(patch_name);
if !patch_file.is_file() {
return Err(format!(
"failed to find patch file '{}'",
patch_file.display()
));
}
let patch = fs::read_to_string(&patch_file).map_err(|err| {
format!(
"failed to read patch file '{}': {}\n{:#?}",
patch_file.display(),
err,
err
)
})?;
let mut command = Command::new("patch");
command.arg("--forward");
command.arg("--batch");
command.arg("--directory").arg(&source_dir);
command.arg("--strip=1");
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);
run_command_stdin(command, format!("{SHARED_PRESCRIPT}\n{script}").as_bytes())?;
}
}
Some(SourceRecipe::Tar {
tar,
......@@ -501,10 +555,18 @@ fn build(
let sysroot_dir_tmp = target_dir.join("sysroot.tmp");
create_dir_clean(&sysroot_dir_tmp)?;
// Make sure sysroot/include exists
create_dir(&sysroot_dir_tmp.join("include"))?;
// Make sure sysroot/lib exists
create_dir(&sysroot_dir_tmp.join("lib"))?;
// Make sure sysroot/usr exists
create_dir(&sysroot_dir_tmp.join("usr"))?;
for folder in &["bin", "include", "lib", "share"] {
// Make sure sysroot/usr/$folder exists
create_dir(&sysroot_dir_tmp.join("usr").join(folder))?;
// Link sysroot/$folder sysroot/usr/$folder
symlink(
Path::new("usr").join(folder),
&sysroot_dir_tmp.join(folder),
)?;
}
for archive_path in dep_pkgars {
let public_path = "build/id_ed25519.pub.toml";
......@@ -637,7 +699,7 @@ function cookbook_cargo_packages {
COOKBOOK_CONFIGURE="${COOKBOOK_SOURCE}/configure"
COOKBOOK_CONFIGURE_FLAGS=(
--host="${GNU_TARGET}"
--prefix=""
--prefix="/usr"
--disable-shared
--enable-static
)
......@@ -764,7 +826,10 @@ done
command
};
let full_script = format!("{}\n{}\n{}\n{}", pre_script, SHARED_PRESCRIPT, script, post_script);
let full_script = format!(
"{}\n{}\n{}\n{}",
pre_script, SHARED_PRESCRIPT, script, post_script
);
run_command_stdin(command, full_script.as_bytes())?;
// Move stage.tmp to stage atomically
......@@ -779,9 +844,10 @@ fn package(
stage_dir: &Path,
target_dir: &Path,
name: &str,
package: &PackageRecipe,
recipe: &Recipe,
) -> Result<PathBuf, String> {
//TODO: metadata like dependencies, name, and version
let package = &recipe.package;
let secret_path = "build/id_ed25519.toml";
let public_path = "build/id_ed25519.pub.toml";
......@@ -829,7 +895,7 @@ fn package(
depends: Vec<String>,
}
let depends = if should_build_shared() {
package.dependencies.iter().chain(package.shared_deps.iter()).cloned().collect()
recipe.runtime_dependencies()
} else {
package.dependencies.clone()
};
......@@ -838,7 +904,7 @@ fn package(
version: "TODO".into(),
target: env::var("TARGET")
.map_err(|err| format!("failed to read TARGET: {:?}", err))?,
depends
depends,
})
.map_err(|err| format!("failed to serialize stage.toml: {:?}", err))?;
fs::write(target_dir.join("stage.toml"), stage_toml)
......@@ -868,81 +934,12 @@ fn cook(recipe_dir: &Path, name: &str, recipe: &Recipe, fetch_only: bool) -> Res
let stage_dir = build(recipe_dir, &source_dir, &target_dir, name, &recipe)
.map_err(|err| format!("failed to build: {}", err))?;
let _package_file = package(recipe_dir, &stage_dir, &target_dir, name, &recipe.package)
let _package_file = package(recipe_dir, &stage_dir, &target_dir, name, &recipe)
.map_err(|err| format!("failed to package: {}", err))?;
Ok(())
}
pub struct CookRecipe {
name: String,
dir: PathBuf,
recipe: Recipe,
}
impl CookRecipe {
pub fn new(name: String) -> Result<Self, String> {
//TODO: sanitize recipe name?
let dir = recipe_find(&name, Path::new("recipes"))?;
if dir.is_none() {
return Err(format!("failed to find recipe directory '{}'", name));
}
let dir = dir.unwrap();
let file = dir.join("recipe.toml");
if !file.is_file() {
return Err(format!("failed to find recipe file '{}'", file.display()));
}
let toml = fs::read_to_string(&file).map_err(|err| {
format!(
"failed to read recipe file '{}': {}\n{:#?}",
file.display(),
err,
err
)
})?;
let recipe: Recipe = toml::from_str(&toml).map_err(|err| {
format!(
"failed to parse recipe file '{}': {}\n{:#?}",
file.display(),
err,
err
)
})?;
Ok(Self { name, dir, recipe })
}
//TODO: make this more efficient, smarter, and not return duplicates
pub fn new_recursive(names: &[String], recursion: usize) -> Result<Vec<Self>, String> {
if recursion == 0 {
return Err(format!(
"recursion limit while processing build dependencies: {:#?}",
names
));
}
let mut recipes = Vec::new();
for name in names {
let recipe = Self::new(name.clone())?;
let dependencies =
Self::new_recursive(&recipe.recipe.dependencies(), recursion - 1).map_err(
|err| format!("{}: failed on loading build dependencies:\n{}", name, err),
)?;
for dependency in dependencies {
recipes.push(dependency);
}
recipes.push(recipe);
}
Ok(recipes)
}
}
fn main() {
let mut matching = true;
let mut dry_run = false;
......@@ -959,7 +956,7 @@ fn main() {
}
}
let recipes = match CookRecipe::new_recursive(&recipe_names, 16) {
let recipes = match CookRecipe::new_recursive(&recipe_names, 16, false) {
Ok(ok) => ok,
Err(err) => {
eprintln!(
......
use cookbook::recipe::CookRecipe;
use std::{env::args, process::ExitCode};
/// Same as `cookbook/src/bin/cook.rs`.
const DEP_DEPTH: usize = 16;
fn usage() {
eprintln!("Usage: pkg_deps_of [package1 package2 ...]");
}
fn main() -> ExitCode {
let names = args().skip(1).collect::<Vec<String>>();
let recipes = CookRecipe::new_recursive(&names, DEP_DEPTH, true).expect("recipe not found");
for recipe in recipes {
println!("{}", recipe.name);
}
ExitCode::SUCCESS
}
use std::{
fs,
path::{Path, PathBuf},
};
use serde::{Deserialize, Serialize};
use crate::recipe_find::recipe_find;
/// Specifies how to download the source for a recipe
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[serde(untagged)]
......@@ -29,6 +36,11 @@ pub enum SourceRecipe {
/// The optional revision of the git repository to use for builds. Please specify for
/// reproducible builds
rev: Option<String>,
/// A list of patch files to apply to the source
#[serde(default)]
patches: Vec<String>,
/// Optional script to run to prepare the source
script: Option<String>,
},
/// A tar file source
Tar {
......@@ -97,13 +109,109 @@ pub struct Recipe {
impl Recipe {
#[inline]
pub fn dependencies_iter(&self) -> impl Iterator<Item = &String> {
self.build.dependencies.iter().chain(self.package.shared_deps.iter())
self.build
.dependencies
.iter()
.chain(self.package.shared_deps.iter())
}
/// `[build.dependencies] + [package.shared_deps]`
#[inline]
pub fn dependencies(&self) -> Vec<String> {
self.dependencies_iter().cloned().collect::<Vec<_>>()
}
/// `[package.dependencies] + [package.shared_deps]`
#[inline]
pub fn runtime_dependencies(&self) -> Vec<String> {
self.package
.dependencies
.iter()
.chain(self.package.shared_deps.iter())
.cloned()
.collect::<Vec<_>>()
}
}
pub struct CookRecipe {
pub name: String,
pub dir: PathBuf,
pub recipe: Recipe,
}
impl CookRecipe {
pub fn new(name: String) -> Result<Self, String> {
//TODO: sanitize recipe name?
let dir = recipe_find(&name, Path::new("recipes"))?;
if dir.is_none() {
return Err(format!("failed to find recipe directory '{}'", name));
}
let dir = dir.unwrap();
let file = dir.join("recipe.toml");
if !file.is_file() {
return Err(format!("failed to find recipe file '{}'", file.display()));
}
let toml = fs::read_to_string(&file).map_err(|err| {
format!(
"failed to read recipe file '{}': {}\n{:#?}",
file.display(),
err,
err
)
})?;
let recipe: Recipe = toml::from_str(&toml).map_err(|err| {
format!(
"failed to parse recipe file '{}': {}\n{:#?}",
file.display(),
err,
err
)
})?;
Ok(Self { name, dir, recipe })
}
//TODO: make this more efficient, smarter, and not return duplicates
pub fn new_recursive(
names: &[String],
recursion: usize,
runtime_deps_only: bool,
) -> Result<Vec<Self>, String> {
if recursion == 0 {
return Err(format!(
"recursion limit while processing build dependencies: {:#?}",
names
));
}
let mut recipes = Vec::new();
for name in names {
let recipe = Self::new(name.clone())?;
let all_deps = recipe.recipe.dependencies();
let runtime_deps = recipe.recipe.runtime_dependencies();
let dependencies = Self::new_recursive(
if runtime_deps_only {
&runtime_deps
} else {
&all_deps
},
recursion - 1,
runtime_deps_only,
)
.map_err(|err| format!("{}: failed on loading build dependencies:\n{}", name, err))?;
for dependency in dependencies {
recipes.push(dependency);
}
recipes.push(recipe);
}
Ok(recipes)
}
}
#[cfg(test)]
......@@ -133,6 +241,8 @@ mod tests {
upstream: None,
branch: Some("master".to_string()),
rev: Some("06344744d3d55a5ac9a62a6059cb363d40699bbc".to_string()),
patches: Vec::new(),
script: None,
}),
build: BuildRecipe {
kind: BuildKind::Cargo {
......@@ -157,7 +267,7 @@ mod tests {
r#"
[source]
tar = "http://downloads.xiph.org/releases/ogg/libogg-1.3.3.tar.xz"
sha256 = "8220c0e4082fa26c07b10bfe31f641d2e33ebe1d1bb0b20221b7016bc8b78a3a"
blake3 = "8220c0e4082fa26c07b10bfe31f641d2e33ebe1d1bb0b20221b7016bc8b78a3a"
[build]
template = "custom"
......