mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-06-23 21:34:18 +08:00
Remove all code that handles recipe.sh
This commit is contained in:
parent
61a9872dec
commit
f4d3630ef8
275
cook.sh
275
cook.sh
@ -13,28 +13,10 @@ 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 <op>" >&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 {
|
||||
@ -44,275 +26,22 @@ function op {
|
||||
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"
|
||||
;;
|
||||
@ -351,10 +80,6 @@ then
|
||||
|
||||
cd "${COOKBOOK_RECIPE}"
|
||||
|
||||
if [ -e recipe.sh ]; then
|
||||
source recipe.sh
|
||||
fi
|
||||
|
||||
ops=()
|
||||
for arg in "${@:2}"
|
||||
do
|
||||
|
||||
7
fetch.sh
7
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
|
||||
|
||||
60
repo.sh
60
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user