Skip to content

Commit 26fa83c

Browse files
committed
feat: allow chroot into existing rootfs
Signed-off-by: ZHANG Yuntian <yt@radxa.com>
1 parent 2034d40 commit 26fa83c

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/libexec/rsdk/rsdk-chroot

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ main() {
6363
disk="${disk%p*}p"
6464
fi
6565

66-
if [[ ! -b $disk ]] && [[ $disk != /dev/mapper/loop* ]]; then
66+
if [[ ! -d $disk ]] && [[ ! -b $disk ]] && [[ $disk != /dev/mapper/loop* ]]; then
6767
error "$EXIT_NOT_BLOCK_DEVICE" "$disk"
6868
fi
6969

@@ -91,6 +91,9 @@ main() {
9191
elif [[ -b "$disk"1 ]]; then
9292
# old armbian image
9393
sudo mount "$disk"1 "$RSDK_TEMP"
94+
elif [[ -d $disk ]]; then
95+
# actually a rootfs directory
96+
sudo mount --bind "$disk" "$RSDK_TEMP"
9497
else
9598
error "$EXIT_BLKDEV_NO_ROOTDEV" "$disk"
9699
fi

src/libexec/rsdk/rsdk-help

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ Requires `systemd-nspawn` (provided by `systemd-container` package in Debian).
8989
9090
## Supported target type
9191
92-
* Raw block devices (i.e. ordinary disks)
92+
* Raw block device (i.e. ordinary disk)
9393
* System image file
9494
* Requires `kpartx` (provided by `multipath-tools` package in Debian)
95+
* Existing rootfs directory
9596
9697
Following distributions may be used in addition to `rsdk` image:
97-
* `debox-radxa` image
98+
* `debos-radxa` image
9899
* `rbuild` image
99100
* `rsdk` image
100101
* `Armbian` image

src/share/bash-completion/completions/rsdk

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ _rsdk_chroot_completions() {
6161
case "$COMP_CWORD" in
6262
2)
6363
local i suggestions=()
64-
for i in out/*/output.img \
65-
"${COMP_WORDS[COMP_CWORD]%/}"/out/*/output.img \
66-
"${COMP_WORDS[COMP_CWORD]%/}"/*/output.img \
67-
"${COMP_WORDS[COMP_CWORD]%/}"/output.img; do
68-
if [[ -f $i ]]; then
64+
for i in \
65+
out/*/{output.img,rootfs/} \
66+
"${COMP_WORDS[COMP_CWORD]%/}"/out/*/{output.img,rootfs/} \
67+
"${COMP_WORDS[COMP_CWORD]%/}"/*/{output.img,rootfs/} \
68+
"${COMP_WORDS[COMP_CWORD]%/}"/{output.img,rootfs/}; do
69+
if [[ -f "$i" ]] || [[ -d "$i" ]]; then
6970
suggestions+=("$i")
7071
fi
7172
done

0 commit comments

Comments
 (0)