On Thu, Jan 14, 2021 at 02:43:30PM +0800, Liu Shaofei wrote:
On Thu, Jan 14, 2021 at 01:45:58PM +0800, Wang Chenglong wrote:
[Why] Sometimes, the kernel is in vmlinux format and needs to be unpacked into vmlinuz format.
Signeo-off-by: Wang Chenglong 18509160991@163.com
container/docker2rootfs/common | 33 ++++++++++++++++++++++++++++- container/docker2rootfs/run | 1 + container/docker2rootfs/setup-image | 2 +- 3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/container/docker2rootfs/common b/container/docker2rootfs/common index c26bbc8..e8c56ba 100755 --- a/container/docker2rootfs/common +++ b/container/docker2rootfs/common @@ -5,6 +5,8 @@ # This file is called by script run running on host # define functions and set host environment variables
+. $CCI_SRC/container/qcow2rootfs/bin/common
get_host_aarch() { aarch=$(arch) @@ -133,7 +135,7 @@ get_rootfs_kernel()
local vmlinuz_file local vmlinuz kernel
- vmlinuz_file=$(find ./boot -name "vmlinuz-*" | grep -v rescue) && export ROOTFS_VMLINUZ_FILE=$vmlinuz_file
- vmlinuz_file=$(find ./boot -name "vmlinu[z|x]-*" | grep -v rescue) && export ROOTFS_VMLINUZ_FILE=$vmlinuz_file
Here, whether can change like this: export ROOTFS_VMLINUZ_FILE=$(find ./boot -name "vmlinu[z|x]-*" | grep -v rescue) I think you can directly use env variable, not need to use "vmlinuz_file" variable. Is right..?
It a good idea, But I don't just use "vmlinuz_file" as a variable, and also use "vmlinuz=$(basename "$vmlinuz_file")". It's needs to be defined through "vmlinuz_file".
Thanks, Chenglong
vmlinuz=$(basename "$vmlinuz_file") && export ROOTFS_VMLINUZ=$vmlinuz kernel=${vmlinuz:8} && export ROOTFS_KERNEL=$kernel
@@ -155,3 +157,32 @@ create_links_vmlinuz_initrd()
echo "[INFO] Create links to initrd.lkp and vmlinuz success!" }
+unzip_vmlinuz() {
get_rootfs_kernel
file ${ROOTFS_VMLINUZ_FILE} | grep -q gzip || return
get_vmlinuz_start_postion ${ROOTFS_VMLINUZ_FILE}
[ $VMLINUZ_START_POSTION -eq -1 ] && return
local unzip_str
if [ $VMLINUZ_START_POSTION -eq 0 ]; then
unzip_str="dd if=$ROOTFS_VMLINUZ bs=1 | zcat > $ROOTFS_VMLINUZ.tmp"
else
unzip_str="dd if=$ROOTFS_VMLINUZ bs=1 skip=$VMLINUZ_START_POSTION | zcat > $ROOTFS_VMLINUZ.tmp"
fi
echo "Unzipping vmlinuz..."
cd "$ROOTFS_DIR/boot"
$unzip_str
mv $ROOTFS_VMLINUZ.tmp $ROOTFS_VMLINUZ
chmod o+r $ROOTFS_VMLINUZ
if [ $? -eq 0 ]; then
echo "[INFO] Unzipping vmlinuz success!"
else
echo "[WARNING] Unzipping vmlinuz failed!"
fi
+} diff --git a/container/docker2rootfs/run b/container/docker2rootfs/run index 8a7b315..cdb19bf 100755 --- a/container/docker2rootfs/run +++ b/container/docker2rootfs/run @@ -31,3 +31,4 @@ start=( cp_rootfs $IMAGE_PACK $2 docker rm -f rootfs-docker create_links_vmlinuz_initrd $2 +unzip_vmlinuz diff --git a/container/docker2rootfs/setup-image b/container/docker2rootfs/setup-image index ffe4937..47bfb7e 100755 --- a/container/docker2rootfs/setup-image +++ b/container/docker2rootfs/setup-image @@ -38,7 +38,7 @@ setup_login() pack_cgz() { echo "Packing package. Please wait."
- find ./ ! -path "./tmp/${IMAGE_PACK}" | cpio -o -Hnewc | gzip -9 >./tmp/$IMAGE_PACK
- find ./ ! -path "./tmp/$IMAGE_PACK" | cpio -o -Hnewc | gzip -9 > "./tmp/$IMAGE_PACK" chmod 644 /tmp/${IMAGE_PACK}
}
-- 2.23.0