Newer
Older
shopt -s nullglob
source config.sh
for arg in "${@:1}"
do
if [ "$arg" == "--debug" ]
then
DEBUG=--debug
else
then
recipes="$(ls -1 recipes)"
fi
for recipe in $recipes
do
if [ -e "recipes/$recipe/recipe.toml" ]
then
if [ ! -d "recipes/$recipe/source/" ]
echo -e "\033[01;38;5;155mrepo - fetching $recipe\033[0m" >&2
./cook.sh "$recipe" fetch
fi
if [ ! -d "recipes/$recipe/build/" ]
echo -e "\033[01;38;5;155mrepo - preparing $recipe\033[0m" >&2
./cook.sh "$recipe" prepare
elif [ ! -d "recipes/$recipe/sysroot/" ]
then
echo -e "\033[01;38;5;155mrepo - repreparing $recipe\033[0m" >&2
./cook.sh "$recipe" unprepare prepare
TIME_SOURCE="$($FIND recipes/$recipe/source/ -type f -not -path '*/.git*' -printf "%Ts\n" | sort -nr | head -n 1)"
TIME_BUILD="$($FIND recipes/$recipe/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 "recipes/$recipe/stage.tar.gz" ]
then
echo -e "\033[01;38;5;155mrepo - building $recipe\033[0m" >&2
./cook.sh "$recipe" build stage tar $DEBUG
TIME_BUILD="$($FIND recipes/$recipe/build/ -type f -not -path '*/.git*' -printf "%Ts\n" | sort -nr | head -n 1)"
TIME_STAGE="$($STAT -c "%Y" recipes/$recipe/stage.tar.gz)"
TIME_RECIPE="$($FIND recipes/$recipe/{recipe.sh,*.patch} -printf '%Ts\n' | sort -nr | head -n 1)"
if [ "$TIME_BUILD" -gt "$TIME_STAGE" -o "$TIME_RECIPE" -gt "$TIME_STAGE" ]
echo -e "\033[01;38;5;155mrepo - rebuilding $recipe\033[0m" >&2
./cook.sh "$recipe" untar unstage build stage tar $DEBUG
echo -e "\033[01;38;5;155mrepo - $recipe up to date\033[0m" >&2
then
echo -e "\033[01;38;5;155mrepo - packaging $recipe\033[0m" >&2
./cook.sh "$recipe" pkg $DEBUG
else
TIME_STAGE="$($STAT -c "%Y" recipes/$recipe/stage.tar.gz)"
if [ "$TIME_STAGE" -gt "$TIME_PKG" ]
then
echo -e "\033[01;38;5;155mrepo - repackaging $recipe\033[0m" >&2
./cook.sh "$recipe" unpkg pkg $DEBUG
fi
fi
for recipe in $recipes
do
if [ "recipes/$recipe/stage.tar.gz" -nt "$REPO/$recipe.tar.gz" ]
echo -e "\033[01;38;5;155mrepo - publishing $recipe\033[0m" >&2
./cook.sh $recipe publish
fi
if [ "recipes/$recipe/stage.pkgar" -nt "$REPO/$recipe.pkgar" ]
then
echo -e "\033[01;38;5;155mrepo - publishing $recipe\033[0m" >&2
echo -e "\033[01;38;5;155mrepo - generating repo.toml\033[0m" >&2
echo "[packages]" > "$REPO/repo.toml"
for toml in "$REPO/"*".toml"
do
package="$(basename "$toml" .toml)"
if [ "$package" != "repo" ]
then
version="$(grep version "$toml" | cut -d '=' -f2-)"
echo "$package =$version" >> "$REPO/repo.toml"
fi
done