Skip to content
Snippets Groups Projects
Commit a48475e4 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Improve rebuild logic

parent b3ad568e
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,8 @@ function usage { ...@@ -14,6 +14,8 @@ function usage {
echo " clean" >&2 echo " clean" >&2
echo " fetch" >&2 echo " fetch" >&2
echo " unfetch" >&2 echo " unfetch" >&2
echo " prepare" >&2
echo " unprepare" >&2
echo " publish" >&2 echo " publish" >&2
echo " unpublish" >&2 echo " unpublish" >&2
echo " stage" >&2 echo " stage" >&2
...@@ -32,7 +34,7 @@ function op { ...@@ -32,7 +34,7 @@ function op {
case "$2" in case "$2" in
dist) dist)
op $1 fetch op $1 prepare
op $1 update op $1 update
op $1 build op $1 build
op $1 stage op $1 stage
...@@ -41,7 +43,7 @@ function op { ...@@ -41,7 +43,7 @@ function op {
distclean) distclean)
op $1 untar op $1 untar
op $1 unstage op $1 unstage
op $1 unfetch op $1 unprepare
;; ;;
fetch) fetch)
if [ -n "$TAR" ] if [ -n "$TAR" ]
...@@ -56,9 +58,6 @@ function op { ...@@ -56,9 +58,6 @@ function op {
mkdir source mkdir source
tar xvf source.tar -C source --strip-components 1 tar xvf source.tar -C source --strip-components 1
fi fi
rm -rf build
cp -r source build
elif [ -n "$GIT" ] elif [ -n "$GIT" ]
then then
if [ ! -d source ] if [ ! -d source ]
...@@ -71,19 +70,22 @@ function op { ...@@ -71,19 +70,22 @@ function op {
git submodule sync git submodule sync
git submodule update --init --recursive git submodule update --init --recursive
popd > /dev/null popd > /dev/null
rm -rf build
cp -r source build
fi fi
;; ;;
unfetch) unfetch)
rm -rfv build source rm -rfv source
if [ -n "$TAR" ] if [ -n "$TAR" ]
then then
rm -f source.tar rm -f source.tar
fi fi
;; ;;
prepare)
rm -rf build
cp -r source build
;;
unprepare)
rm -rf build
;;
version) version)
pushd build > /dev/null pushd build > /dev/null
skip="0" skip="0"
......
...@@ -17,19 +17,33 @@ do ...@@ -17,19 +17,33 @@ do
./cook.sh "$recipe" fetch ./cook.sh "$recipe" fetch
fi fi
if [ ! -f "recipes/$recipe/stage.tar" ] if [ ! -d "recipes/$recipe/build" ]
then then
echo -e "\033[01;38;5;215mrepo - building $recipe\033[0m" >&2 echo -e "\033[01;38;5;155mrepo - preparing $recipe\033[0m" >&2
./cook.sh $recipe update build stage tar ./cook.sh "$recipe" prepare
else else
TIME_SOURCE="$(find recipes/$recipe/source -type f -not -path '*/.git*' -printf "%Ts\n" | sort -nr | head -n 1)" 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" ]
then
echo -e "\033[01;38;5;155mrepo - building $recipe\033[0m" >&2
./cook.sh "$recipe" update build stage tar
else
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)" TIME_STAGE="$(stat -c "%Y" recipes/$recipe/stage.tar)"
if [ "$TIME_SOURCE" -ge "$TIME_STAGE" ] if [ "$TIME_BUILD" -gt "$TIME_STAGE" ]
then then
echo -e "\033[01;38;5;215mrepo - rebuilding $recipe\033[0m" >&2 echo -e "\033[01;38;5;155mrepo - rebuilding $recipe\033[0m" >&2
./cook.sh "$recipe" untar unstage update build stage tar ./cook.sh "$recipe" untar unstage update build stage tar
else else
echo -e "\033[01;38;5;215mrepo - $recipe up to date\033[0m" >&2 echo -e "\033[01;38;5;155mrepo - $recipe up to date\033[0m" >&2
fi fi
fi fi
done done
...@@ -38,12 +52,12 @@ for recipe in $recipes ...@@ -38,12 +52,12 @@ for recipe in $recipes
do do
if [ "recipes/$recipe/stage.tar" -nt "$REPO/$recipe.tar" ] if [ "recipes/$recipe/stage.tar" -nt "$REPO/$recipe.tar" ]
then then
echo -e "\033[01;38;5;215mrepo - publishing $recipe\033[0m" >&2 echo -e "\033[01;38;5;155mrepo - publishing $recipe\033[0m" >&2
./cook.sh $recipe publish ./cook.sh $recipe publish
fi fi
done done
echo -e "\033[01;38;5;215mrepo - generating repo.toml\033[0m" >&2 echo -e "\033[01;38;5;155mrepo - generating repo.toml\033[0m" >&2
echo "[packages]" > "$REPO/repo.toml" echo "[packages]" > "$REPO/repo.toml"
for toml in "$REPO/"*".toml" for toml in "$REPO/"*".toml"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment