@@ -2107,9 +2107,9 @@ install_dahdi() {
21072107
21082108phreak_tree_module () { # $1 = file to patch, $2 = whether failure is acceptable
21092109 printf " Adding new module: %s\n" " $1 "
2110- wget -q " https://raw.githubusercontent.com/InterLinked1/phreakscript/master/ $1 " -O " $AST_SOURCE_PARENT_DIR /$AST_SRC_DIR /$1 " --no-cache
2110+ cp " $GIT_REPO_PATH / $1 " " $AST_SOURCE_PARENT_DIR /$AST_SRC_DIR /$1 "
21112111 if [ $? -ne 0 ]; then
2112- echoerr " Failed to download module: $1 "
2112+ echoerr " Failed to copy module: $1 "
21132113 if [ " $2 " != " 1" ]; then # unless failure is acceptable, abort
21142114 exit 2
21152115 fi
@@ -2118,6 +2118,7 @@ phreak_tree_module() { # $1 = file to patch, $2 = whether failure is acceptable
21182118
21192119phreak_tree_module_branch () { # $1 = file to patch, $2 = whether failure is acceptable, $3 = branch name
21202120 printf " Adding new module: %s\n" " $1 "
2121+ # Always need to download, since the local copy of the git repo is on the master branch
21212122 wget -q " https://raw.githubusercontent.com/InterLinked1/phreakscript/$3 /$1 " -O " $AST_SOURCE_PARENT_DIR /$AST_SRC_DIR /$1 " --no-cache
21222123 if [ $? -ne 0 ]; then
21232124 echoerr " Failed to download module from branch $3 , retrying with master..."
@@ -2154,9 +2155,9 @@ phreak_nontree_patch() { # $1 = patched file, $2 = patch name
21542155
21552156phreak_tree_patch () { # $1 = patched file, $2 = patch name
21562157 printf " Applying patch %s to %s\n" " $2 " " $1 "
2157- wget -q " https://raw.githubusercontent.com/InterLinked1/phreakscript/master/ patches/$2 " -O " /tmp/$2 " --no-cache
2158+ cp " $GIT_REPO_PATH / patches/$2 " " /tmp/$2 "
21582159 if [ $? -ne 0 ]; then
2159- echoerr " Failed to download patch: $2 "
2160+ echoerr " Failed to copy patch: $2 "
21602161 exit 2
21612162 fi
21622163 patch -u -b " $1 " -i " /tmp/$2 "
@@ -2243,13 +2244,41 @@ add_experimental() {
22432244 custom_module " res/res_pjsip_sca_body_generator.c" " https://code.phreaknet.org/asterisk/res_pjsip_sca_body_generator.c"
22442245}
22452246
2247+ # Instantiate an instance of the PhreakScript repository, if not already present
2248+ # This is necessary since this script file is designed to be able to be used standalone,
2249+ # without the rest of the repoistory necessarily being present.
2250+ instantiate_repo () {
2251+ # GitHub no longers allows svn access (which was useful to download a subset of a repo)
2252+ # Settle for using a shallow clone
2253+ # At this point, this is more efficient than individually downloading all of the files
2254+ # used by phreak_tree_module and phreak_tree_patch.
2255+ if [ " $GIT_REPO_PATH " = " " ]; then
2256+ cd /tmp
2257+ if [ ! -d phreakscript ]; then
2258+ printf " GIT_REPO_PATH not already set and not found in /tmp, cloning...\n"
2259+ git clone --depth=1 https://github.com/InterLinked1/phreakscript.git
2260+ else
2261+ printf " GIT_REPO_PATH not already set but found in /tmp, updating...\n"
2262+ cd /tmp/phreakscript
2263+ git checkout master
2264+ git pull
2265+ fi
2266+ GIT_REPO_PATH=/tmp/phreakscript
2267+ else
2268+ printf " GIT_REPO_PATH already provided: %s\n" " $GIT_REPO_PATH "
2269+ fi
2270+ }
2271+
22462272phreak_patches () { # $1 = $PATCH_DIR, $2 = $AST_SRC_DIR
22472273 # ## Inject custom PhreakNet patches to add additional functionality and features.
22482274 # ## If/when/as these are integrated upstream, they will be removed from this function.
22492275
2276+ instantiate_repo
2277+
22502278 cd $AST_SOURCE_PARENT_DIR /$2
22512279
22522280 # # Add Standalone PhreakNet Modules
2281+ # XXX In theory, something like cp $GIT_REPO_PATH/apps/*.c apps, etc. would also suffice, rather than enumerating
22532282 phreak_tree_module " apps/app_acts.c"
22542283 phreak_tree_module " apps/app_assert.c"
22552284 phreak_tree_module " apps/app_audichron.c"
0 commit comments