diff --git a/clean.sh b/clean.sh index 7aba7ca85..c1ed4cf24 100755 --- a/clean.sh +++ b/clean.sh @@ -10,7 +10,25 @@ else recipes="$@" fi -for recipe_path in $recipes +for recipe in $recipes do - ./cook.sh "$recipe_path" distclean + if (echo "$recipe" | grep '.*/.*' >/dev/null); then + recipe_name=$(basename "$recipe") + recipe_path="$recipe" + else + recipe_name="$recipe" + recipe_path=`target/release/find_recipe $recipe` + fi + + echo -e "\033[01;38;5;215mcook - clean $recipe_name\033[0m" + + if [ -d "$ROOT/$recipe_path" ] + then + COOKBOOK_RECIPE="${ROOT}/$recipe_path" + TARGET_DIR="${ROOT}/$recipe_path/target/${TARGET}" + + rm -rf "${TARGET_DIR}" + else + echo "clean.sh: recipe '$recipe_name' not found" >&2 + fi done diff --git a/cook.sh b/cook.sh deleted file mode 100755 index 6435f2cce..000000000 --- a/cook.sh +++ /dev/null @@ -1,380 +0,0 @@ -#!/usr/bin/env bash -set -e -shopt -s nullglob - -source config.sh - -# Variables to be overriden by recipes -export BINDIR=bin -export CARGO=(env RUSTFLAGS="$PREFIX_RUSTFLAGS -C link-arg=-zmuldefs" cargo) -export CARGOBUILD=rustc -export CARGOFLAGS= -export DEBUG= -export EXAMPLES= -export PREPARE_COPY=1 - -if hash sha256sum 2>/dev/null -then - SHASUM="sha256sum" -else - SHASUM="shasum -a 256" -fi - -function usage { - echo "cook.sh $1 " >&2 - echo " dist" >&2 - echo " distclean" >&2 - echo " build" >&2 - echo " clean" >&2 - echo " fetch" >&2 - echo " unfetch" >&2 - echo " pkg" >&2 - echo " unpkg" >&2 - echo " prepare" >&2 - echo " unprepare" >&2 - echo " stage" >&2 - echo " unstage" >&2 - echo " version" >&2 -} - -function op { - if [ ! "$COOK_QUIET" = "1" ] - then - echo -e "\033[01;38;5;215mcook - $1 $2\033[0m" >&2 - fi - - case "$2" in - dist) - op $1 prepare - op $1 build - op $1 stage - op $1 pkg - ;; - distclean) - op $1 unpkg - op $1 unstage - op $1 unprepare - ;; - fetch) - skip=0 - if [ "$(type -t recipe_fetch)" = "function" ] - then - recipe_fetch - fi - if [ "$skip" -eq "0" ] - then - if [ -n "$TAR" ] - then - if [ ! -f source.tar ] - then - wget "$TAR" --continue -O source.tar.tmp - mv source.tar.tmp source.tar - fi - - if [ -n "$TAR_SHA256" ] - then - $SHASUM -c <<< "${TAR_SHA256} source.tar" - fi - - if [ ! -d source ] - then - mkdir source - tar xvf source.tar -C source --strip-components 1 - fi - elif [ -n "$GIT" ] - then - if [ ! -d source ] - then - if [ -n "$BRANCH" ] - then - git clone --recursive "$GIT" -b "$BRANCH" source - else - git clone --recursive "$GIT" source - fi - fi - - pushd source > /dev/null - git remote set-url origin "$GIT" - git fetch origin - if [ -n "$GIT_UPSTREAM" ] - then - git remote set-url upstream "$GIT_UPSTREAM" &> /dev/null || - git remote add upstream "$GIT_UPSTREAM" - git fetch upstream - fi - - ORIGIN_BRANCH="$(git branch --remotes | grep '^ origin/HEAD -> ' | cut -d ' ' -f 5-)" - if [ -n "$BRANCH" ] - then - ORIGIN_BRANCH="origin/$BRANCH" - fi - - if [ "$(git rev-parse HEAD)" != "$(git rev-parse $ORIGIN_BRANCH)" ] - then - git checkout -B "$(echo "$ORIGIN_BRANCH" | cut -d / -f 2-)" "$ORIGIN_BRANCH" - fi - git submodule sync --recursive - git submodule update --init --recursive - popd > /dev/null - fi - fi - ;; - unfetch) - rm -rfv source source.tar - ;; - prepare) - skip=0 - if [ "$(type -t recipe_prepare)" = "function" ] - then - recipe_prepare - fi - if [ "$skip" -eq "0" ] - then - rm -rf "${COOKBOOK_SYSROOT}" - mkdir "${COOKBOOK_SYSROOT}" - - # usrmerge - mkdir "${COOKBOOK_SYSROOT}/usr" - for folder in bin include lib share - do - mkdir "${COOKBOOK_SYSROOT}/usr/${folder}" - ln -s "usr/${folder}" "${COOKBOOK_SYSROOT}/${folder}" - done - - if [ ${#BUILD_DEPENDS} -gt 0 ] - then - pushd $ROOT - ./repo.sh "${BUILD_DEPENDS[@]}" - popd - - for i in "${BUILD_DEPENDS[@]}" - do - pkgar \ - extract \ - "${COOKBOOK_SYSROOT}" \ - --archive "$REPO/$i.pkgar" \ - --pkey "${ROOT}/build/id_ed25519.pub.toml" - done - fi - - rm -rf "${COOKBOOK_BUILD}" - if [ "$PREPARE_COPY" -eq "0" ] - then - mkdir "${COOKBOOK_BUILD}" - else - cp -Rp source "${COOKBOOK_BUILD}" - fi - - for patch in *.patch - do - patch -p1 -d "${COOKBOOK_BUILD}" < "$patch" - done - fi - ;; - unprepare) - rm -rf "${COOKBOOK_BUILD}" - rm -rf "${COOKBOOK_SYSROOT}" - ;; - version) - pushd "${COOKBOOK_BUILD}" > /dev/null - skip=0 - if [ "$(type -t recipe_version)" = "function" ] - then - recipe_version - fi - if [ "$skip" -eq "0" ] - then - # there's an unstable built-in cargo config command, so hack around it - cargo-config config package.version | tr -d '"' - fi - popd > /dev/null - ;; - gitversion) - if [ -d "${COOKBOOK_BUILD}"/.git ] - then - echo "$(op $1 version)-$(git -C "${COOKBOOK_BUILD}" rev-parse --short HEAD)" - else - op $1 version - fi - ;; - build) - pushd "${COOKBOOK_BUILD}" > /dev/null - skip=0 - if [ "$(type -t recipe_build)" = "function" ] - then - recipe_build - fi - - release_flag="--release" - if [ "$DEBUG" == 1 ] - then - release_flag= - fi - - if [ -n "$CARGO_PACKAGE" ]; then - package_flag="--package=$CARGO_PACKAGE" - else - package_flag= - fi - - if [ "$skip" -eq "0" ] - then - "${CARGO[@]}" "$CARGOBUILD" --target "$TARGET" $release_flag $package_flag $CARGOFLAGS - fi - popd > /dev/null - ;; - clean) - pushd "${COOKBOOK_BUILD}" > /dev/null - skip=0 - if [ "$(type -t recipe_clean)" = "function" ] - then - recipe_clean - fi - if [ "$skip" -eq "0" ] - then - "${CARGO[@]}" clean - fi - popd > /dev/null - ;; - stage) - op $1 unstage - mkdir -p "${COOKBOOK_STAGE}" - stage="$(realpath "${COOKBOOK_STAGE}")" - source="$(realpath source)" - pushd "${COOKBOOK_BUILD}" > /dev/null - skip=0 - if [ "$(type -t recipe_stage)" = "function" ] - then - recipe_stage "$stage" - fi - if [ "$skip" -eq "0" ] - then - #TODO "${CARGO[@]}" install --root "$stage" $CARGOFLAGS - if [ "$DEBUG" == 1 ] - then - build=debug - else - build=release - fi - - bins="$(find target/$TARGET/$build/ -maxdepth 1 -type f ! -name '*.*')" - if [ -z "$bins" ] || [ "$EXAMPLES" == 1 ] - then - example=true - bins="$bins $(find target/$TARGET/$build/examples/ -maxdepth 1 -type f ! -name '*.*' ! -name '*-*' \ - 2> /dev/null || true)" - fi - if [ -n "$bins" ] - then - if [ -n "$example" ] && [ "$EXAMPLES" != 1 ] - then - echo "$(tput bold)Note$(tput sgr0): No binaries detected, using example binaries" - fi - mkdir -p "$stage/$BINDIR" - for bin in $bins - do - if [ "$DEBUG" == 1 ] - then - cp -v "$bin" "$stage/$BINDIR/$(basename $bin)" - else - "${STRIP}" -v "$bin" -o "$stage/$BINDIR/$(basename $bin)" - fi - done - else - echo "$(tput bold)Warning$(tput sgr0): Recipe does not have any binaries" >&2 - fi - fi - popd > /dev/null - ;; - unstage) - rm -rfv "${COOKBOOK_STAGE}" - rm -fv "${TARGET_DIR}/auto_deps.toml" - ;; - pkg) - pkgar \ - create \ - --archive "${COOKBOOK_STAGE}.pkgar" \ - --skey "${ROOT}/build/id_ed25519.toml" \ - "${COOKBOOK_STAGE}" - - # Generate stage.toml - echo "name = \"$1\"" > "${COOKBOOK_STAGE}.toml" - echo "version = \"$(op $1 version)\"" >> "${COOKBOOK_STAGE}.toml" - echo "target = \"$TARGET\"" >> "${COOKBOOK_STAGE}.toml" - - # Add runtime dependencies to package if they exist - if [ -n "$DEPENDS" ] - then - # Remove leading and trailing whitespace, replace whitespace between - # package names with commas, and surround package names with quotes - dependencies=$(echo -e "$DEPENDS" | sed -E 's/^[[:space:]]*//;s/[[:space:]]*$//;s/[[:space:]]+/,/g;s/[^, ][^, ]*/"&"/g') - echo "depends = [$dependencies]" >> "${COOKBOOK_STAGE}.toml" - else - echo "depends = []" >> "${COOKBOOK_STAGE}.toml" - fi - ;; - unpkg) - rm -fv "${COOKBOOK_STAGE}.pkgar" "${COOKBOOK_STAGE}.toml" - ;; - *) - usage $1 - ;; - esac -} - -if [ -n "$1" ] -then - if (echo "$1" | grep '.*/.*' >/dev/null); then - recipe_name=$(basename "$1") - recipe_path="$1" - else - recipe_name="$1" - recipe_path=`target/release/find_recipe $recipe_name` - fi - - if [ -d "$ROOT/$recipe_path" ] - then - export COOKBOOK_RECIPE="${ROOT}/$recipe_path" - - TARGET_DIR="${COOKBOOK_RECIPE}/target/${TARGET}" - mkdir -p "${TARGET_DIR}" - - export COOKBOOK_BUILD="${TARGET_DIR}/build" - export COOKBOOK_STAGE="${TARGET_DIR}/stage" - export COOKBOOK_SOURCE="${COOKBOOK_RECIPE}/source" - export COOKBOOK_SYSROOT="${TARGET_DIR}/sysroot" - - export PKG_CONFIG_ALLOW_CROSS=1 - export PKG_CONFIG_PATH= - export PKG_CONFIG_LIBDIR="${COOKBOOK_SYSROOT}/lib/pkgconfig" - export PKG_CONFIG_SYSROOT_DIR="${COOKBOOK_SYSROOT}" - - cd "${COOKBOOK_RECIPE}" - - if [ -e recipe.sh ]; then - source recipe.sh - fi - - ops=() - for arg in "${@:2}" - do - if [ "$arg" == "--debug" ] - then - DEBUG=1 - else - ops[${#ops[@]}]="$arg" - fi - done - - for i in "${ops[@]}" - do - op "$recipe_name" "$i" - done - elif [ "$IGNORE_ERROR" != "1" ] - then - echo "cook.sh: recipe '$recipe_name' at not found" >&2 - exit 1 - fi -else - usage "{package}" -fi diff --git a/fetch.sh b/fetch.sh index 060ac6e4d..a3bc69c76 100755 --- a/fetch.sh +++ b/fetch.sh @@ -32,10 +32,5 @@ do recipe_path=`target/release/find_recipe $recipe_name` fi - if [ -e "$recipe_path/recipe.toml" ] - then - target/release/cook --fetch-only "$recipe_name" - else - ./cook.sh "$recipe_name" fetch - fi + target/release/cook --fetch-only "$recipe_name" done diff --git a/repo.sh b/repo.sh index 40476cefd..8869c0e7b 100755 --- a/repo.sh +++ b/repo.sh @@ -34,9 +34,6 @@ 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` @@ -47,65 +44,18 @@ do COOKBOOK_SOURCE="${COOKBOOK_RECIPE}/source" COOKBOOK_SYSROOT="${TARGET_DIR}/sysroot" - if [ -e "${COOKBOOK_RECIPE}/recipe.toml" ] - then - toml_recipes+=" $recipe" - target/release/cook $COOK_OPT "$recipe" - continue - fi - - if [ ! -d "${COOKBOOK_SOURCE}" ] - then - echo -e "\033[01;38;5;155mrepo - fetching $recipe\033[0m" >&2 - ./cook.sh "$recipe" fetch - fi - - if [ ! -d "${COOKBOOK_BUILD}" ] - then - echo -e "\033[01;38;5;155mrepo - preparing $recipe\033[0m" >&2 - ./cook.sh "$recipe" prepare - elif [ ! -d "${COOKBOOK_SYSROOT}" ] - then - echo -e "\033[01;38;5;155mrepo - repreparing $recipe\033[0m" >&2 - ./cook.sh "$recipe" unprepare prepare - else - TIME_SOURCE="$($FIND "${COOKBOOK_SOURCE}" -type f -not -path '*/.git*' -printf "%Ts\n" | sort -nr | head -n 1)" - TIME_BUILD="$($FIND "${COOKBOOK_BUILD}" -type f -not -path '*/.git*' -printf "%Ts\n" | sort -nr | head -n 1)" - if [ "$TIME_SOURCE" -gt "$TIME_BUILD" ] - then - echo -e "\033[01;38;5;155mrepo - repreparing $recipe\033[0m" >&2 - ./cook.sh "$recipe" unprepare prepare - fi - fi - - if [ ! -f "${COOKBOOK_STAGE}.pkgar" ] - then - echo -e "\033[01;38;5;155mrepo - building $recipe\033[0m" >&2 - ./cook.sh "$recipe" build stage pkg $DEBUG - else - TIME_BUILD="$($FIND "${COOKBOOK_BUILD}" -type f -not -path '*/.git*' -printf "%Ts\n" | sort -nr | head -n 1)" - TIME_STAGE="$($STAT -c "%Y" "${COOKBOOK_STAGE}.pkgar")" - TIME_RECIPE="$($FIND "${COOKBOOK_RECIPE}"/{recipe.sh,*.patch} -printf '%Ts\n' | sort -nr | head -n 1)" - if [ "$TIME_BUILD" -gt "$TIME_STAGE" -o "$TIME_RECIPE" -gt "$TIME_STAGE" ] - then - echo -e "\033[01;38;5;155mrepo - rebuilding $recipe\033[0m" >&2 - ./cook.sh "$recipe" untar unstage build stage pkg $DEBUG - else - echo -e "\033[01;38;5;155mrepo - $recipe up to date\033[0m" >&2 - fi - fi + target/release/cook $COOK_OPT "$recipe" done mkdir -p "$REPO" declare -A APPSTREAM_SOURCES -# Currently, we only support runtime dependencies for recipes in the new TOML -# format. Runtime dependencies include both `[package.dependencies]` and -# dynamically linked packages discovered by auto_deps. -# +# Runtime dependencies include both `[package.dependencies]` and dynamically +# linked packages discovered by auto_deps. +# # The following adds the package dependencies of the recipes to the repo as # well. -recipes="$recipes $(target/release/pkg_deps $toml_recipes)" +recipes="$recipes $(target/release/pkg_deps $recipes)" target/release/repo_builder "$REPO" $recipes diff --git a/unfetch.sh b/unfetch.sh index eb73178c3..d8016a05f 100755 --- a/unfetch.sh +++ b/unfetch.sh @@ -10,7 +10,16 @@ else recipes="$@" fi -for recipe_path in $recipes +for recipe in $recipes do - ./cook.sh "$recipe_path" unfetch + if (echo "$recipe" | grep '.*/.*' >/dev/null); then + recipe_name=$(basename "$recipe") + recipe_path="$recipe" + else + recipe_name="$recipe" + recipe_path=`target/release/find_recipe $recipe` + fi + + rm -rfv "$recipe_path"/source "$recipe_path"/source.tar done +