Newer
Older

Jeremy Soller
committed
source config.sh

Jeremy Soller
committed
export BINDIR=bin
export CARGO=(env RUSTFLAGS="$PREFIX_RUSTFLAGS -C link-arg=-zmuldefs" cargo)

Jeremy Soller
committed
export CARGOFLAGS=
if hash sha256sum 2>/dev/null
then
SHASUM="sha256sum"
else
if [ ! "$(uname -s)" = "Redox" ]
then
function docgen {
CC=cc cargo run --release --manifest-path "$ROOT/docgen/Cargo.toml" --bin docgen -- "$@"
}
CC=cc cargo run --release --manifest-path "$ROOT/pkgutils/Cargo.toml" --bin pkg -- "$@"
function pkgar {
CC=cc cargo run --release --manifest-path "$ROOT/pkgar/Cargo.toml" --bin pkgar -- "$@"
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 " stage" >&2
echo " unstage" >&2
echo " tar" >&2
echo " untar" >&2
echo " version" >&2
}
then
echo -e "\033[01;38;5;215mcook - $1 $2\033[0m" >&2
fi
op $1 build
op $1 stage
op $1 tar
skip=0
if [ "$(type -t recipe_fetch)" = "function" ]
then
recipe_fetch
fi
if [ "$skip" -eq "0" ]
if [ ! -f source.tar ]
then
wget "$TAR" -O source.tar
fi
if [ ! -d source ]
then
mkdir source
tar xvf source.tar -C source --strip-components 1
fi
elif [ -n "$GIT" ]
if [ -n "$BRANCH" ]
then
git clone --recursive "$GIT" -b "$BRANCH" source
else
git clone --recursive "$GIT" source
fi
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"
git submodule update --init --recursive
popd > /dev/null
fi
skip=0
if [ "$(type -t recipe_prepare)" = "function" ]
recipe_prepare
fi
if [ "$skip" -eq "0" ]
then
rm -rf "${COOKBOOK_SYSROOT}"
mkdir "${COOKBOOK_SYSROOT}"
if [ ${#BUILD_DEPENDS} -gt 0 ]
then
pushd $ROOT
./repo.sh "${BUILD_DEPENDS[@]}"
popd
for i in "${BUILD_DEPENDS[@]}"
do
--archive "$REPO/$i.pkgar" \
--pkey "${ROOT}/build/id_ed25519.pub.toml"
cp -rp source "${COOKBOOK_BUILD}"
patch -p1 -d "${COOKBOOK_BUILD}" < "$patch"
rm -rf "${COOKBOOK_BUILD}"
rm -rf "${COOKBOOK_SYSROOT}"
pushd "${COOKBOOK_BUILD}" > /dev/null
if [ "$(type -t recipe_version)" = "function" ]
fi
if [ "$skip" -eq "0" ]
# there's an unstable built-in cargo config command, so hack around it
cargo-config config package.version | tr -d '"'
gitversion)
if [ -d "${COOKBOOK_BUILD}"/.git ]
echo "$(op $1 version)-$(git -C "${COOKBOOK_BUILD}" rev-parse --short HEAD)"
else
op $1 version
fi
;;
pushd "${COOKBOOK_BUILD}" > /dev/null
if [ "$(type -t recipe_build)" = "function" ]
then
release_flag="--release"
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
pushd "${COOKBOOK_BUILD}" > /dev/null
if [ "$(type -t recipe_clean)" = "function" ]
then
fi
if [ "$skip" -eq "0" ]
then
mkdir -p "${COOKBOOK_STAGE}"
stage="$(realpath "${COOKBOOK_STAGE}")"
source="$(realpath source)"
pushd "${COOKBOOK_BUILD}" > /dev/null
if [ "$(type -t recipe_stage)" = "function" ]
then

Jeremy Soller
committed
fi
if [ "$skip" -eq "0" ]

Jeremy Soller
committed
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 ]
bins="$bins $(find target/$TARGET/$build/examples/ -maxdepth 1 -type f ! -name '*.*' ! -name '*-*' \
if [ -n "$example" ] && [ "$EXAMPLES" != 1 ]
echo "$(tput bold)Note$(tput sgr0): No binaries detected, using example binaries"
if [ "$DEBUG" == 1 ]
then
"${STRIP}" -v "$bin" -o "$stage/$BINDIR/$(basename $bin)"
else
echo "$(tput bold)Warning$(tput sgr0): Recipe does not have any binaries" >&2
docgen "$source" "$stage/ref"
rm -rfv "${COOKBOOK_STAGE}"
--archive "${COOKBOOK_STAGE}.pkgar" \
rm -fv "${COOKBOOK_STAGE}.pkgar"
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"
rm -rf "${COOKBOOK_STAGE}/pkg"
mkdir -p "${COOKBOOK_STAGE}/pkg"

Jeremy Soller
committed
pushd "${COOKBOOK_STAGE}" > /dev/null
find -L . -type f | cut -d / -f 2- | sort | while read file

Jeremy Soller
committed
do

Jeremy Soller
committed
done
popd > /dev/null
cp -v "${COOKBOOK_STAGE}.toml" "${COOKBOOK_STAGE}/pkg/$1.toml"
pushd "$(dirname "${COOKBOOK_STAGE}")" > /dev/null
pkg --target="$TARGET" create "$(basename "${COOKBOOK_STAGE}")"
popd > /dev/null
rm -rfv "${COOKBOOK_STAGE}.tar.gz" "${COOKBOOK_STAGE}.sig" "${COOKBOOK_STAGE}.toml"
if [ -d "$ROOT/recipes/$1" ]
export COOKBOOK_RECIPE="${ROOT}/recipes/$1"
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_LIBDIR="${COOKBOOK_SYSROOT}/lib/pkgconfig"
export PKG_CONFIG_SYSROOT_DIR="${COOKBOOK_SYSROOT}"
if [ -e recipe.sh ]; then
source recipe.sh
fi
if [ "$arg" == "--debug" ]
then
else
ops[${#ops[@]}]="$arg"
fi
done
for i in "${ops[@]}"
do
op "$1" "$i"