From 061cfd139f4452998f8a47f15b30e3deaba7e780 Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Fri, 23 Jun 2023 11:39:18 +0200 Subject: [PATCH 1/2] owntone: support building a PR branch, and build a pr branch with partial library scans to try it out, docker image tagged with branch name --- build.sh | 42 +++++++++++++++++++++++------- owntone/.pipeline/build.sh | 39 ++++++++++++++++++--------- owntone/.pipeline/docker-push.sh | 3 +-- owntone/.pipeline/init-git.sh | 27 +++++++++++++++++-- owntone/.pipeline/owntone.env | 2 ++ owntone/builder/package-owntone.sh | 19 +++++++++++--- 6 files changed, 103 insertions(+), 29 deletions(-) diff --git a/build.sh b/build.sh index 9fd120e..d7f6ad6 100755 --- a/build.sh +++ b/build.sh @@ -3,18 +3,42 @@ set -e usage() { - echo "$0 " + echo "$0 [--docker-push]" exit 1 } -if [ "$1" = "" ]; then +if [[ "$1" = "" ]]; then usage else PROJECT=$1 PROJECT_PIPELINE=./${PROJECT}/.pipeline shift + if [[ "$1" == "--docker-push" && -f "${PROJECT_PIPELINE}/docker-push.sh" ]]; then + DOCKER_PUSH="true" + else + DOCKER_PUSH="false" + fi fi +if [[ -f "${PROJECT_PIPELINE}/build.sh" && "${PROJECT}" == "owntone" ]]; then + ( + set -e + cd ./$PROJECT + . .pipeline/build.sh + + echo "[build.sh] executed '${PROJECT_PIPELINE}/build.sh' and exited with '$?'" + echo + + if [[ "${DOCKER_PUSH}" == "true" ]]; then + . .pipeline/docker-push.sh + echo "[build.sh] executed '${PROJECT_PIPELINE}/docker-push.sh' and exited with '$?'" + echo + fi + ) + exit 0 +fi + + for f in ${PROJECT_PIPELINE}/*.env; do echo "sourcing: $f" source $f @@ -22,12 +46,12 @@ for f in ${PROJECT_PIPELINE}/*.env; do done echo && echo -if [ "${DOCKER_REPO}" = "" ]; then +if [[ "${DOCKER_REPO}" = "" ]]; then # default if not explicitly set in project DOCKER_REPO="git.sudo.is/ben" fi -if [ -f "${PROJECT_PIPELINE}/init-git.sh" ]; then +if [[ -f "${PROJECT_PIPELINE}/init-git.sh" ]]; then echo "running 'init-git.sh' for ${PROJECT}" ( set -e @@ -42,24 +66,24 @@ echo && echo echo "cleaning up ${PROJECT}/dist" mkdir -pv ./${PROJECT}/dist -if [ -d ./${PROJECT}/dist/target ]; then +if [[ -d ./${PROJECT}/dist/target ]]; then echo "removing directory '${PROJECT}/dist/target'" rm -r ${PROJECT}/dist/target fi -if [ -f "./${PROJECT}/dist/*.tar.gz" ]; then +if [[ -f "./${PROJECT}/dist/*.tar.gz" ]]; then rm -v ./${PROJECT}/dist/*.tar.gz fi -if [ -f "./${PROJECT}/dist/*.tar.gz2" ]; then +if [[ -f "./${PROJECT}/dist/*.tar.gz2" ]]; then rm -v ./${PROJECT}/dist/*.tar.gz2 fi -if [ -f "./${PROJECT}/dist/*.deb" ]; then +if [[ -f "./${PROJECT}/dist/*.deb" ]]; then rm -v ./${PROJECT}/dist/*.deb fi echo && echo BUILD_ARGS_FILE="${PROJECT_PIPELINE}/docker-build-args" -if [ -f "$BUILD_ARGS_FILE" ]; then +if [[ -f "$BUILD_ARGS_FILE" ]]; then echo "found docker-build-args file" cat $BUILD_ARGS_FILE diff --git a/owntone/.pipeline/build.sh b/owntone/.pipeline/build.sh index d491c51..2f05ed5 100755 --- a/owntone/.pipeline/build.sh +++ b/owntone/.pipeline/build.sh @@ -12,8 +12,8 @@ fi . ./.pipeline/init-git.sh - mkdir -pv ./dist/ +rm -rv ./dist/dark-reader || true rm -rv ./dist/target || true rm -v ./dist/*.tar.gz || true rm -v ./dist/*.deb || true @@ -26,23 +26,36 @@ rm -v ./dist/*.deb || true # create the .patch file with (dont include the huge css file): # git diff --patch > ../dark-reader-css.patch -# chdir into the git tree to apply the patch -( - # copy into the git tree and apply the patch - cd owntone-server/ - git apply ../dark-reader-css.patch -) +# # chdir into the git tree to apply the patch +# ( +# # copy into the git tree and apply the patch +# cd owntone-server/ +# git apply ../dark-reader-css.patch +# ) -# then copy the css file -cp dark-reader.css owntone-server/htdocs/assets +# # then copy the css file +# cp dark-reader.css owntone-server/htdocs/assets -git --no-pager diff --color=always -cp ../ +# git --no-pager diff --color=always +# cp ../ docker build --pull --build-arg "VITE_OWNTONE_URL=$VITE_OWNTONE_URL" --target builder -t owntone:latest-builder . docker run -u $(id -u) --name owntone-build --rm -it -v $(pwd)/dist/:/mnt/dist/ owntone:latest-builder cp -r /usr/local/src/dist/. /mnt/dist/ -docker build --pull --build-arg "VITE_OWNTONE_URL=$VITE_OWNTONE_URL" -t ${DOCKER_REPO}/owntone:latest . +docker build --pull --build-arg "VITE_OWNTONE_URL=$VITE_OWNTONE_URL" -t ${DOCKER_REPO}/owntone:${OWNTONE_DOCKER_TAG} . -echo "$VITE_OWNTONE_URL" +if [[ -d "./dist/dark-reader/" && -f "./dist/dark-reader/index.html" ]]; then + echo + echo + ( + set -x + diff --color=always ./dist/dark-reader/index.html ./dist/dark-reader/index.html.orig + ) || true + echo + echo +fi + +echo "VITE_OWNTONE_URL=\"${VITE_OWNTONE_URL}\"" +echo "[owntone/.pipeline/build.sh] done" +echo "----------------------------" diff --git a/owntone/.pipeline/docker-push.sh b/owntone/.pipeline/docker-push.sh index b5cd7eb..c01449c 100755 --- a/owntone/.pipeline/docker-push.sh +++ b/owntone/.pipeline/docker-push.sh @@ -4,5 +4,4 @@ set -e source ./.pipeline/owntone.env -docker push ${DOCKER_REPO}/owntone:latest - +docker push ${DOCKER_REPO}/owntone:${OWNTONE_DOCKER_TAG} diff --git a/owntone/.pipeline/init-git.sh b/owntone/.pipeline/init-git.sh index 481208b..e292adb 100755 --- a/owntone/.pipeline/init-git.sh +++ b/owntone/.pipeline/init-git.sh @@ -1,22 +1,24 @@ #!/bin/bash -if [ -d "./${OWNTONE_SRC_REPO_NAME}/.git" ]; then +if [[ -d "./${OWNTONE_SRC_REPO_NAME}/.git" ]]; then echo "clone of the ${OWNTONE_SRC_REPO_NAME} repo exists, updating branch '${OWNTONE_SRC_REPO_BRANCH}'." ( cd ${OWNTONE_SRC_REPO_NAME}/ + git checkout ${OWNTONE_SRC_REPO_BRANCH} git checkout . git clean -fd git remote rm origin git remote add origin ${OWNTONE_SRC_REPO_ORIGIN} git pull origin ${OWNTONE_SRC_REPO_BRANCH} git checkout ${OWNTONE_SRC_REPO_BRANCH} + ) else echo "clone of the ${OWNTONE_SRC_REPO_NAME} does not exist, cloning ${OWNTONE_SRC_REPO_ORIGIN}" git clone ${OWNTONE_SRC_REPO_ORIGIN} fi -if [ -d "./${OWNTONE_APT_REPO_NAME}/.git" ]; then +if [[ -d "./${OWNTONE_APT_REPO_NAME}/.git" ]]; then echo "clone of the ${OWNTONE_APT_REPO_NAME} repo exists, updating branch '${OWNTONE_APT_REPO_BRANCH}'." ( cd ${OWNTONE_APT_REPO_NAME}/ @@ -33,3 +35,24 @@ else fi +echo "pulling and rebasing the branch for the partial filescans PR: https://github.com/owntone/owntone-server/pull/1179" +( + set -e + + cd ${OWNTONE_SRC_REPO_NAME}/ + git checkout ${OWNTONE_SRC_REPO_BRANCH} + + # cleanup and return to the main branch + git branch -D file-scan-dir-path || true + git remote rm whatdoineed2d || true + + # add the repo with the PR branch + git remote add whatdoineed2d https://github.com/whatdoineed2do/forked-daapd + git fetch whatdoineed2d + + #git rebase file-scan-dir-path + + # check out the PR branch and rebase the main branch onto it (works now at least) + git checkout file-scan-dir-path + git rebase ${OWNTONE_SRC_REPO_BRANCH} +) diff --git a/owntone/.pipeline/owntone.env b/owntone/.pipeline/owntone.env index 438201a..f74d266 100644 --- a/owntone/.pipeline/owntone.env +++ b/owntone/.pipeline/owntone.env @@ -7,3 +7,5 @@ export OWNTONE_APT_REPO_NAME="owntone-apt" export OWNTONE_APT_REPO_BRANCH="master" export DOCKER_REPO=git.sudo.is/ben + +export OWNTONE_DOCKER_TAG="file-scan-dir-path" diff --git a/owntone/builder/package-owntone.sh b/owntone/builder/package-owntone.sh index f90d1b2..f65c2b7 100755 --- a/owntone/builder/package-owntone.sh +++ b/owntone/builder/package-owntone.sh @@ -1,18 +1,31 @@ #!/bin/bash set -e +set -x # copy dark-reader.css file from dark-reader (firefox extension), and # the modified index.html. both were placed in # /usr/local/src/dark-reader during the 'docker build`, and copy them # inside of the owntone build before we package it up +# save the diff of the index.html file in the dist/dark-reader dir for later inspection +mkdir -p ${DISTDIR}dark-reader/ +ls -l ${DISTDIR}dark-reader/ +# touch ${DISTDIR}dark-reader/diff-index-html.txt +# diff /usr/local/src/dark-reader/index.html ${DISTDIR}target/usr/share/owntone/htdocs/index.html >> ${DISTDIR}dark-reader/ + +# and save both the dark-reader findex.html file as it is included int he build, and the original index.html +cp ${DISTDIR}target/usr/share/owntone/htdocs/index.html ${DISTDIR}dark-reader/index.html.orig +cp /usr/local/src/dark-reader/index.html ${DISTDIR}dark-reader/ + + +# copy the files into the build cp -v /usr/local/src/dark-reader/dark-reader-full.css ${DISTDIR}/target/usr/share/owntone/htdocs/assets/dark-reader-full.css cp -v /usr/local/src/dark-reader/index.html ${DISTDIR}/target/usr/share/owntone/htdocs/index.html -echo "cat index.html" - -cat ${DISTDIR}/target/usr/share/owntone/htdocs/index.html +# save ls output of the htdocs/assets dir +ls -l ${DISTDIR}/target/usr/share/owntone/htdocs/assets/ > ${DISTDIR}/dark-reader/ls-htdocs-assets.txt +ls -l ${DISTDIR}/target/usr/share/owntone/htdocs/assets/dark-reader-full.css > ${DISTDIR}/dark-reader/ls-htdocs-assets-dark-reader-full.css.txt tar -C ${DISTDIR}/target/ -czf ${DISTDIR}/owntone.tar.gz ${DISTDIR}/target/ -- 2.40.1 From be19bfd69fd3bad18e84442393270b400e259544 Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Fri, 23 Jun 2023 12:13:04 +0200 Subject: [PATCH 2/2] owntone: try enabling dark-reader css again --- owntone/dark-reader/index.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/owntone/dark-reader/index.html b/owntone/dark-reader/index.html index c217502..6c2ca53 100644 --- a/owntone/dark-reader/index.html +++ b/owntone/dark-reader/index.html @@ -18,9 +18,7 @@ OwnTone - +
-- 2.40.1