Skip to content

Commit ca97b1e

Browse files
committed
Add sudo-enabled user support;Add Ubuntu 19.04;Update e2fsprogs;fix bugs
1 parent b2ffb07 commit ca97b1e

File tree

12 files changed

+98
-31
lines changed

12 files changed

+98
-31
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ 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 mirror.china.sh
20+
extensions: *.sh config.xml LICENSE rootfs.ext3.base rootfs.ext4.base menu.json
2121
rm -fr extensions
2222
$(MAKE) -C ./e2fsprogs/
2323
mkdir -p extensions/$(PACKAGE)

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,18 @@
1010

1111
`nodejs` `p7zip` `docker` and normal GNU/Linux
1212

13-
## Build ZIP
13+
[you need to `sudo usermod -aG docker $(whoami)`](https://stackoverflow.com/questions/21871479/docker-cant-connect-to-docker-daemon)
14+
15+
[Once you need to configure binfmt-support on your Docker host. This works locally or remotely (i.e using boot2docker or swarm).](https://github.com/multiarch/alpine)
1416

17+
```bash
18+
# configure binfmt-support on the Docker host (works locally or remotely, i.e: using boot2docker)
19+
$ docker run --rm --privileged multiarch/qemu-user-static:register --reset
1520
```
21+
22+
## Build ZIP
23+
24+
```bash
1625
$ make
1726
```
1827

chroot.shell.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
[ -f "$ROOTFS_LOCK" ] || mount_rootfs_all
66

7-
copy_etc_files
8-
9-
do_chroot /bin/sh
7+
do_chroot su
108

119
quit

chroot.shell.user.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+
do_chroot su -l kindle
8+
9+
quit

e2fsprogs/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ RUN sed -i 's|security.debian.org|mirrors.ustc.edu.cn/debian-security|g' /etc/ap
55
RUN apt update
66
RUN apt install -y gcc dietlibc-dev aria2 make
77
RUN mkdir /src
8-
RUN cd /src && aria2c -k 1048576 -s 32768 -j 32768 -x 16 -k 1M http://prdownloads.sourceforge.net/e2fsprogs/e2fsprogs-1.45.2.tar.gz
9-
RUN cd /src && tar -xzvf e2fsprogs-1.45.2.tar.gz
10-
RUN cd /src/e2fsprogs-1.45.2 && ./configure --prefix=/src --disable-threads --disable-tls --disable-nls --with-diet-libc --disable-imager --disable-debugfs --disable-defrag --disable-fuse2fs --disable-fsck --disable-e2initrd-helper
11-
RUN cd /src/e2fsprogs-1.45.2 && make -j4
12-
RUN cd /src/e2fsprogs-1.45.2 && make install
8+
ARG e2fsprogs_version=1.45.3
9+
RUN cd /src && aria2c -o e2fsprogs-${e2fsprogs_version}.tar.gz -k 1048576 -s 32768 -j 32768 -x 16 -k 1M https://kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v${e2fsprogs_version}/e2fsprogs-${e2fsprogs_version}.tar.gz
10+
RUN cd /src && tar -xzvf e2fsprogs-${e2fsprogs_version}.tar.gz
11+
RUN cd /src/e2fsprogs-${e2fsprogs_version} && ./configure --prefix=/src --disable-threads --disable-tls --disable-nls --with-diet-libc --disable-imager --disable-debugfs --disable-defrag --disable-fuse2fs --disable-fsck --disable-e2initrd-helper
12+
RUN cd /src/e2fsprogs-${e2fsprogs_version} && make -j4
13+
RUN cd /src/e2fsprogs-${e2fsprogs_version} && make install

gen.menu.json.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ const kterm_scripts=
33
["LinuxDeploy",
44
[["Linux",
55
[
6-
["Install Alpine Linux","./install.alpine.sh"],
7-
["Shell","./chroot.shell.sh"],
6+
["Install",[
7+
["Alpine Linux Edge","./install.alpine.sh"],
8+
["Ubuntu 19.04(maybe require Linux 4.x?)","./install.ubuntu.1904.sh"]]],
89
["Change mirror",[
910
["China Mainland","./mirror.china.sh"]]],
11+
["Add a sudo-enabled user called \"kindle\"","./install.sudo.user.sh"],
12+
["Reset \"kindle\" user's password","./set.user.password.sh"],
13+
["Shell",[
14+
["USER=kindle","./chroot.shell.user.sh"],
15+
["USER=root","./chroot.shell.sh"]]],
1016
["Umount","./umount.sh"],
1117
["Resize rootfs","./resize.sh"],
1218
["Remove rootfs",

install.alpine.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44

55
[ -f "$ROOTFS_IMG" ] && fail "rootfs exist.Please remove it and continue."
66

7-
install_alpine_rootfs
7+
get_rootfs_tgz_filename(){
8+
curl http://dl-cdn.alpinelinux.org/alpine/edge/releases/armhf/ |
9+
grep '^<a.*"alpine-minirootfs-[0-9]*-armhf\.tar\.gz"' |
10+
sed 's|^<a *href="\(.*\)">.*</a>.*$|\1|' |
11+
sort |
12+
tail -1
13+
}
14+
get_rootfs_tgz_url(){
15+
echo "http://dl-cdn.alpinelinux.org/alpine/edge/releases/armhf/$(get_rootfs_tgz_filename)"
16+
}
17+
18+
install_tgz_rootfs "$(get_rootfs_tgz_url)"
819

920
quit

install.sudo.user.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
. "$(dirname "$0")"/lib.sh
4+
5+
[ -f "$ROOTFS_LOCK" ] || mount_rootfs_all
6+
7+
if [ -f "$ROOTFS_DIR/etc/apk/repositories" ]; then
8+
do_chroot apk add sudo || fail "cannot install sudo."
9+
elif [ -f "$ROOTFS_DIR/etc/apt/sources.list" ]; then
10+
do_chroot apt update || fail "cannot install sudo."
11+
do_chroot apt install -y sudo || fail "cannot install sudo."
12+
else
13+
fail "Unsupport system."
14+
fi
15+
16+
do_chroot adduser -D kindle || fail "cannot add user."
17+
echo "kindle ALL=(ALL) ALL" > "$ROOTFS_DIR/etc/sudoers.d/kindle" || fail
18+
chmod 440 "$ROOTFS_DIR/etc/sudoers.d/kindle" || fail
19+
do_chroot passwd kindle || fail "cannot change password.(You can safely change password later.)"
20+
21+
quit

install.ubuntu.1904.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_IMG" ] && fail "rootfs exist.Please remove it and continue."
6+
7+
install_tgz_rootfs "http://mirrors.ustc.edu.cn/ubuntu-cdimage/ubuntu-base/releases/19.04/release/ubuntu-base-19.04-base-armhf.tar.gz"
8+
9+
quit

lib.sh

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ echo "
1717
along with this program. If not, see <https://www.gnu.org/licenses/>.
1818
"
1919

20-
cd "$(dirname "$0")"
21-
2220
quit(){
2321
echo "Done. $*"
2422
echo "press enter to countinue."
@@ -33,6 +31,8 @@ fail(){
3331
exit 1
3432
}
3533

34+
cd "$(dirname "$0")" || fail
35+
3636
BIN="$(pwd)"
3737
ROOTFS_DIR="$(pwd)/rootfs"
3838
ROOTFS_IMG="$(pwd)/rootfs.img"
@@ -49,37 +49,28 @@ else
4949
fail "This kernel doesn't support ext4 and ext3."
5050
fi
5151

52-
get_rootfs_tgz_filename(){
53-
curl http://dl-cdn.alpinelinux.org/alpine/edge/releases/armhf/ |
54-
grep '^<a.*"alpine-minirootfs-[0-9]*-armhf\.tar\.gz"' |
55-
sed 's|^<a *href="\(.*\)">.*</a>.*$|\1|' |
56-
sort |
57-
tail -1
58-
}
59-
get_rootfs_tgz_url(){
60-
echo "http://dl-cdn.alpinelinux.org/alpine/edge/releases/armhf/$(get_rootfs_tgz_filename)"
52+
copy_etc_files(){
53+
[ -f "$ROOTFS_LOCK" ] || fail "rootfs is not mounted."
54+
cp /etc/hostname /etc/hostname /etc/hosts /etc/resolv.conf "$ROOTFS_DIR/etc"
6155
}
6256

6357
mount_rootfs_base(){
6458
[ -f "$ROOTFS_LOCK" ] && fail "rootfs mounted."
6559
touch "$ROOTFS_LOCK" || fail
6660
mkdir -p "$ROOTFS_DIR" || fail
6761
mount -o loop "$ROOTFS_IMG" "$ROOTFS_DIR" || fail "cannot mount rootfs."
62+
chmod 755 "$ROOTFS_DIR" || fail
6863
}
6964
mount_rootfs_all(){
7065
mount_rootfs_base
66+
copy_etc_files
7167
mkdir -p "$INNER_TMP" || fail
7268
mount -o bind "$INNER_TMP" "$ROOTFS_DIR/tmp" || fail "cannot bind /tmp."
7369
for d in /dev /dev/pts /proc /sys; do
7470
mount -o bind "/$d" "$ROOTFS_DIR/$d" || fail "cannot bind $d"
7571
done
7672
}
7773

78-
copy_etc_files(){
79-
[ -f "$ROOTFS_LOCK" ] || fail "rootfs is not mounted."
80-
cp /etc/hostname /etc/hostname /etc/hosts /etc/resolv.conf "$ROOTFS_DIR/etc"
81-
}
82-
8374
umount_rootfs_all(){
8475
[ -f "$ROOTFS_LOCK" ] || fail "rootfs is not mounted."
8576
for d in /dev/pts /dev /proc /sys /tmp; do
@@ -96,13 +87,14 @@ resize_rootfs_interactive(){
9687
"$BIN"/resize2fs "$ROOTFS_IMG" "$ROOTFS_SIZE" || fail "cannot resize."
9788
}
9889

99-
install_alpine_rootfs(){
90+
install_tgz_rootfs(){
91+
local ROOTFS_TGZ_URL="$1"
10092
[ -f "$ROOTFS_LOCK" ] && fail "rootfs mounted."
10193
rm -fr "$ROOTFS_IMG" || fail
10294
cp rootfs."$ROOTFS_TYPE".base "$ROOTFS_IMG" || fail
10395
resize_rootfs_interactive
10496
mount_rootfs_base
105-
curl "$(get_rootfs_tgz_url)" | tar -xvz -C "$ROOTFS_DIR" || fail "download and extract rootfs: failed."
97+
curl "$ROOTFS_TGZ_URL" | tar -xvz -C "$ROOTFS_DIR" || fail "download and extract rootfs: failed."
10698
umount_rootfs_all
10799
}
108100

0 commit comments

Comments
 (0)