diff --git a/Makefile.am b/Makefile.am index caa00fb..925aa94 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,12 +18,17 @@ DOMAIN := libreboot.at all: website.tar.gz -if WANT_LBWWW_PATH -BUILD_OPTIONS := --with-lbwww-path $(LBWWW_PATH) -GUIX_SHARE_LBWWW_OPTION := --share=`realpath $(LBWWW_PATH)` -else BUILD_OPTIONS := -GUIX_SHARE_LBWWW_OPTION := +GUIX_SHARE_OPTIONS := + +if WANT_LBWWW_PATH +BUILD_OPTIONS += --with-lbwww-path $(LBWWW_PATH) +GUIX_SHARE_OPTIONS += --share=`realpath $(LBWWW_PATH)` +endif + +if WANT_LBWWW_IMG_PATH +BUILD_OPTIONS += --with-lbwww-img-path $(LBWWW_IMG_PATH) +GUIX_SHARE_OPTIONS += --share=`realpath $(LBWWW_IMG_PATH)` endif build: @@ -33,7 +38,7 @@ build: --container \ --network \ --emulate-fhs \ - $(GUIX_SHARE_LBWWW_OPTION) \ + $(GUIX_SHARE_OPTIONS) \ bash \ coreutils \ findutils \ diff --git a/build.sh b/build.sh index 0c34029..0e1eb41 100755 --- a/build.sh +++ b/build.sh @@ -20,6 +20,9 @@ EX_USAGE=64 lbwww_uri="https://git.sr.ht/~libreboot/lbwww" lbwww_path="" +lbwww_img_uri="https://git.sr.ht/~libreboot/lbwww-img" +lbwww_img_path="" + help() { echo "Usage: $0 [options]" @@ -31,6 +34,31 @@ help() echo -e "\t\tUse a local lbwww directory from PATH\n" \ "\t\tinstead of downloading the latest version from\n" \ "\t\t${lbwww_uri}" + echo -e "\t--with-lbwww-img-path PATH" + echo -e "\t\tUse a local lbwww-img directory from PATH\n" \ + "\t\tinstead of downloading the latest version from\n" \ + "\t\t${lbwww_img_uri}" +} + +sync_repo() +{ + dst_path="$1" + src_uri="$2" + src_path="$3" + + if [ -z "${src_path}" ] && [ ! -d "${dst_path}" ] ; then + git clone "${src_uri}" "${dst_path}" + elif [ ! -d "${dst_path}" ] ; then + mkdir -p "$(dirname ${dst_path})" + cp -a "${src_path}" "${dst_path}" + elif [ -z "${src_path}" ] ; then + git -C "${dst_path}" remote set-url origin "${src_uri}" + git -C "${dst_path}" clean -dfx + git -C "${dst_path}" pull --rebase + else + rm -rf "${dst_path}" + cp -a "${src_path}" "${dst_path}" + fi } if [ $# -eq 1 ] && [ "$1" = "-h" -o "$1" == "--help" ] ; then @@ -38,6 +66,16 @@ if [ $# -eq 1 ] && [ "$1" = "-h" -o "$1" == "--help" ] ; then exit 0 elif [ $# -eq 2 ] && [ "$1" = "--with-lbwww-path" ] ; then lbwww_path="$(realpath $2)" +elif [ $# -eq 2 ] && [ "$1" = "--with-lbwww-img-path" ] ; then + lbwww_img_path="$(realpath $2)" +elif [ $# -eq 4 ] && [ "$1" = "--with-lbwww-path" ] && \ + [ "$3" = "--with-lbwww-img-path" ] ; then + lbwww_path="$(realpath $2)" + lbwww_img_path="$(realpath $4)" +elif [ $# -eq 4 ] && [ "$1" = "--with-lbwww-img-path" ] && \ + [ "$3" = "--with-lbwww-path" ] ; then + lbwww_img_path="$(realpath $2)" + lbwww_path="$(realpath $4)" elif [ $# -ne 0 ] ; then help exit ${EX_USAGE} @@ -52,28 +90,8 @@ else git -C untitled pull --rebase fi -cd untitled && mkdir -p www && cd www - -if [ -z "${lbwww_path}" ] && [ ! -d lbwww ] ; then - git clone "${lbwww_uri}" -elif [ ! -d lbwww ] ; then - cp -a "${lbwww_path}" lbwww -elif [ -z "${lbwww_path}" ] ; then - git -C lbwww remote set-url origin "${lbwww_uri}" - git -C lbwww clean -dfx - git -C lbwww pull --rebase -else - rm -rf lbwww - cp -a "${lbwww_path}" lbwww -fi - -if [ ! -d lbwww-img ] ; then - git clone https://git.sr.ht/~libreboot/lbwww-img -else - git -C lbwww-img clean -dfx - git -C lbwww-img pull --rebase -fi - -cd ../ +sync_repo "untitled/www/lbwww" "${lbwww_uri}" "${lbwww_path}" +sync_repo "untitled/www/lbwww-img" "${lbwww_img_uri}" "${lbwww_img_path}" +cd untitled ./build sites lbwww diff --git a/configure.ac b/configure.ac index 953fd69..67233cb 100644 --- a/configure.ac +++ b/configure.ac @@ -19,6 +19,8 @@ AC_CONFIG_FILES([Makefile]) AC_SUBST([LBWWW_PATH], []) AC_SUBST([LBWWW_GIT_FOUND], []) +AC_SUBST([LBWWW_IMG_PATH], []) +AC_SUBST([LBWWW_IMG_GIT_FOUND], []) # Check dependencies AC_CHECK_PROG([CAT], [cat], [cat]) @@ -29,6 +31,7 @@ AC_CHECK_PROG([PRINTF], [printf], [printf]) AC_CHECK_PROG([REALPATH], [realpath], [realpath]) AC_CHECK_PROG([TAR], [tar], [tar]) +# --with-lbwww-path AC_ARG_WITH([lbwww-path], [AS_HELP_STRING([--with-lbwww-path=PATH], [Use a local lbwww directory from PATH instead of downloading @@ -38,9 +41,24 @@ AC_ARG_WITH([lbwww-path], AM_CONDITIONAL( [WANT_LBWWW_PATH], [test x"$LBWWW_PATH" != x""]) +# --with-lbwww-img-path +AC_ARG_WITH([lbwww-img-path], + [AS_HELP_STRING([--with-lbwww-img-path=PATH], + [Use a local lbwww-img directory from PATH instead of downloading + the latest version from https://git.sr.ht/~libreboot/lbwww-img])], + [LBWWW_IMG_PATH=$withval], + []) + +AM_CONDITIONAL( [WANT_LBWWW_IMG_PATH], [test x"$LBWWW_IMG_PATH" != x""]) + AC_OUTPUT -AS_IF([test x"$LBWWW_PATH" != x""], +AS_IF([test x"$LBWWW_PATH" != x"" || test x"$LBWWW_IMG_PATH" != x""], [AS_ECHO(["Configuration options:"]) - AS_ECHO([]) - AS_ECHO([" LBWWW_PATH: $LBWWW_PATH"])]) + AS_ECHO([])]) + +AS_IF([test x"$LBWWW_PATH" != x""], + [AS_ECHO([" LBWWW_PATH: $LBWWW_PATH"])]) + +AS_IF([test x"$LBWWW_IMG_PATH" != x""], + [AS_ECHO([" LBWWW_IMG_PATH: $LBWWW_IMG_PATH"])])