File tree Expand file tree Collapse file tree 4 files changed +61
-27
lines changed
Expand file tree Collapse file tree 4 files changed +61
-27
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,27 @@ enableStaticContext();
3434patchTargetSdkVersion ( ) ;
3535
3636
37+ function getTmpDir ( ) {
38+ const tmpdirEnv = process . env . TMPDIR ;
39+
40+ if ( tmpdirEnv ) {
41+ try {
42+ fs . accessSync ( tmpdirEnv , fs . constants . R_OK | fs . constants . W_OK ) ;
43+ return tmpdirEnv ;
44+ } catch {
45+ // TMPDIR exists but not accessible
46+ }
47+ }
48+
49+ try {
50+ fs . accessSync ( "/tmp" , fs . constants . R_OK | fs . constants . W_OK ) ;
51+ return "/tmp" ;
52+ } catch {
53+ console . error ( "Error: No usable temporary directory found (TMPDIR or /tmp not accessible)." ) ;
54+ process . exit ( 1 ) ;
55+ }
56+ }
57+
3758function patchTargetSdkVersion ( ) {
3859 const prefix = execSync ( 'npm prefix' ) . toString ( ) . trim ( ) ;
3960 const gradleFile = path . join ( prefix , 'platforms/android/app/build.gradle' ) ;
@@ -49,13 +70,16 @@ function patchTargetSdkVersion() {
4970
5071 if ( sdkRegex . test ( content ) ) {
5172 let api = "35" ;
52- const froidFlag = path . join ( prefix , 'fdroid.bool' ) ;
73+ const froidFlag = path . join ( getTmpDir ( ) , 'fdroid.bool' ) ;
5374
5475 if ( fs . existsSync ( froidFlag ) ) {
5576 const fdroid = fs . readFileSync ( froidFlag , 'utf-8' ) . trim ( ) ;
5677 if ( fdroid == "true" ) {
5778 api = "28" ;
5879 }
80+ } else {
81+ console . error ( `${ getTmpDir ( ) } /fdroid.bool not found` ) ;
82+ process . exit ( 1 ) ;
5983 }
6084
6185 content = content . replace ( sdkRegex , 'targetSdkVersion ' + api ) ;
Original file line number Diff line number Diff line change 3636 "cordova-plugin-websocket" : {},
3737 "cordova-plugin-buildinfo" : {},
3838 "com.foxdebug.acode.rk.exec.terminal" : {},
39- "com.foxdebug.acode.rk.exec.proot" : {},
4039 "cordova-plugin-browser" : {},
4140 "cordova-plugin-system" : {}
4241 },
6362 "@types/url-parse" : " ^1.4.11" ,
6463 "autoprefixer" : " ^10.4.21" ,
6564 "babel-loader" : " ^10.0.0" ,
66- "com.foxdebug.acode.rk.exec.proot" : " file:src/plugins/proot" ,
6765 "com.foxdebug.acode.rk.exec.terminal" : " file:src/plugins/terminal" ,
6866 "cordova-android" : " ^14.0.1" ,
6967 "cordova-clipboard" : " ^1.3.0" ,
Original file line number Diff line number Diff line change 1- #! /bin/bash
1+ #! /bin/bash
22
3- app=" $1 "
4- mode=" $2 "
5- fdroidFlag=" $3 "
3+ # Default values
4+ app=" paid"
5+ mode=" d"
6+ fdroidFlag=" "
67webpackmode=" development"
78cordovamode=" "
89
10+ # Check all arguments for specific values
11+ for arg in " $@ " ; do
12+ case " $arg " in
13+ " free" |" paid" )
14+ app=" $arg "
15+ ;;
16+ " p" |" prod" |" d" |" dev" )
17+ mode=" $arg "
18+ ;;
19+ " fdroid" )
20+ fdroidFlag=" fdroid"
21+ ;;
22+ * )
23+ echo " Warning: Unknown argument '$arg ' ignored"
24+ ;;
25+ esac
26+ done
27+
928root=$( npm prefix)
1029
30+ if [ -n " $TMPDIR " ] && [ -r " $TMPDIR " ] && [ -w " $TMPDIR " ]; then
31+ tmpdir=" $TMPDIR "
32+ elif [ -r " /tmp" ] && [ -w " /tmp" ]; then
33+ tmpdir=" /tmp"
34+ else
35+ echo " Error: No usable temporary directory found (TMPDIR or /tmp not accessible)." >&2
36+ exit 1
37+ fi
1138
1239if [[ " $fdroidFlag " == " fdroid" ]]; then
13- echo " true" > " $root /fdroid.bool"
40+ echo " true" > " $tmpdir /fdroid.bool"
1441 cordova plugin remove com.foxdebug.acode.rk.exec.proot
15-
1642else
17- echo " false" > " $root /fdroid.bool"
43+ echo " false" > " $tmpdir /fdroid.bool"
1844 cordova plugin add src/plugins/proot/
1945fi
2046
21- if [ -z " $mode " ]
22- then
23- mode=" d"
24- fi
25-
26- if [ -z " $app " ]
27- then
28- app=" paid"
29- fi
30-
47+ # Normalize mode values
3148if [ " $mode " = " p" ] || [ " $mode " = " prod" ]
3249then
3350mode=" p"
@@ -50,4 +67,4 @@ $script2&&
5067# $script3 ;
5168echo \" ${RED} $script4 ${NC} \" ;
5269$script4 ;
53- "
70+ "
You can’t perform that action at this time.
0 commit comments