@@ -1467,7 +1467,10 @@ dahdi_patch() {
1467
1467
1468
1468
git_patch () {
1469
1469
printf " Applying git patch: %s\n" " $1 "
1470
- wget -q " https://raw.githubusercontent.com/InterLinked1/phreakscript/master/patches/$1 " -O /tmp/$1 --no-cache
1470
+ cp " $GIT_REPO_PATH /patches/$1 " " /tmp/$1 "
1471
+ if [ $? -ne 0 ]; then
1472
+ die " File $1 does not exist"
1473
+ fi
1471
1474
git apply " /tmp/$1 "
1472
1475
if [ $? -ne 0 ]; then
1473
1476
die " Failed to apply git patch $1 ... this should be reported..."
@@ -1517,16 +1520,17 @@ asterisk_pr() {
1517
1520
}
1518
1521
1519
1522
git_custom_patch () {
1523
+ CUSTOM_PATCH_FILE=/tmp/tmp_git_patch.diff
1520
1524
printf " Applying git patch: %s\n" " $1 "
1521
- wget -q " $1 " -O /tmp/tmp_git_patch.diff --no-cache
1522
- if [ ! -f /tmp/tmp_git_patch.diff ]; then
1525
+ wget -q " $1 " -O $CUSTOM_PATCH_FILE --no-cache
1526
+ if [ ! -f $CUSTOM_PATCH_FILE ]; then
1523
1527
die " Failed to download patch $1 "
1524
1528
fi
1525
- git apply " /tmp/tmp_git_patch.diff "
1529
+ git apply $CUSTOM_PATCH_FILE
1526
1530
if [ $? -ne 0 ]; then
1527
1531
die " Failed to apply git patch $1 ... this should be reported..."
1528
1532
fi
1529
- rm " /tmp/tmp_git_patch.diff "
1533
+ rm $CUSTOM_PATCH_FILE
1530
1534
}
1531
1535
1532
1536
dahdi_unpurge () { # undo "great purge" of 2018: $1 = DAHDI_LIN_SRC_DIR
@@ -1866,6 +1870,8 @@ install_dahdi() {
1866
1870
dahdi_unpurge $DAHDI_LIN_SRC_DIR # for some reason, this needs to be applied before the next branch patches
1867
1871
fi
1868
1872
1873
+ instantiate_repo
1874
+
1869
1875
# Compiler fixes for 5.17/5.18:
1870
1876
if [ $DAHDI_MM_VER -lt 33 ]; then
1871
1877
phreak_fuzzy_patch " dahdi_pci.diff"
@@ -2107,9 +2113,9 @@ install_dahdi() {
2107
2113
2108
2114
phreak_tree_module () { # $1 = file to patch, $2 = whether failure is acceptable
2109
2115
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
2116
+ cp " $GIT_REPO_PATH / $1 " " $AST_SOURCE_PARENT_DIR /$AST_SRC_DIR /$1 "
2111
2117
if [ $? -ne 0 ]; then
2112
- echoerr " Failed to download module: $1 "
2118
+ echoerr " Failed to copy module: $1 "
2113
2119
if [ " $2 " != " 1" ]; then # unless failure is acceptable, abort
2114
2120
exit 2
2115
2121
fi
@@ -2118,6 +2124,7 @@ phreak_tree_module() { # $1 = file to patch, $2 = whether failure is acceptable
2118
2124
2119
2125
phreak_tree_module_branch () { # $1 = file to patch, $2 = whether failure is acceptable, $3 = branch name
2120
2126
printf " Adding new module: %s\n" " $1 "
2127
+ # Always need to download, since the local copy of the git repo is on the master branch
2121
2128
wget -q " https://raw.githubusercontent.com/InterLinked1/phreakscript/$3 /$1 " -O " $AST_SOURCE_PARENT_DIR /$AST_SRC_DIR /$1 " --no-cache
2122
2129
if [ $? -ne 0 ]; then
2123
2130
echoerr " Failed to download module from branch $3 , retrying with master..."
@@ -2154,9 +2161,9 @@ phreak_nontree_patch() { # $1 = patched file, $2 = patch name
2154
2161
2155
2162
phreak_tree_patch () { # $1 = patched file, $2 = patch name
2156
2163
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
2164
+ cp " $GIT_REPO_PATH / patches/$2 " " /tmp/$2 "
2158
2165
if [ $? -ne 0 ]; then
2159
- echoerr " Failed to download patch: $2 "
2166
+ echoerr " Failed to copy patch: $2 "
2160
2167
exit 2
2161
2168
fi
2162
2169
patch -u -b " $1 " -i " /tmp/$2 "
@@ -2169,7 +2176,7 @@ phreak_tree_patch() { # $1 = patched file, $2 = patch name
2169
2176
2170
2177
phreak_fuzzy_patch () {
2171
2178
printf " Applying patch %s to %s\n" " $1 " " $1 "
2172
- wget -q " https://raw.githubusercontent.com/InterLinked1/phreakscript/master/ patches/$1 " -O " /tmp/$1 " --no-cache
2179
+ cp " $GIT_REPO_PATH / patches/$1 " " /tmp/$1 "
2173
2180
if [ $? -ne 0 ]; then
2174
2181
echoerr " Failed to download patch: $1 "
2175
2182
exit 2
@@ -2243,13 +2250,51 @@ add_experimental() {
2243
2250
custom_module " res/res_pjsip_sca_body_generator.c" " https://code.phreaknet.org/asterisk/res_pjsip_sca_body_generator.c"
2244
2251
}
2245
2252
2253
+ # Instantiate an instance of the PhreakScript repository, if not already present
2254
+ # This is necessary since this script file is designed to be able to be used standalone,
2255
+ # without the rest of the repository necessarily being present.
2256
+ instantiate_repo () {
2257
+ # GitHub no longers allows svn access (which was useful to download a subset of a repo)
2258
+ # Settle for using a shallow clone
2259
+ # At this point, this is more efficient than individually downloading all of the files
2260
+ # used by phreak_tree_module and phreak_tree_patch.
2261
+ if [ " ${GIT_REPO_PATH} " = " " ]; then
2262
+ # pushd is a bashism, can't use it!
2263
+ ORIG_DIR=" $PWD "
2264
+ cd /tmp
2265
+ if [ ! -d phreakscript ]; then
2266
+ printf " GIT_REPO_PATH not already set and not found in /tmp, cloning...\n"
2267
+ git clone --depth=1 https://github.com/InterLinked1/phreakscript.git
2268
+ else
2269
+ printf " GIT_REPO_PATH not already set but found in /tmp, updating...\n"
2270
+ cd /tmp/phreakscript
2271
+ git checkout master
2272
+ git pull
2273
+ fi
2274
+ GIT_REPO_PATH=/tmp/phreakscript
2275
+ if [ ! -d $GIT_REPO_PATH ]; then
2276
+ die " Directory does not exist: $GIT_REPO_PATH "
2277
+ fi
2278
+ printf " GIT_REPO_PATH is now %s\n" " $GIT_REPO_PATH "
2279
+ cd " $ORIG_DIR "
2280
+ else
2281
+ printf " GIT_REPO_PATH already provided: %s\n" " $GIT_REPO_PATH "
2282
+ if [ ! -d " $GIT_REPO_PATH " ]; then
2283
+ die " Directory does not exist: $GIT_REPO_PATH "
2284
+ fi
2285
+ fi
2286
+ }
2287
+
2246
2288
phreak_patches () { # $1 = $PATCH_DIR, $2 = $AST_SRC_DIR
2247
2289
# ## Inject custom PhreakNet patches to add additional functionality and features.
2248
2290
# ## If/when/as these are integrated upstream, they will be removed from this function.
2249
2291
2292
+ instantiate_repo
2293
+
2250
2294
cd $AST_SOURCE_PARENT_DIR /$2
2251
2295
2252
2296
# # Add Standalone PhreakNet Modules
2297
+ # XXX In theory, something like cp $GIT_REPO_PATH/apps/*.c apps, etc. would also suffice, rather than enumerating
2253
2298
phreak_tree_module " apps/app_acts.c"
2254
2299
phreak_tree_module " apps/app_assert.c"
2255
2300
phreak_tree_module " apps/app_audichron.c"
@@ -3229,6 +3274,7 @@ elif [ "$cmd" = "install" ]; then
3229
3274
echoerr " Distro not supported for package audit"
3230
3275
fi
3231
3276
fi
3277
+
3232
3278
# Install Pre-Reqs
3233
3279
printf " %s %d\n" " Starting installation with country code" $AST_CC
3234
3280
quell_mysql
@@ -3735,6 +3781,7 @@ elif [ "$cmd" = "fullpatch" ]; then
3735
3781
filename=" ${filename} .c"
3736
3782
fi
3737
3783
fi
3784
+ instantiate_repo
3738
3785
phreak_tree_module " $filename "
3739
3786
elif [ " $cmd " = " runtest" ]; then
3740
3787
if [ ${# 2} -eq 0 ]; then
0 commit comments