Skip to content

Commit 7f3f5e1

Browse files
update installer
1 parent 05dfa3f commit 7f3f5e1

File tree

5 files changed

+70
-34
lines changed

5 files changed

+70
-34
lines changed

install.sh

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
#!/usr/bin/env bash
22

3-
TPREFIX="/data/data/com.termux/files"
4-
BIN_DIR="${TPREFIX}/usr/bin"
5-
UDROID_FILE="scripts/udroid/udroid.sh"
6-
7-
echo "setting udroid..."
8-
9-
if [ -f $UDROID_FILE ]; then
10-
if [ -f ${BIN_DIR}/udroid.sh ]; then
11-
rm -rf "${BIN_DIR}/udroid.sh"
12-
fi
13-
cp ${UDROID_FILE} ${BIN_DIR}/udroid
14-
chmod 775 ${BIN_DIR}/udroid
15-
else
16-
echo "Installation Failed..."
3+
[[ ! -d udroid/src ]] && {
4+
echo "udroid/src not found"
175
exit 1
18-
fi
6+
}
197

20-
echo "Done"
8+
cd udroid/src || exit 1
219

22-
exit 0
10+
bash install.sh

udroid/src/install.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
BIN="$PREFIX/bin"
44
INSTALL_DIR="${PREFIX}/etc/udroid"
55

6-
FSDIR="${PREFIX}/var/lib/udroid"
7-
FS_INSTALL_DIR="${FS_DIR}/installed_fs"
8-
DLCACHE="${FSDIR}/dlcache"
6+
DEFAULT_ROOT="${PREFIX}/var/lib/udroid"
7+
DEFAULT_FS_INSTALL_DIR="${FS_DIR}/installed_fs"
8+
DLCACHE="${DEFAULT_ROOT}/dlcache"
99
RTCACHE="${RTR}/.cache"
1010

1111
[[ -f ./gum_wrapper.sh ]] && source ./gum_wrapper.sh
@@ -21,8 +21,8 @@ function create_dir() {
2121
}
2222

2323
create_dir $INSTALL_DIR
24-
create_dir $FSDIR
25-
create_dir $FS_INSTALL_DIR
24+
create_dir $DEFAULT_ROOT
25+
create_dir $DEFAULT_FS_INSTALL_DIR
2626
create_dir $DLCACHE
2727
create_dir $RTCACHE
2828

udroid/src/install_sim.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
2-
BIN="/root/anyc/fs-manager-udroid/bin"
3-
INSTALL_DIR="/root/anyc/fs-manager-udroid/test"
2+
BIN="fs-manager-udroid/bin"
3+
INSTALL_DIR="fs-manager-udroid/test"
44

55
sleep 2
66
ln -sv $INSTALL_DIR/udroid.sh $BIN/udroid

udroid/src/proot-utils/proot-utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ p_extract() {
2727
done
2828

2929
[[ -z $file ]] && msg "file not specified" && return 1
30-
[[ -z $path ]] && echo "no path provided" && exit 1
30+
[[ -z $path ]] && echo "no path provided" && exit 1
3131
[[ ! -f $file ]] && msg "file not found" && return 1
3232
[[ ! -d $path ]] && msg "path not found" && return 1
3333

udroid/src/udroid.sh

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ source gum_wrapper.sh
99
export distro_data
1010

1111
RTR="${PREFIX}/etc/udroid"
12+
DEFAULT_ROOT="${PREFIX}/var/lib/udroid"
13+
DEFAULT_FS_INSTALL_DIR="installed-filesystems"
1214
DLCACHE="${TODO_DIR}/dlcache"
1315
RTCACHE="${RTR}/.cache"
1416

@@ -30,11 +32,30 @@ fetch_distro_data() {
3032

3133
install() {
3234
local arg=$1
35+
local path=""
3336
local suite=${arg%%:*}
3437
local varient=${arg#*:}
3538

39+
while [[ $# -gt 0 ]]; do
40+
case $1 in
41+
-p | --path)
42+
shift
43+
local path=$1
44+
LOG "(install) custom installation path set to $path"
45+
;;
46+
*) break ;;
47+
esac
48+
done
49+
3650
LOG "[USER] function args => suite=$suite varient=$varient"
37-
[[ -n $TEST_MODE ]] && distro_data=test.json
51+
[[ -n $TEST_MODE ]] && {
52+
LOG "[TEST] test mode enabled"
53+
distro_data=test.json
54+
DLCACHE="./tmp/dlcache"
55+
mkdir -p $DLCACHE
56+
LOG "[TEST] DLCACHE=$DLCACHE"
57+
LOG "[TEST] distro_data=$distro_data"
58+
}
3859

3960
############### START OF OPTION PARSER ##############
4061

@@ -67,7 +88,7 @@ install() {
6788
}
6889

6990
# Check if somehow suite and varient are same ( which is not the case )
70-
if [[ $suite -eq $varient ]]; then
91+
if [[ "$suite" == "$varient" ]]; then
7192
[[ -n "$suite" ]] && [[ -n "$varient" ]] && {
7293
ELOG "Parsing error in [$arg] (both can't be same)"
7394
LOG "function args => suite=$suite varient=$varient"
@@ -108,11 +129,30 @@ install() {
108129
exit 1
109130
}
110131

111-
# echo "$link + $name"
112-
download "$name" "$link"
113-
114-
# Start Extracting
115-
p_extract --file "$DLCACHE/$name" --path "$TODO_DIR"
132+
# file extension
133+
ext=$(echo $link | awk -F. '{print $NF}')
134+
135+
# if path is set then download fs and extract it to path
136+
# cause it make better use of path
137+
if [[ -z $path ]]; then
138+
# echo "$link + $name"
139+
download "$name.tar.$ext" "$link"
140+
141+
# Start Extracting
142+
LOG "Extracting $name.tar.$ext"
143+
p_extract --file "$DLCACHE/$name.tar.$ext" --path "$DEFAULT_FS_INSTALL_DIR/$name"
144+
else
145+
download "$name.tar.$ext" "$link" "$path"
146+
147+
[[ -d $path ]] && {
148+
LOG "Extracting $name.tar.$ext"
149+
mkdir -p $path/$name
150+
} || {
151+
ELOG "ERROR: path $path not found"
152+
echo "ERROR: path $path not found"
153+
}
154+
p_extract --file "$path/$name.tar.$ext" --path "$path/$name"
155+
fi
116156

117157
}
118158

@@ -125,11 +165,19 @@ remove() {
125165
}
126166

127167
####################
128-
downlaod() {
168+
download() {
129169
local name=$1
130170
local link=$2
131171

132-
axel -o ${DLCACHE}/$name $link
172+
[[ -n "$3" ]] && local path=$3
173+
[[ -z $path ]] && path="$DLCACHE"
174+
175+
LOG "download() args => name=$name link=$link path=$path"
176+
axel -a -o ${path}/$name $link || {
177+
ELOG "failed to download $name"
178+
echo "failed to download $name"
179+
exit 1
180+
}
133181
}
134182
####################
135183

0 commit comments

Comments
 (0)