From 925eaba3a042a9d04817bbb0af31612c7b0f3d3b Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jackpot51@gmail.com> Date: Thu, 11 May 2017 20:29:07 -0600 Subject: [PATCH] Move update-packages into repo command, use source timestamps --- config.sh | 9 ++++++++ cook.sh | 31 +++---------------------- repo.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++++ update-packages.sh | 40 -------------------------------- 4 files changed, 69 insertions(+), 68 deletions(-) create mode 100755 config.sh create mode 100755 repo.sh delete mode 100755 update-packages.sh diff --git a/config.sh b/config.sh new file mode 100755 index 000000000..bab886f90 --- /dev/null +++ b/config.sh @@ -0,0 +1,9 @@ +#!/bin/bash -e + +# Configuration +export TARGET=x86_64-unknown-redox + +# Automatic variables +ROOT="$(cd `dirname "$0"` && pwd)" +REPO="$ROOT/repo/$TARGET" +export CC="$ROOT/libc-artifacts/gcc.sh" diff --git a/cook.sh b/cook.sh index ddc4fbaae..f6d5f80bf 100755 --- a/cook.sh +++ b/cook.sh @@ -1,19 +1,11 @@ -#!/bin/bash +#!/bin/bash -e -# Configuration -export TARGET=x86_64-unknown-redox - -# Automatic variables -ROOT="$(cd `dirname "$0"` && pwd)" -REPO="$ROOT/repo/$TARGET" -export CC="$ROOT/libc-artifacts/gcc.sh" +source config.sh # Variables to be overriden by recipes export BINDIR=bin export CARGOFLAGS= -set -e - function usage { echo "cook.sh $1 <op>" >&2 echo " dist" >&2 @@ -222,24 +214,7 @@ function op { if [ -n "$1" ] then - if [ "$1" = "repo" ] - then - if [ ! "$COOK_QUIET" = "1" ] - then - echo -e "\033[01;38;5;215mcook - repo\033[0m" >&2 - fi - - 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 - elif [ -d "$ROOT/recipes/$1" ] + if [ -d "$ROOT/recipes/$1" ] then cd "$ROOT/recipes/$1" source recipe.sh diff --git a/repo.sh b/repo.sh new file mode 100755 index 000000000..0c94fd7b0 --- /dev/null +++ b/repo.sh @@ -0,0 +1,57 @@ +#!/bin/bash -e + +source config.sh + +if [ $# = 0 ] +then + recipes="$(ls -1 recipes)" +else + recipes="$@" +fi + +for recipe in $recipes +do + if [ ! -d "recipes/$recipe/source" ] + then + echo -e "\033[01;38;5;215mrepo - fetching and updating $recipe\033[0m" >&2 + ./cook.sh "$recipe" fetch + fi + + if [ ! -f "recipes/$recipe/stage.tar" ] + then + echo -e "\033[01;38;5;215mrepo - building $recipe\033[0m" >&2 + ./cook.sh $recipe update build stage tar + else + TIME_SOURCE="$(find recipes/$recipe/source -printf "%Ts\n" | sort -nr | head -n 1)" + TIME_STAGE="$(stat -c "%Y" recipes/$recipe/stage.tar)" + if [ "$TIME_SOURCE" -ge "$TIME_STAGE" ] + then + echo -e "\033[01;38;5;215mrepo - rebuilding $recipe\033[0m" >&2 + ./cook.sh "$recipe" untar unstage update build stage tar + else + echo -e "\033[01;38;5;215mrepo - $recipe up to date\033[0m" >&2 + fi + fi +done + +for recipe in $recipes +do + if [ "recipes/$recipe/stage.tar" -nt "$REPO/$recipe.tar" ] + then + echo -e "\033[01;38;5;215mrepo - publishing $recipe\033[0m" >&2 + ./cook.sh $recipe publish + fi +done + +echo -e "\033[01;38;5;215mrepo - 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 diff --git a/update-packages.sh b/update-packages.sh deleted file mode 100755 index 0109dd234..000000000 --- a/update-packages.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -set -e - -if [ $# = 0 ] -then - recipes=$(ls -1 recipes) -else - recipes=$@ -fi - -publish="" -for recipe in $recipes -do - if [ ! -f "recipes/$recipe/stage.tar" ] - then - echo "$recipe: building..." - ./cook.sh $recipe dist - publish="${publish} $recipe" - else - oldver=$(COOK_QUIET=1 ./cook.sh $recipe gitversion) - ./cook.sh $recipe fetch - newver=$(COOK_QUIET=1 ./cook.sh $recipe gitversion) - if [ "$oldver" = "$newver" ] - then - echo "$recipe: up to date (version $newver)." - else - echo "$recipe: updating $oldver -> $newver..." - ./cook.sh $recipe unstage untar dist - publish="${publish} $recipe" - fi - fi -done - -for recipe in $publish -do - ./cook.sh $recipe publish -done - -./cook.sh repo -- GitLab