Skip to content

Commit e5b7834

Browse files
committed
mirror.china;rewrite ext3,4 detect
1 parent 5006eae commit e5b7834

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ rootfs.ext4.base:
1717
menu.json: gen.menu.json.js
1818
./gen.menu.json.js > menu.json
1919

20-
extensions: chroot.shell.sh config.xml install.alpine.sh lib.sh LICENSE remove.sh resize.sh rootfs.ext3.base rootfs.ext4.base umount.sh menu.json
21-
rm -fr $@
20+
extensions: chroot.shell.sh config.xml install.alpine.sh lib.sh LICENSE remove.sh resize.sh rootfs.ext3.base rootfs.ext4.base umount.sh menu.json mirror.china.sh
21+
rm -fr extensions
2222
$(MAKE) -C ./e2fsprogs/
2323
mkdir -p extensions/$(PACKAGE)
2424
cp $^ ./e2fsprogs/out/sbin/resize2fs extensions/$(PACKAGE)

gen.menu.json.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ const kterm_scripts=
55
[
66
["Install Alpine Linux","./install.alpine.sh"],
77
["Shell","./chroot.shell.sh"],
8+
["Change mirror",[
9+
["China Mainland","./mirror.china.sh"]]],
810
["Umount","./umount.sh"],
911
["Resize rootfs","./resize.sh"],
1012
["Remove rootfs",
1113
[["Yes,Remove rootfs","./remove.sh"],
12-
["No",null]],
13-
]]]]]
14+
["No",null]]]]]]]
1415

1516
function translate_kterm_scripts(name,priority,script){
1617
if(script===null||script===void 0){

lib.sh

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,18 @@ fail(){
3636
BIN="$(pwd)"
3737
ROOTFS_DIR="$(pwd)/rootfs"
3838
ROOTFS_IMG="$(pwd)/rootfs.img"
39-
ROOTFS_TYPE=ext3
4039
ROOTFS_LOCK="/tmp/kUaL_lInUx_mOuNtEd"
4140
INNER_TMP="/tmp/kUaL_lInUx"
42-
mkdir -p tmp.testext4
43-
cp rootfs.ext4.base tmp.testext4.img || fail
44-
if mount -o loop tmp.testext4.img tmp.testext4 2>/dev/null; then
45-
echo This kernel support ext4.
41+
ROOTFS_TYPE=unknown
42+
if [ -z "$(grep 'nodev.*ext4' /proc/filesystems)" ] && [ -n "$(grep 'ext4' /proc/filesystems)" ]; then
43+
echo "This kernel support ext4."
4644
ROOTFS_TYPE=ext4
47-
else
48-
mkdir -p tmp.testext3
49-
cp rootfs.ext3.base tmp.testext3.img || fail
50-
mount -o loop tmp.testext3.img tmp.testext3 || fail "This kernel doesn't support ext4 and ext3."
51-
echo This kernel support ext3.
45+
elif [ -z "$(grep 'nodev.*ext3' /proc/filesystems)" ] && [ -n "$(grep 'ext3' /proc/filesystems)" ]; then
46+
echo "This kernel support ext3 and doesn't support ext4."
5247
ROOTFS_TYPE=ext3
48+
else
49+
fail "This kernel doesn't support ext4 and ext3."
5350
fi
54-
umount tmp.testext4 2>/dev/null
55-
umount tmp.testext3 2>/dev/null
56-
rm -fr tmp.*
5751

5852
get_rootfs_tgz_filename(){
5953
curl http://dl-cdn.alpinelinux.org/alpine/edge/releases/armhf/ |

mirror.china.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
. "$(dirname "$0")"/lib.sh
4+
5+
[ -f "$ROOTFS_LOCK" ] || mount_rootfs_all
6+
7+
[ -f "$ROOTFS_DIR/etc/apk/repositories" ] && sed -i 's|https\?://[^/]*/alpine|http://mirrors.ustc.edu.cn/alpine|g' "$ROOTFS_DIR/etc/apk/repositories"
8+
9+
quit

0 commit comments

Comments
 (0)