[PATCH v2 compass-ci 2/2] container/dracut-initrd: add module 90lkp/lkp-deploy.sh

lkp-deploy.sh does the concrete work of 90lkp, it adds the lkp scripts into testbox's rootfs to run test job. Signed-off-by: Xu Xijian <hdxuxijian@163.com> --- .../modules.d/90lkp/lkp-deploy.sh | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 container/dracut-initrd/modules.d/90lkp/lkp-deploy.sh diff --git a/container/dracut-initrd/modules.d/90lkp/lkp-deploy.sh b/container/dracut-initrd/modules.d/90lkp/lkp-deploy.sh new file mode 100755 index 0000000..e88959b --- /dev/null +++ b/container/dracut-initrd/modules.d/90lkp/lkp-deploy.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. /lib/dracut-lib.sh + +# transfer LKP dirs +[ -d /lkp ] || return 0 + +cp -a /lkp "$NEWROOT"/ + +for i in /lkp/lkp/src/rootfs/addon/* /usr/local/* /opt/* +do + dir=$(basename "$i") + + [ "$i" != "${i%/\*}" ] && continue # skip: i='dir/*' + + [ -d "$NEWROOT/$dir" ] || mkdir -p "$NEWROOT/$dir" + + for j in "$i"/* "$i"/.??* + do + [ "$j" != "${j%/\*}" ] && continue # skip: j='dir/*' + + [ -f "$j" ] && { + cp -a "$j" "$NEWROOT/$dir"/ + continue + } + + subdir=$(basename "$j") + + [ -d "$NEWROOT/$dir/$subdir" ] || mkdir -p "$NEWROOT/$dir/$subdir" + + for k in "$j"/* + do + [ "$k" != "${k%/\*}" ] && continue # skip: k='dir/*' + + cp -a "$j"/* "$NEWROOT/$dir/$subdir"/ + done + done +done + +[ -d /usr/src ] && + cp -a /usr/src "$NEWROOT"/usr/ + +kmdir=/lib/modules/$(uname -r) +if test -d "$kmdir" && ! test -d "$NEWROOT/$kmdir"; then + cp -an "$kmdir" "$NEWROOT"/lib/modules/ + cp -an /lib/firmware "$NEWROOT"/lib/ +fi -- 2.23.0

@@ -0,0 +1,48 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. /lib/dracut-lib.sh + +# transfer LKP dirs +[ -d /lkp ] || return 0 + +cp -a /lkp "$NEWROOT"/ + +for i in /lkp/lkp/src/rootfs/addon/* /usr/local/* /opt/* +do + dir=$(basename "$i") + + [ "$i" != "${i%/\*}" ] && continue # skip: i='dir/*'
it's a little puzzling for the test style, why do you use "${i%/\*}" for you have use command 'basename'. do you want to check if it's a dir? you can use: [ -d "$i" ] || continue dir=$(basename "$i") Thanks, Luan Shengde
+ + [ -d "$NEWROOT/$dir" ] || mkdir -p "$NEWROOT/$dir" + + for j in "$i"/* "$i"/.??* + do + [ "$j" != "${j%/\*}" ] && continue # skip: j='dir/*'
ditto
+ + [ -f "$j" ] && { + cp -a "$j" "$NEWROOT/$dir"/ + continue + } + + subdir=$(basename "$j") + + [ -d "$NEWROOT/$dir/$subdir" ] || mkdir -p "$NEWROOT/$dir/$subdir" + + for k in "$j"/* + do + [ "$k" != "${k%/\*}" ] && continue # skip: k='dir/*' + + cp -a "$j"/* "$NEWROOT/$dir/$subdir"/ + done + done +done + +[ -d /usr/src ] && + cp -a /usr/src "$NEWROOT"/usr/ + +kmdir=/lib/modules/$(uname -r) +if test -d "$kmdir" && ! test -d "$NEWROOT/$kmdir"; then + cp -an "$kmdir" "$NEWROOT"/lib/modules/ + cp -an /lib/firmware "$NEWROOT"/lib/ +fi -- 2.23.0

On Tue, Mar 02, 2021 at 09:13:41AM +0800, Luan Shengde wrote:
@@ -0,0 +1,48 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. /lib/dracut-lib.sh + +# transfer LKP dirs +[ -d /lkp ] || return 0 + +cp -a /lkp "$NEWROOT"/ + +for i in /lkp/lkp/src/rootfs/addon/* /usr/local/* /opt/* +do + dir=$(basename "$i") + + [ "$i" != "${i%/\*}" ] && continue # skip: i='dir/*'
it's a little puzzling for the test style, why do you use "${i%/\*}" for you have use command 'basename'. do you want to check if it's a dir? you can use: [ -d "$i" ] || continue dir=$(basename "$i")
Thanks, Luan Shengde
Good, it's used to skip when i is just a empty dir, I'll modify to make it more clear for readers. Thanks for remiding. Thanks, Xijian
participants (2)
-
Luan Shengde
-
Xu Xijian