From f784f483a84257a927e26a33da39466102d65a6a Mon Sep 17 00:00:00 2001 From: jo Date: Sat, 11 Sep 2021 04:07:20 +0200 Subject: [PATCH 1/4] Move composer files in airtime_mvc --- .gitignore | 11 ----------- airtime_mvc/.gitignore | 11 +++++++++++ composer.json => airtime_mvc/composer.json | 0 composer.lock => airtime_mvc/composer.lock | 0 4 files changed, 11 insertions(+), 11 deletions(-) rename composer.json => airtime_mvc/composer.json (100%) rename composer.lock => airtime_mvc/composer.lock (100%) diff --git a/.gitignore b/.gitignore index e7f374ff6..ca462e5e8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,17 +7,6 @@ *~ VERSION -## Github Composer .gitignore -## See https://github.com/github/gitignore/blob/master/Composer.gitignore -################################################################################ - -composer.phar -/vendor/ - -# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control -# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file -# composer.lock - ## Github Python .gitignore ## See https://github.com/github/gitignore/blob/master/Python.gitignore ################################################################################ diff --git a/airtime_mvc/.gitignore b/airtime_mvc/.gitignore index b74fe9c95..47ac046c3 100644 --- a/airtime_mvc/.gitignore +++ b/airtime_mvc/.gitignore @@ -4,3 +4,14 @@ /tests/*.jar /tests/results.html /tests/test_results.xml + +## Github Composer .gitignore +## See https://github.com/github/gitignore/blob/master/Composer.gitignore +################################################################################ + +composer.phar +/vendor/ + +# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control +# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file +# composer.lock diff --git a/composer.json b/airtime_mvc/composer.json similarity index 100% rename from composer.json rename to airtime_mvc/composer.json diff --git a/composer.lock b/airtime_mvc/composer.lock similarity index 100% rename from composer.lock rename to airtime_mvc/composer.lock From 03b109dcb5fcb33d23895c544975216969010b8d Mon Sep 17 00:00:00 2001 From: jo Date: Sat, 11 Sep 2021 04:20:50 +0200 Subject: [PATCH 2/4] Fix paths after composer.* files move --- .github/scripts/release.sh | 6 ++++-- .github/workflows/test.yml | 5 +++-- airtime_mvc/composer.json | 4 ++-- airtime_mvc/public/index.php | 2 +- airtime_mvc/public/setup/general-setup.php | 2 +- airtime_mvc/public/setup/media-setup.php | 2 +- airtime_mvc/public/setup/setup-functions.php | 2 +- airtime_mvc/tests/application/bootstrap.php | 8 ++++---- build.sh | 2 ++ dev_tools/propel_regenerate.sh | 2 +- dev_tools/release/release.sh | 6 ++++-- install | 2 -- 12 files changed, 24 insertions(+), 19 deletions(-) diff --git a/.github/scripts/release.sh b/.github/scripts/release.sh index 5dc03e557..95f6f7e60 100755 --- a/.github/scripts/release.sh +++ b/.github/scripts/release.sh @@ -28,7 +28,9 @@ echo -n "${suffix}" > ./VERSION echo " Done" echo -n "Running composer install..." +pushd airtime_mvc || (echo "could not cd in airtime_mvc!" && exit 1) composer install --quiet --no-dev --ignore-platform-reqs +popd || exit echo " Done" # Adding back; may be useful later... @@ -50,7 +52,7 @@ tar -czf "libretime-${suffix}.tar.gz" \ --exclude .travis.yml \ --exclude travis \ --exclude dev_tools \ - --exclude vendor/phing \ - --exclude vendor/simplepie/simplepie/tests \ + --exclude airtime_mvc/vendor/phing \ + --exclude airtime_mvc/vendor/simplepie/simplepie/tests \ libretime echo " Done" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bab069b74..623d79f5b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -87,14 +87,15 @@ jobs: - name: Install dependencies run: | composer install --no-progress --dev + working-directory: airtime_mvc - name: Run PHP tests run: | sudo mkdir -p "$LIBRETIME_LOG_DIR" sudo chown runner:runner "$LIBRETIME_LOG_DIR" - cd airtime_mvc/tests - php ../../vendor/bin/phpunit + php ../vendor/bin/phpunit + working-directory: airtime_mvc/tests test: runs-on: ubuntu-latest diff --git a/airtime_mvc/composer.json b/airtime_mvc/composer.json index 8b53c29cc..7c4b1928b 100644 --- a/airtime_mvc/composer.json +++ b/airtime_mvc/composer.json @@ -1,12 +1,12 @@ { "autoload": { "classmap": [ - "airtime_mvc/application/" + "application/" ] }, "autoload-dev": { "classmap": [ - "airtime_mvc/tests/application/", + "tests/application/", "vendor/phpunit/dbunit/src/" ] }, diff --git a/airtime_mvc/public/index.php b/airtime_mvc/public/index.php index 836bb95de..94dbbbe0c 100644 --- a/airtime_mvc/public/index.php +++ b/airtime_mvc/public/index.php @@ -28,7 +28,7 @@ define('BUILD_PATH', ROOT_PATH . 'build/'); define('SETUP_PATH', BUILD_PATH . 'airtime-setup/'); define('APPLICATION_PATH', ROOT_PATH . 'application/'); define('CONFIG_PATH', APPLICATION_PATH . 'configs/'); -define('VENDOR_PATH', ROOT_PATH . '../vendor/'); +define('VENDOR_PATH', ROOT_PATH . 'vendor/'); define('REST_MODULE_CONTROLLER_PATH', APPLICATION_PATH . 'modules/rest/controllers/'); define("AIRTIME_CONFIG_STOR", "/etc/airtime/"); diff --git a/airtime_mvc/public/setup/general-setup.php b/airtime_mvc/public/setup/general-setup.php index 7032f1055..a32368f27 100644 --- a/airtime_mvc/public/setup/general-setup.php +++ b/airtime_mvc/public/setup/general-setup.php @@ -2,7 +2,7 @@ define("CONFIG_PATH", dirname(dirname( __DIR__)) . "/application/configs/"); -require_once(dirname(dirname( __DIR__)) . "/../vendor/propel/propel1/runtime/lib/Propel.php"); +require_once(dirname(dirname( __DIR__)) . "/vendor/propel/propel1/runtime/lib/Propel.php"); require_once(CONFIG_PATH . 'conf.php'); require_once(dirname(dirname( __DIR__)) . "/application/models/airtime/CcPref.php"); require_once(dirname(dirname( __DIR__)) . "/application/models/airtime/CcPrefPeer.php"); diff --git a/airtime_mvc/public/setup/media-setup.php b/airtime_mvc/public/setup/media-setup.php index 8fce8ba53..5601cb498 100644 --- a/airtime_mvc/public/setup/media-setup.php +++ b/airtime_mvc/public/setup/media-setup.php @@ -3,7 +3,7 @@ define("CONFIG_PATH", dirname(dirname( __DIR__)) . "/application/configs/"); define("DEFAULT_STOR_DIR", "/srv/airtime/stor/"); -require_once(dirname(dirname( __DIR__)) . "/../vendor/propel/propel1/runtime/lib/Propel.php"); +require_once(dirname(dirname( __DIR__)) . "/vendor/propel/propel1/runtime/lib/Propel.php"); require_once(CONFIG_PATH . 'conf.php'); require_once(dirname(dirname( __DIR__)) . "/application/models/airtime/map/CcMusicDirsTableMap.php"); diff --git a/airtime_mvc/public/setup/setup-functions.php b/airtime_mvc/public/setup/setup-functions.php index 37c179693..519fab589 100644 --- a/airtime_mvc/public/setup/setup-functions.php +++ b/airtime_mvc/public/setup/setup-functions.php @@ -6,7 +6,7 @@ define("RMQ_INI_TEMP_PATH", "/tmp/rabbitmq.ini.tmp"); // load autoloader since this files is an entry path see // the end of the file for the "server" that is being // executed. -require_once __DIR__ . '/../../../vendor/autoload.php'; +require_once __DIR__ . '/../../vendor/autoload.php'; /** * Class Setup diff --git a/airtime_mvc/tests/application/bootstrap.php b/airtime_mvc/tests/application/bootstrap.php index 857399f1e..760d42378 100644 --- a/airtime_mvc/tests/application/bootstrap.php +++ b/airtime_mvc/tests/application/bootstrap.php @@ -2,7 +2,7 @@ error_reporting(E_ALL | E_STRICT); // load composer autoloader -require_once __DIR__.'/../../../vendor/autoload.php'; +require_once __DIR__ . '/../../vendor/autoload.php'; // Define path to application directory defined('APPLICATION_PATH') @@ -30,13 +30,13 @@ set_include_path(implode(PATH_SEPARATOR, array( // Ensure vendor/ is on the include path set_include_path(implode(PATH_SEPARATOR, array( get_include_path(), - realpath(APPLICATION_PATH . '/../../vendor'), - realpath(APPLICATION_PATH . '/../../vendor/zf1s/zend-loader/library') + realpath(APPLICATION_PATH . '/../vendor'), + realpath(APPLICATION_PATH . '/../vendor/zf1s/zend-loader/library') ))); set_include_path(implode(PATH_SEPARATOR, array( get_include_path(), - realpath(APPLICATION_PATH . '/../../vendor/propel/propel1/runtime/lib') + realpath(APPLICATION_PATH . '/../vendor/propel/propel1/runtime/lib') ))); // Ensure library/ is on include_path diff --git a/build.sh b/build.sh index 2fbd3fa3d..718d8d1eb 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,9 @@ set -e # Exit if any of the steps fails. +pushd airtime_mvc || (echo "could not cd in airtime_mvc!" && exit 1) composer install --no-dev --no-interaction +popd || exit git_build="" if [ -d .git ]; then diff --git a/dev_tools/propel_regenerate.sh b/dev_tools/propel_regenerate.sh index 31dfd01c1..3c3f82815 100755 --- a/dev_tools/propel_regenerate.sh +++ b/dev_tools/propel_regenerate.sh @@ -11,4 +11,4 @@ cd "$SCRIPTPATH/../airtime_mvc/" || (echo "could not cd in $SCRIPTPATH/../airtim path=$(pwd) cd build sed -i "s|\"project\.home =.*$\"|\"project.home = $path\"|g" build.properties -../../vendor/propel/propel1/generator/bin/propel-gen +../vendor/propel/propel1/generator/bin/propel-gen diff --git a/dev_tools/release/release.sh b/dev_tools/release/release.sh index 4fac2376a..a5c37ad62 100755 --- a/dev_tools/release/release.sh +++ b/dev_tools/release/release.sh @@ -51,7 +51,9 @@ git checkout --quiet tags/${suffix} echo " Done" echo -n "Running composer install..." +pushd airtime_mvc || (echo "could not cd in airtime_mvc!" && exit 1) composer install --quiet --no-dev --ignore-platform-reqs +popd || exit echo " Done" popd @@ -74,8 +76,8 @@ tar -czf $target_file \ --exclude .travis.yml \ --exclude travis \ --exclude dev_tools \ - --exclude vendor/phing \ - --exclude vendor/simplepie/simplepie/tests \ + --exclude airtime_mvc/vendor/phing \ + --exclude airtime_mvc/vendor/simplepie/simplepie/tests \ libretime-${suffix} echo " Done" popd diff --git a/install b/install index 4fc6391ba..dada559c9 100755 --- a/install +++ b/install @@ -865,7 +865,6 @@ if [ "$in_place" = "t" ]; then elif [ -n "$web_root" ]; then verbose "\n * Creating Apache web root directory..." cp -R ${AIRTIMEROOT}/airtime_mvc ${web_root} - cp -R ${AIRTIMEROOT}/vendor ${web_root} cp ${AIRTIMEROOT}/VERSION ${web_root} web_root=${web_root}/airtime_mvc/public/ else @@ -873,7 +872,6 @@ else web_root="/usr/share/airtime/php" mkdir -p ${web_root} cp -R ${AIRTIMEROOT}/airtime_mvc ${web_root} - cp -R ${AIRTIMEROOT}/vendor ${web_root} cp ${AIRTIMEROOT}/VERSION ${web_root} web_root=${web_root}/airtime_mvc/public/ fi From f161fb0e0a7377cd0213d613095a8f709415354f Mon Sep 17 00:00:00 2001 From: jo Date: Sat, 11 Sep 2021 04:21:19 +0200 Subject: [PATCH 3/4] Remove duplicate script --- dev_tools/release/release.sh | 85 ------------------------------------ 1 file changed, 85 deletions(-) delete mode 100755 dev_tools/release/release.sh diff --git a/dev_tools/release/release.sh b/dev_tools/release/release.sh deleted file mode 100755 index a5c37ad62..000000000 --- a/dev_tools/release/release.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env bash - -set -e - -#release.sh 1.8.2 -#creates a libretime folder with a "1.8.2" suffix -#creates tarballs with a "1.8.2" suffix - -#release.sh 1.8.2 RC -#creates a libretime folder with a "1.8.2-RC" suffix -#creates tarballs with a "1.8.2-RC" suffix - -#release.sh 1.8.2-RC -#creates a libretime folder with a "1.8.2-RC" suffix -#creates tarballs with a "1.8.2-RC" suffix - -if [ $# == 0 ]; then - echo "Zero arguments" - exit -elif [ $# == 1 ]; then - suffix=$1 - # version=$1 -else - suffix=$1-$2 - # version=$1 -fi - -# dir=$(dirname "$(readlink -f "$0")") -gitrepo=$(readlink -f ./../../) - -echo "Creating tarball for LibreTime ${suffix}." - -target=/tmp/libretime-${suffix} -target_file=${gitrepo}/build/libretime-${suffix}.tar.gz - -rm -rf $target -rm -f $target_file -echo -n "Cloning temporary git repo..." -git clone --quiet --depth=1 file://$gitrepo $target -echo " Done" - -echo -n "Creating VERSION file for ${suffix}..." -echo -n "${suffix}" > ${target}/VERSION -echo " Done" - -pushd $target - -echo -n "Checking out tag ${suffix}..." -git fetch --quiet --tags -git checkout --quiet tags/${suffix} -echo " Done" - -echo -n "Running composer install..." -pushd airtime_mvc || (echo "could not cd in airtime_mvc!" && exit 1) -composer install --quiet --no-dev --ignore-platform-reqs -popd || exit -echo " Done" - -popd - -#echo "Minimizing LibreTime Javascript files..." -#cd $dir -#find $target/airtime_mvc/public/js/airtime/ -iname "*.js" -exec bash -c 'echo {}; jsmin/jsmin < {} > {}.min' \; -#find $target/airtime_mvc/public/js/airtime/ -iname "*.js" -exec mv {}.min {} \; -#echo "Done" - -pushd /tmp/ -find libretime-${suffix} -type f -exec dos2unix {} \; -echo -n "Creating tarball..." -tar -czf $target_file \ - --owner=root --group=root \ - --exclude-vcs \ - --exclude .zfproject.xml \ - --exclude .gitignore \ - --exclude .gitattributes \ - --exclude .travis.yml \ - --exclude travis \ - --exclude dev_tools \ - --exclude airtime_mvc/vendor/phing \ - --exclude airtime_mvc/vendor/simplepie/simplepie/tests \ - libretime-${suffix} -echo " Done" -popd - -echo "Output file available at $target_file" From 9a7c3e0d212f6a26cbe9769d5f379de05b757d84 Mon Sep 17 00:00:00 2001 From: jo Date: Sat, 11 Sep 2021 04:45:07 +0200 Subject: [PATCH 4/4] Replace build.sh with make to manage airtime_mvc --- .github/workflows/test.yml | 12 +++--------- Makefile | 3 +++ airtime_mvc/Makefile | 12 ++++++++++++ build.sh | 32 -------------------------------- install | 5 +++-- tools/version.sh | 24 ++++++++++++++++++++++++ 6 files changed, 45 insertions(+), 43 deletions(-) create mode 100644 airtime_mvc/Makefile delete mode 100755 build.sh create mode 100755 tools/version.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 623d79f5b..a3f98baf0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -84,18 +84,12 @@ jobs: restore-keys: | ${{ runner.os }}-composer- - - name: Install dependencies - run: | - composer install --no-progress --dev - working-directory: airtime_mvc - - - name: Run PHP tests + - name: Run tests run: | sudo mkdir -p "$LIBRETIME_LOG_DIR" sudo chown runner:runner "$LIBRETIME_LOG_DIR" - - php ../vendor/bin/phpunit - working-directory: airtime_mvc/tests + make test + working-directory: airtime_mvc test: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index c2e69bef5..cd01c8fc3 100644 --- a/Makefile +++ b/Makefile @@ -14,3 +14,6 @@ shell-format: shell-check: shfmt -f . | xargs shfmt -i 2 -ci -sr -kp -d shfmt -f . | xargs shellcheck --color=always --severity=$${SEVERITY:-style} + +VERSION: + tools/version.sh diff --git a/airtime_mvc/Makefile b/airtime_mvc/Makefile new file mode 100644 index 000000000..664e1d9d5 --- /dev/null +++ b/airtime_mvc/Makefile @@ -0,0 +1,12 @@ +.PHONY: build + +SHELL = bash + +vendor: + composer install --no-progress --no-interaction + +test: vendor + cd tests && ../vendor/bin/phpunit + +build: + composer install --no-progress --no-interaction --no-dev diff --git a/build.sh b/build.sh deleted file mode 100755 index 718d8d1eb..000000000 --- a/build.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -set -e # Exit if any of the steps fails. - -pushd airtime_mvc || (echo "could not cd in airtime_mvc!" && exit 1) -composer install --no-dev --no-interaction -popd || exit - -git_build="" -if [ -d .git ]; then - echo " * Building from Git" - git_build="y" -fi - -if [ "${git_build}" = "y" ]; then - git_version=$(git tag --points-at HEAD) - echo " * Version from tag: ${git_version}" - if [ "${git_version}" = "" ]; then - git_version=$(git rev-parse --short HEAD) - echo " * Overriding empty version with sha1 commit-ish: ${git_version}" - fi - echo "${git_version}" > VERSION -else - # if no file was in tarball we create one letting the user know - # if you run in to this you should grab an enriched tarball built - # by travis. It already contains the VERSION file and also bundles - # all the PHP you vendors files making the install much faster on - # your part. - if [ ! -f VERSION ]; then - echo "could not detect version for VERSION file" > VERSION - fi -fi diff --git a/install b/install index dada559c9..9e60dce93 100755 --- a/install +++ b/install @@ -797,8 +797,9 @@ if [[ ! ${commandFound} -eq 0 ]]; then PATH="${PATH}:/usr/local/bin" fi -# Run composer (install PHP dependencies) and create a VERSION file -loudCmd "bash ./build.sh" +make VERSION # Create a VERSION file +make -C airtime_mvc build # Install php dependencies with composer + if [ -f /etc/airtime/airtime.conf ]; then # TODO use VERSION or some other way to check for updates and handle # media-monitor case on it's own diff --git a/tools/version.sh b/tools/version.sh new file mode 100755 index 000000000..e559af385 --- /dev/null +++ b/tools/version.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -u + +error() { + echo >&2 "error: $*" + exit 1 +} + +command -v git > /dev/null || error "git command not found!" +command -v tee > /dev/null || error "tee command not found!" + +typeset -r version_file="VERSION" + +if [[ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" == "true" ]]; then + tag=$(git tag --points-at HEAD | tee "$version_file" || error "could not extract tag") + if [[ -z "$tag" ]]; then + git rev-parse --short HEAD > "$version_file" || error "could not extract commit sha" + fi +else + if [[ ! -f "$version_file" ]]; then + echo "could not detect version" > VERSION + fi +fi