Skip to content

Commit b17b2ac

Browse files
committed
lib/tests/pkgbuild.sh: abstract pack_to_cgz()
Signed-off-by: Philip Li <philip.li@intel.com>
1 parent dd88d2f commit b17b2ac

6 files changed

Lines changed: 20 additions & 10 deletions

File tree

distro/centos

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ shopt -s nullglob
55
. $LKP_SRC/lib/install.sh
66
. $LKP_SRC/distro/common
77
. $LKP_SRC/lib/debug.sh
8+
. $LKP_SRC/lib/tests/pkgbuild.sh
89

910
fixup_distro_mirror()
1011
{
@@ -85,7 +86,7 @@ pack()
8586

8687
mv $downloaded_rpms $target_dir
8788

88-
find $target_dir | cpio --quiet -o -H newc --owner=root.root | gzip -n -9 >$pack_to/${BM_NAME}_$date.cgz
89+
find $target_dir | pack_to_cgz "$pack_to/${BM_NAME}_$date.cgz" --owner=root.root
8990

9091
ln -sf ${BM_NAME}_$date.cgz $pack_to/${BM_NAME}.cgz || return
9192
chown .lkp $pack_to/${BM_NAME}_$date.cgz $pack_to/${BM_NAME}.cgz || return

distro/debian

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ shopt -s nullglob
55
. $LKP_SRC/lib/install.sh
66
. $LKP_SRC/distro/common
77
. $LKP_SRC/lib/debug.sh
8+
. $LKP_SRC/lib/tests/pkgbuild.sh
89

910
update()
1011
{
@@ -125,9 +126,7 @@ pack()
125126

126127
local pkg_dir=$(get_pkg_dir $BM_NAME)
127128
[[ -d $pkg_dir && -f $pkg_dir/allowlist ]] && cat $pkg_dir/allowlist
128-
} |
129-
cpio --quiet -o -H newc --owner=root.root |
130-
gzip -n -9 > $pack_to/${BM_NAME}_$date.cgz || return
129+
} | pack_to_cgz "$pack_to/${BM_NAME}_$date.cgz" --owner=root.root || return
131130

132131
ln -sf ${BM_NAME}_$date.cgz \
133132
$pack_to/${BM_NAME}.cgz || return

lib/tests/pkgbuild.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,10 @@ pack_qemu()
274274
# create /bin/kvm link that app like avocado list requires kvm bin
275275
log_cmd ln -s qemu-system-x86_64 $pkgdir/usr/bin/kvm
276276
}
277+
278+
pack_to_cgz()
279+
{
280+
local output="$1"
281+
shift
282+
cpio -o -H newc --quiet "$@" | gzip -n -9 > "$output"
283+
}

lkp-exec/qemu

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
. $LKP_SRC/lib/job-init.sh
88
. $LKP_SRC/lib/lkp_cmd.sh
99
. $LKP_SRC/lib/lkp_path.sh
10+
. $LKP_SRC/lib/tests/pkgbuild.sh
1011

1112
script_name=$(basename $0)
1213

@@ -124,7 +125,6 @@ create_job_initrd()
124125
mkdir -p $CACHE_DIR/$job_initrd_dir
125126
cp $job_script $job_sh
126127
chmod +x $job_sh
127-
local archive=$CACHE_DIR/job
128128
(
129129
cd $CACHE_DIR || exit
130130
{
@@ -135,9 +135,7 @@ create_job_initrd()
135135
echo $dir
136136
done
137137
find ${job_initrd_dir#/}/*
138-
} | cpio -o -H newc -F $archive.cpio
139-
gzip -n -9 $archive.cpio
140-
mv -f $archive.cpio.gz $CACHE_DIR/$job_initrd
138+
} | pack_to_cgz $CACHE_DIR/$job_initrd
141139
)
142140
}
143141

pack/default

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
. $LKP_SRC/lib/git.sh
4+
. $LKP_SRC/lib/tests/pkgbuild.sh
45

56
pre_download()
67
{
@@ -114,7 +115,7 @@ pack()
114115
echo /lkp/benchmarks/$BM_NAME
115116
find /lkp/benchmarks/$BM_NAME/*
116117
} |
117-
cpio --quiet -o -H newc --owner=root.root | gzip -n -9 > /lkp/benchmarks/${BM_NAME}.cgz
118+
pack_to_cgz "/lkp/benchmarks/${BM_NAME}.cgz" --owner=root.root
118119
[[ $arch ]] && mv "/lkp/benchmarks/${BM_NAME}.cgz" "/lkp/benchmarks/${BM_NAME}-${arch}.cgz"
119120
}
120121

tools/bm-mkcgz

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
[ -n "$LKP_SRC" ] || export LKP_SRC=$(dirname $(dirname $(readlink -e -v $0)))
4+
5+
. $LKP_SRC/lib/tests/pkgbuild.sh
6+
37
usage()
48
{
59
echo "Usage: $(basename $0) <benchmark>"
@@ -18,4 +22,4 @@ bm_path=/lkp/benchmarks/$BM_NAME
1822
exit 1
1923
}
2024

21-
find $bm_path | cpio -o -H newc | gzip -n -9 > $BM_NAME.cgz
25+
find $bm_path | pack_to_cgz "$BM_NAME.cgz"

0 commit comments

Comments
 (0)