diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5a559cf..b620399 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -132,7 +132,7 @@ jobs: - name: Build DAHDI and Asterisk run: | sudo ./phreaknet.sh make - sudo phreaknet install --fast --dahdi --drivers --devmode --sip + GIT_REPO_PATH=$PWD sudo phreaknet install --fast --dahdi --drivers --devmode --sip ubuntu-stable: runs-on: ubuntu-22.04 name: Ubuntu 22.04 @@ -142,7 +142,7 @@ jobs: - name: Build DAHDI and Asterisk run: | sudo ./phreaknet.sh make - sudo phreaknet install --fast --dahdi --drivers --devmode --sip + GIT_REPO_PATH=$PWD sudo phreaknet install --fast --dahdi --drivers --devmode --sip debian-stable-asterisk-lts: runs-on: ubuntu-24.04 name: Debian 12, Asterisk 20 @@ -152,7 +152,7 @@ jobs: - name: Build DAHDI and Asterisk run: | ./phreaknet.sh make - phreaknet install --fast --dahdi --drivers --sip --testsuite --version=20 + GIT_REPO_PATH=$PWD phreaknet install --fast --dahdi --drivers --sip --testsuite --version=20 - name: Run tests run: | phreaknet runtests @@ -165,7 +165,7 @@ jobs: - name: Build DAHDI and Asterisk run: | ./phreaknet.sh make - phreaknet install --fast --dahdi --drivers --sip --testsuite + GIT_REPO_PATH=$PWD phreaknet install --fast --dahdi --drivers --sip --testsuite - name: Run tests run: | phreaknet runtests @@ -178,7 +178,7 @@ jobs: - name: Build DAHDI and Asterisk run: | ./phreaknet.sh make - phreaknet install --fast --dahdi --devmode --sip --vanilla --user=asterisk + GIT_REPO_PATH=$PWD phreaknet install --fast --dahdi --devmode --sip --vanilla --user=asterisk fedora-42: runs-on: ubuntu-24.04 name: Fedora 42 @@ -188,7 +188,7 @@ jobs: - name: Build DAHDI and Asterisk run: | ./phreaknet.sh make - phreaknet install --fast --dahdi --autokvers --drivers --devmode + GIT_REPO_PATH=$PWD phreaknet install --fast --dahdi --autokvers --drivers --devmode alma-9-5: runs-on: ubuntu-24.04 name: Alma Linux 9.5 @@ -198,7 +198,7 @@ jobs: - name: Build DAHDI and Asterisk run: | ./phreaknet.sh make - phreaknet install --fast --dahdi --autokvers --drivers --devmode + GIT_REPO_PATH=$PWD phreaknet install --fast --dahdi --autokvers --drivers --devmode rocky-9: runs-on: ubuntu-24.04 name: Rocky Linux 9.3 @@ -208,7 +208,7 @@ jobs: - name: Build DAHDI and Asterisk run: | ./phreaknet.sh make - phreaknet install --fast --dahdi --autokvers --drivers --devmode + GIT_REPO_PATH=$PWD phreaknet install --fast --dahdi --autokvers --drivers --devmode rocky-8: runs-on: ubuntu-24.04 name: Rocky Linux 8.9 @@ -218,7 +218,7 @@ jobs: - name: Build DAHDI and Asterisk run: | ./phreaknet.sh make - phreaknet install --fast --dahdi --autokvers --drivers --devmode + GIT_REPO_PATH=$PWD phreaknet install --fast --dahdi --autokvers --drivers --devmode opensuse: runs-on: ubuntu-24.04 name: openSUSE Tumbleweed @@ -228,7 +228,7 @@ jobs: - name: Build Asterisk run: | ./phreaknet.sh make - phreaknet install --fast --devmode --sip + GIT_REPO_PATH=$PWD phreaknet install --fast --devmode --sip archlinux: runs-on: ubuntu-24.04 name: Arch Linux @@ -238,7 +238,7 @@ jobs: - name: Build DAHDI and Asterisk run: | ./phreaknet.sh make - phreaknet install --fast --dahdi --drivers --devmode --sip + GIT_REPO_PATH=$PWD phreaknet install --fast --dahdi --drivers --devmode --sip # FreeBSD CI disabled since libuuid headers can't get installed in CI? # freebsd-14: # runs-on: ubuntu-24.04 diff --git a/phreaknet.sh b/phreaknet.sh index 7d4b2d0..9c183ca 100755 --- a/phreaknet.sh +++ b/phreaknet.sh @@ -2107,9 +2107,9 @@ install_dahdi() { phreak_tree_module() { # $1 = file to patch, $2 = whether failure is acceptable printf "Adding new module: %s\n" "$1" - wget -q "https://raw.githubusercontent.com/InterLinked1/phreakscript/master/$1" -O "$AST_SOURCE_PARENT_DIR/$AST_SRC_DIR/$1" --no-cache + cp "$GIT_REPO_PATH/$1" "$AST_SOURCE_PARENT_DIR/$AST_SRC_DIR/$1" if [ $? -ne 0 ]; then - echoerr "Failed to download module: $1" + echoerr "Failed to copy module: $1" if [ "$2" != "1" ]; then # unless failure is acceptable, abort exit 2 fi @@ -2118,6 +2118,7 @@ phreak_tree_module() { # $1 = file to patch, $2 = whether failure is acceptable phreak_tree_module_branch() { # $1 = file to patch, $2 = whether failure is acceptable, $3 = branch name printf "Adding new module: %s\n" "$1" + # Always need to download, since the local copy of the git repo is on the master branch wget -q "https://raw.githubusercontent.com/InterLinked1/phreakscript/$3/$1" -O "$AST_SOURCE_PARENT_DIR/$AST_SRC_DIR/$1" --no-cache if [ $? -ne 0 ]; then echoerr "Failed to download module from branch $3, retrying with master..." @@ -2154,9 +2155,9 @@ phreak_nontree_patch() { # $1 = patched file, $2 = patch name phreak_tree_patch() { # $1 = patched file, $2 = patch name printf "Applying patch %s to %s\n" "$2" "$1" - wget -q "https://raw.githubusercontent.com/InterLinked1/phreakscript/master/patches/$2" -O "/tmp/$2" --no-cache + cp "$GIT_REPO_PATH/patches/$2" "/tmp/$2" if [ $? -ne 0 ]; then - echoerr "Failed to download patch: $2" + echoerr "Failed to copy patch: $2" exit 2 fi patch -u -b "$1" -i "/tmp/$2" @@ -2243,13 +2244,41 @@ add_experimental() { custom_module "res/res_pjsip_sca_body_generator.c" "https://code.phreaknet.org/asterisk/res_pjsip_sca_body_generator.c" } +# Instantiate an instance of the PhreakScript repository, if not already present +# This is necessary since this script file is designed to be able to be used standalone, +# without the rest of the repoistory necessarily being present. +instantiate_repo() { + # GitHub no longers allows svn access (which was useful to download a subset of a repo) + # Settle for using a shallow clone + # At this point, this is more efficient than individually downloading all of the files + # used by phreak_tree_module and phreak_tree_patch. + if [ "$GIT_REPO_PATH" = "" ]; then + cd /tmp + if [ ! -d phreakscript ]; then + printf "GIT_REPO_PATH not already set and not found in /tmp, cloning...\n" + git clone --depth=1 https://github.com/InterLinked1/phreakscript.git + else + printf "GIT_REPO_PATH not already set but found in /tmp, updating...\n" + cd /tmp/phreakscript + git checkout master + git pull + fi + GIT_REPO_PATH=/tmp/phreakscript + else + printf "GIT_REPO_PATH already provided: %s\n" "$GIT_REPO_PATH" + fi +} + phreak_patches() { # $1 = $PATCH_DIR, $2 = $AST_SRC_DIR ### Inject custom PhreakNet patches to add additional functionality and features. ### If/when/as these are integrated upstream, they will be removed from this function. + instantiate_repo + cd $AST_SOURCE_PARENT_DIR/$2 ## Add Standalone PhreakNet Modules + # XXX In theory, something like cp $GIT_REPO_PATH/apps/*.c apps, etc. would also suffice, rather than enumerating phreak_tree_module "apps/app_acts.c" phreak_tree_module "apps/app_assert.c" phreak_tree_module "apps/app_audichron.c"