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();
34
34
patchTargetSdkVersion ( ) ;
35
35
36
36
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
+
37
58
function patchTargetSdkVersion ( ) {
38
59
const prefix = execSync ( 'npm prefix' ) . toString ( ) . trim ( ) ;
39
60
const gradleFile = path . join ( prefix , 'platforms/android/app/build.gradle' ) ;
@@ -49,13 +70,16 @@ function patchTargetSdkVersion() {
49
70
50
71
if ( sdkRegex . test ( content ) ) {
51
72
let api = "35" ;
52
- const froidFlag = path . join ( prefix , 'fdroid.bool' ) ;
73
+ const froidFlag = path . join ( getTmpDir ( ) , 'fdroid.bool' ) ;
53
74
54
75
if ( fs . existsSync ( froidFlag ) ) {
55
76
const fdroid = fs . readFileSync ( froidFlag , 'utf-8' ) . trim ( ) ;
56
77
if ( fdroid == "true" ) {
57
78
api = "28" ;
58
79
}
80
+ } else {
81
+ console . error ( `${ getTmpDir ( ) } /fdroid.bool not found` ) ;
82
+ process . exit ( 1 ) ;
59
83
}
60
84
61
85
content = content . replace ( sdkRegex , 'targetSdkVersion ' + api ) ;
Original file line number Diff line number Diff line change 36
36
"cordova-plugin-websocket" : {},
37
37
"cordova-plugin-buildinfo" : {},
38
38
"com.foxdebug.acode.rk.exec.terminal" : {},
39
- "com.foxdebug.acode.rk.exec.proot" : {},
40
39
"cordova-plugin-browser" : {},
41
40
"cordova-plugin-system" : {}
42
41
},
63
62
"@types/url-parse" : " ^1.4.11" ,
64
63
"autoprefixer" : " ^10.4.21" ,
65
64
"babel-loader" : " ^10.0.0" ,
66
- "com.foxdebug.acode.rk.exec.proot" : " file:src/plugins/proot" ,
67
65
"com.foxdebug.acode.rk.exec.terminal" : " file:src/plugins/terminal" ,
68
66
"cordova-android" : " ^14.0.1" ,
69
67
"cordova-clipboard" : " ^1.3.0" ,
Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /bin/bash
2
2
3
- app=" $1 "
4
- mode=" $2 "
5
- fdroidFlag=" $3 "
3
+ # Default values
4
+ app=" paid"
5
+ mode=" d"
6
+ fdroidFlag=" "
6
7
webpackmode=" development"
7
8
cordovamode=" "
8
9
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
+
9
28
root=$( npm prefix)
10
29
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
11
38
12
39
if [[ " $fdroidFlag " == " fdroid" ]]; then
13
- echo " true" > " $root /fdroid.bool"
40
+ echo " true" > " $tmpdir /fdroid.bool"
14
41
cordova plugin remove com.foxdebug.acode.rk.exec.proot
15
-
16
42
else
17
- echo " false" > " $root /fdroid.bool"
43
+ echo " false" > " $tmpdir /fdroid.bool"
18
44
cordova plugin add src/plugins/proot/
19
45
fi
20
46
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
31
48
if [ " $mode " = " p" ] || [ " $mode " = " prod" ]
32
49
then
33
50
mode=" p"
@@ -50,4 +67,4 @@ $script2&&
50
67
# $script3 ;
51
68
echo \" ${RED} $script4 ${NC} \" ;
52
69
$script4 ;
53
- "
70
+ "
You can’t perform that action at this time.
0 commit comments