Use the tool to create a new centos-7 initfamfs image with on click. and we also can customize the pre-installed software by configuring ./bin/repolist.
Signed-off-by: Wang Chenglong 18509160991@163.com --- rootfs/initfamfs/centos/aarch64/7/README.md | 12 +++++ rootfs/initfamfs/centos/aarch64/7/bin/creat | 46 +++++++++++++++++++ rootfs/initfamfs/centos/aarch64/7/bin/dellist | 8 ++++ rootfs/initfamfs/centos/aarch64/7/bin/lib | 32 +++++++++++++ .../initfamfs/centos/aarch64/7/bin/repolist | 2 + rootfs/initfamfs/centos/aarch64/7/build | 28 +++++++++++ 6 files changed, 128 insertions(+) create mode 100644 rootfs/initfamfs/centos/aarch64/7/README.md create mode 100755 rootfs/initfamfs/centos/aarch64/7/bin/creat create mode 100644 rootfs/initfamfs/centos/aarch64/7/bin/dellist create mode 100755 rootfs/initfamfs/centos/aarch64/7/bin/lib create mode 100644 rootfs/initfamfs/centos/aarch64/7/bin/repolist create mode 100755 rootfs/initfamfs/centos/aarch64/7/build
diff --git a/rootfs/initfamfs/centos/aarch64/7/README.md b/rootfs/initfamfs/centos/aarch64/7/README.md new file mode 100644 index 0000000..c503925 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/README.md @@ -0,0 +1,12 @@ +#Use the tool to create a new centos-7 initfamfs image. + +Usage: + ./build + +Some configuration items: +./bin/repolist + If you want to pre-install the software, you can write the package name in ./bin/repolist. + +./bin/dellist + If you want remove some unnecessary files, you can write the name in ./bin/dellist + diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/creat b/rootfs/initfamfs/centos/aarch64/7/bin/creat new file mode 100755 index 0000000..8cd0d2c --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/creat @@ -0,0 +1,46 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + + +#Configure rootfs +make_rootfs() +{ + yum repolist + yum -y install $(</root/bin/repolist) + yum clean all + rm -rf $(</root/bin/dellist) + ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime + cd /root/modules + zcat modules-5.8.0.1.cgz | cpio -idmv >/dev/null + + +} + +#config passwd +pre_config_rootfs() { + [ -n "$ROOT_NEW_PASSWD" ] && { + echo "Changing root password" + passwd_md5=$(openssl passwd -1 "$ROOT_NEW_PASSWD") + echo $passwd_md5 + sed -i -r "s/^root:[^:]*:(.*)/root:${passwd_md5////\/}:\1/" "$ROOTFS_DIR/etc/shadow" + sed -i 's/[# ]PermitRootLogin.*/PermitRootLogin yes/' "$ROOTFS_DIR/etc/ssh/sshd_config" + } + +} + +#pack cgz package +pack_cgz() +{ + echo "Packing package. Please wait." + cd / + find ./ ! -path "./${image_name}" ! -path "./root/modules/modules-5.8.0.1.cgz" |cpio -o -Hnewc |gzip -9 >/${image_name} + chmod 644 /${image_name} +} + + +make_rootfs +pre_config_rootfs +cat $ROOTFS_DIR/etc/shadow +pack_cgz + diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/dellist b/rootfs/initfamfs/centos/aarch64/7/bin/dellist new file mode 100644 index 0000000..ce079b9 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/dellist @@ -0,0 +1,8 @@ +/.dockerenv +/lib/modules +/usr/share/doc +/usr/share/man +/usr/share/info +/usr/share/i18n +/usr/share/locale +/usr/share/terminfo diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/lib b/rootfs/initfamfs/centos/aarch64/7/bin/lib new file mode 100755 index 0000000..da0cdaa --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/lib @@ -0,0 +1,32 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + + +DIR="$(dirname $(realpath $0))" +image="centos:7" +name="$(echo "$image" | cut -d '/' -f 2 | cut -d ':' -f 1)" +version="$(echo "$image" | cut -d '/' -f 2 | cut -d ':' -f 2)" +image_name="${name}-${version}.cgz" + +#check passwd file +check_passwd_file() { + root_pwd_file="$HOME/.config/compass-ci/rootfs.passwd" + export ROOT_NEW_PASSWD= + [ -f "$root_pwd_file" ] || { + echo "[INFO] Please set the password file." + echo "$HOME/.config/compass-ci/rootfs.passwd" + exit 1 + } + + export ROOT_NEW_PASSWD=$(cat "$root_pwd_file") +} + + +#pull_docker +pull_docker() +{ + docker pull $image || return + echo "finsh down image" +} + diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/repolist b/rootfs/initfamfs/centos/aarch64/7/bin/repolist new file mode 100644 index 0000000..5d31c40 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/repolist @@ -0,0 +1,2 @@ +openssh-server +openssl diff --git a/rootfs/initfamfs/centos/aarch64/7/build b/rootfs/initfamfs/centos/aarch64/7/build new file mode 100755 index 0000000..36a8216 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/build @@ -0,0 +1,28 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +docker rm -f init_docker 2&> /dev/null +. ./bin/lib + +check_passwd_file "$root_pwd_file" + +DIR=$(dirname $(realpath $0)) +cmd=( + docker run + --name init_docker + -v $DIR/bin/:/root/bin + -v /srv/initrd/modules/:/root/modules + -e ROOT_NEW_PASSWD=$ROOT_NEW_PASSWD + -e image_name=$image_name + $image + /root/bin/creat +) + +pull_docker + +${cmd[@]} + +docker cp -a init_docker:/${image_name} ./ +echo "build finished!!!" +
On Sat, Oct 10, 2020 at 02:12:33PM +0800, Wang Chenglong wrote:
Use the tool to create a new centos-7 initfamfs image with on click. and we also can customize the pre-installed software by configuring ./bin/repolist.
Signed-off-by: Wang Chenglong 18509160991@163.com
rootfs/initfamfs/centos/aarch64/7/README.md | 12 +++++ rootfs/initfamfs/centos/aarch64/7/bin/creat | 46 +++++++++++++++++++ rootfs/initfamfs/centos/aarch64/7/bin/dellist | 8 ++++ rootfs/initfamfs/centos/aarch64/7/bin/lib | 32 +++++++++++++ .../initfamfs/centos/aarch64/7/bin/repolist | 2 + rootfs/initfamfs/centos/aarch64/7/build | 28 +++++++++++ 6 files changed, 128 insertions(+) create mode 100644 rootfs/initfamfs/centos/aarch64/7/README.md create mode 100755 rootfs/initfamfs/centos/aarch64/7/bin/creat create mode 100644 rootfs/initfamfs/centos/aarch64/7/bin/dellist create mode 100755 rootfs/initfamfs/centos/aarch64/7/bin/lib create mode 100644 rootfs/initfamfs/centos/aarch64/7/bin/repolist create mode 100755 rootfs/initfamfs/centos/aarch64/7/build
diff --git a/rootfs/initfamfs/centos/aarch64/7/README.md b/rootfs/initfamfs/centos/aarch64/7/README.md new file mode 100644 index 0000000..c503925 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/README.md @@ -0,0 +1,12 @@ +#Use the tool to create a new centos-7 initfamfs image.
+Usage:
- ./build
+Some configuration items: +./bin/repolist
- If you want to pre-install the software, you can write the package name in ./bin/repolist.
+./bin/dellist
- If you want remove some unnecessary files, you can write the name in ./bin/dellist
diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/creat b/rootfs/initfamfs/centos/aarch64/7/bin/creat new file mode 100755 index 0000000..8cd0d2c --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/creat @@ -0,0 +1,46 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+#Configure rootfs +make_rootfs() +{
- yum repolist
- yum -y install $(</root/bin/repolist)
- yum clean all
- rm -rf $(</root/bin/dellist)
- ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- cd /root/modules
- zcat modules-5.8.0.1.cgz | cpio -idmv >/dev/null
Unused balnklines.
+}
+#config passwd +pre_config_rootfs() {
- [ -n "$ROOT_NEW_PASSWD" ] && {
echo "Changing root password"
passwd_md5=$(openssl passwd -1 "$ROOT_NEW_PASSWD")
echo $passwd_md5
sed -i -r "s/^root:[^:]*:(.*)/root:${passwd_md5//\//\\/}:\1/" "$ROOTFS_DIR/etc/shadow"
sed -i 's/[# ]PermitRootLogin.*/PermitRootLogin yes/' "$ROOTFS_DIR/etc/ssh/sshd_config"
- }
ditto
+}
+#pack cgz package +pack_cgz() +{
- echo "Packing package. Please wait."
- cd /
- find ./ ! -path "./${image_name}" ! -path "./root/modules/modules-5.8.0.1.cgz" |cpio -o -Hnewc |gzip -9 >/${image_name}
- chmod 644 /${image_name}
+}
one blankline is enough.
+make_rootfs +pre_config_rootfs +cat $ROOTFS_DIR/etc/shadow +pack_cgz
diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/dellist b/rootfs/initfamfs/centos/aarch64/7/bin/dellist new file mode 100644 index 0000000..ce079b9 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/dellist @@ -0,0 +1,8 @@ +/.dockerenv +/lib/modules +/usr/share/doc +/usr/share/man +/usr/share/info +/usr/share/i18n +/usr/share/locale +/usr/share/terminfo diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/lib b/rootfs/initfamfs/centos/aarch64/7/bin/lib new file mode 100755 index 0000000..da0cdaa --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/lib @@ -0,0 +1,32 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+DIR="$(dirname $(realpath $0))" +image="centos:7" +name="$(echo "$image" | cut -d '/' -f 2 | cut -d ':' -f 1)" +version="$(echo "$image" | cut -d '/' -f 2 | cut -d ':' -f 2)" +image_name="${name}-${version}.cgz"
+#check passwd file +check_passwd_file() {
- root_pwd_file="$HOME/.config/compass-ci/rootfs.passwd"
export ROOT_NEW_PASSWD=
[ -f "$root_pwd_file" ] || {
echo "[INFO] Please set the password file."
echo "$HOME/.config/compass-ci/rootfs.passwd"
exit 1
}
export ROOT_NEW_PASSWD=$(cat "$root_pwd_file")
+}
ditto.
Thanks, Xijian
+#Configure rootfs +make_rootfs() +{
- yum repolist
- yum -y install $(</root/bin/repolist)
- yum clean all
- rm -rf $(</root/bin/dellist)
- ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- cd /root/modules
- zcat modules-5.8.0.1.cgz | cpio -idmv >/dev/null
Unused balnklines.
Ok. I will delete it.
+}
+#config passwd +pre_config_rootfs() {
- [ -n "$ROOT_NEW_PASSWD" ] && {
echo "Changing root password"
passwd_md5=$(openssl passwd -1 "$ROOT_NEW_PASSWD")
echo $passwd_md5
sed -i -r "s/^root:[^:]*:(.*)/root:${passwd_md5//\//\\/}:\1/" "$ROOTFS_DIR/etc/shadow"
sed -i 's/[# ]PermitRootLogin.*/PermitRootLogin yes/' "$ROOTFS_DIR/etc/ssh/sshd_config"
- }
ditto
Ok.
+}
+#pack cgz package +pack_cgz() +{
- echo "Packing package. Please wait."
- cd /
- find ./ ! -path "./${image_name}" ! -path "./root/modules/modules-5.8.0.1.cgz" |cpio -o -Hnewc |gzip -9 >/${image_name}
- chmod 644 /${image_name}
+}
one blankline is enough.
Ok.
+make_rootfs +pre_config_rootfs +cat $ROOTFS_DIR/etc/shadow
+#check passwd file +check_passwd_file() {
- root_pwd_file="$HOME/.config/compass-ci/rootfs.passwd"
export ROOT_NEW_PASSWD=
[ -f "$root_pwd_file" ] || {
echo "[INFO] Please set the password file."
echo "$HOME/.config/compass-ci/rootfs.passwd"
exit 1
}
export ROOT_NEW_PASSWD=$(cat "$root_pwd_file")
+}
ditto.
Ok
Thanks, Chenglong
Thanks, Xijian
On Sat, Oct 10, 2020 at 02:12:33PM +0800, Wang Chenglong wrote:
Use the tool to create a new centos-7 initfamfs image with on click. and we also can customize the pre-installed software by configuring ./bin/repolist.
Signed-off-by: Wang Chenglong 18509160991@163.com
rootfs/initfamfs/centos/aarch64/7/README.md | 12 +++++ rootfs/initfamfs/centos/aarch64/7/bin/creat | 46 +++++++++++++++++++ rootfs/initfamfs/centos/aarch64/7/bin/dellist | 8 ++++ rootfs/initfamfs/centos/aarch64/7/bin/lib | 32 +++++++++++++ .../initfamfs/centos/aarch64/7/bin/repolist | 2 + rootfs/initfamfs/centos/aarch64/7/build | 28 +++++++++++ 6 files changed, 128 insertions(+) create mode 100644 rootfs/initfamfs/centos/aarch64/7/README.md create mode 100755 rootfs/initfamfs/centos/aarch64/7/bin/creat create mode 100644 rootfs/initfamfs/centos/aarch64/7/bin/dellist create mode 100755 rootfs/initfamfs/centos/aarch64/7/bin/lib create mode 100644 rootfs/initfamfs/centos/aarch64/7/bin/repolist create mode 100755 rootfs/initfamfs/centos/aarch64/7/build
diff --git a/rootfs/initfamfs/centos/aarch64/7/README.md b/rootfs/initfamfs/centos/aarch64/7/README.md new file mode 100644 index 0000000..c503925 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/README.md @@ -0,0 +1,12 @@ +#Use the tool to create a new centos-7 initfamfs image.
+Usage:
- ./build
+Some configuration items: +./bin/repolist
- If you want to pre-install the software, you can write the package name in ./bin/repolist.
package names
+./bin/dellist
- If you want remove some unnecessary files, you can write the name in ./bin/dellist
write the names
diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/creat b/rootfs/initfamfs/centos/aarch64/7/bin/creat new file mode 100755 index 0000000..8cd0d2c --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/creat @@ -0,0 +1,46 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+#Configure rootfs +make_rootfs() +{
- yum repolist
- yum -y install $(</root/bin/repolist)
add --skip-broken.
- yum clean all
- rm -rf $(</root/bin/dellist)
- ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- cd /root/modules
- zcat modules-5.8.0.1.cgz | cpio -idmv >/dev/null
+}
+#config passwd +pre_config_rootfs() {
- [ -n "$ROOT_NEW_PASSWD" ] && {
echo "Changing root password"
passwd_md5=$(openssl passwd -1 "$ROOT_NEW_PASSWD")
echo $passwd_md5
sed -i -r "s/^root:[^:]*:(.*)/root:${passwd_md5//\//\\/}:\1/" "$ROOTFS_DIR/etc/shadow"
sed -i 's/[# ]PermitRootLogin.*/PermitRootLogin yes/' "$ROOTFS_DIR/etc/ssh/sshd_config"
- }
+}
+#pack cgz package +pack_cgz() +{
- echo "Packing package. Please wait."
- cd /
- find ./ ! -path "./${image_name}" ! -path "./root/modules/modules-5.8.0.1.cgz" |cpio -o -Hnewc |gzip -9 >/${image_name}
- chmod 644 /${image_name}
+}
+make_rootfs +pre_config_rootfs +cat $ROOTFS_DIR/etc/shadow +pack_cgz
diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/dellist b/rootfs/initfamfs/centos/aarch64/7/bin/dellist new file mode 100644 index 0000000..ce079b9 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/dellist @@ -0,0 +1,8 @@ +/.dockerenv +/lib/modules +/usr/share/doc +/usr/share/man +/usr/share/info +/usr/share/i18n +/usr/share/locale +/usr/share/terminfo diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/lib b/rootfs/initfamfs/centos/aarch64/7/bin/lib new file mode 100755 index 0000000..da0cdaa --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/lib @@ -0,0 +1,32 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+DIR="$(dirname $(realpath $0))" +image="centos:7" +name="$(echo "$image" | cut -d '/' -f 2 | cut -d ':' -f 1)" +version="$(echo "$image" | cut -d '/' -f 2 | cut -d ':' -f 2)" +image_name="${name}-${version}.cgz"
+#check passwd file +check_passwd_file() {
- root_pwd_file="$HOME/.config/compass-ci/rootfs.passwd"
export ROOT_NEW_PASSWD=
[ -f "$root_pwd_file" ] || {
echo "[INFO] Please set the password file."
echo "$HOME/.config/compass-ci/rootfs.passwd"
We can use one echo with 2 lines.
exit 1
}
export ROOT_NEW_PASSWD=$(cat "$root_pwd_file")
+}
+#pull_docker +pull_docker() +{
- docker pull $image || return
- echo "finsh down image"
"finsh downloading image"
Thanks, Xijian
+}
diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/repolist b/rootfs/initfamfs/centos/aarch64/7/bin/repolist new file mode 100644 index 0000000..5d31c40 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/repolist @@ -0,0 +1,2 @@ +openssh-server +openssl diff --git a/rootfs/initfamfs/centos/aarch64/7/build b/rootfs/initfamfs/centos/aarch64/7/build new file mode 100755 index 0000000..36a8216 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/build @@ -0,0 +1,28 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+docker rm -f init_docker 2&> /dev/null +. ./bin/lib
+check_passwd_file "$root_pwd_file"
+DIR=$(dirname $(realpath $0)) +cmd=(
- docker run
- --name init_docker
- -v $DIR/bin/:/root/bin
- -v /srv/initrd/modules/:/root/modules
- -e ROOT_NEW_PASSWD=$ROOT_NEW_PASSWD
- -e image_name=$image_name
- $image
- /root/bin/creat
+)
+pull_docker
+${cmd[@]}
+docker cp -a init_docker:/${image_name} ./ +echo "build finished!!!"
-- 2.23.0
+#Use the tool to create a new centos-7 initfamfs image.
+Usage:
- ./build
+Some configuration items: +./bin/repolist
- If you want to pre-install the software, you can write the package name in ./bin/repolist.
package names
Got it.
+./bin/dellist
- If you want remove some unnecessary files, you can write the name in ./bin/dellist
write the names
Ok.
diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/creat b/rootfs/initfamfs/centos/aarch64/7/bin/creat new file mode 100755 index 0000000..8cd0d2c --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/creat @@ -0,0 +1,46 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+#Configure rootfs +make_rootfs() +{
- yum repolist
- yum -y install $(</root/bin/repolist)
add --skip-broken.
Got it.
- yum clean all
- rm -rf $(</root/bin/dellist)
- ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- cd /root/modules
- zcat modules-5.8.0.1.cgz | cpio -idmv >/dev/null
+}
+#config passwd +pre_config_rootfs() {
- [ -n "$ROOT_NEW_PASSWD" ] && {
echo "Changing root password"
passwd_md5=$(openssl passwd -1 "$ROOT_NEW_PASSWD")
echo $passwd_md5
sed -i -r "s/^root:[^:]*:(.*)/root:${passwd_md5//\//\\/}:\1/" "$ROOTFS_DIR/etc/shadow"
sed -i 's/[# ]PermitRootLogin.*/PermitRootLogin yes/' "$ROOTFS_DIR/etc/ssh/sshd_config"
- }
+}
+#pack cgz package +pack_cgz() +{
- echo "Packing package. Please wait."
- cd /
- find ./ ! -path "./${image_name}" ! -path "./root/modules/modules-5.8.0.1.cgz" |cpio -o -Hnewc |gzip -9 >/${image_name}
- chmod 644 /${image_name}
+}
+make_rootfs +pre_config_rootfs +cat $ROOTFS_DIR/etc/shadow +pack_cgz
diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/dellist b/rootfs/initfamfs/centos/aarch64/7/bin/dellist new file mode 100644 index 0000000..ce079b9 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/dellist @@ -0,0 +1,8 @@ +/.dockerenv +/lib/modules +/usr/share/doc +/usr/share/man +/usr/share/info +/usr/share/i18n +/usr/share/locale +/usr/share/terminfo diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/lib b/rootfs/initfamfs/centos/aarch64/7/bin/lib new file mode 100755 index 0000000..da0cdaa --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/lib @@ -0,0 +1,32 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+DIR="$(dirname $(realpath $0))" +image="centos:7" +name="$(echo "$image" | cut -d '/' -f 2 | cut -d ':' -f 1)" +version="$(echo "$image" | cut -d '/' -f 2 | cut -d ':' -f 2)" +image_name="${name}-${version}.cgz"
+#check passwd file +check_passwd_file() {
- root_pwd_file="$HOME/.config/compass-ci/rootfs.passwd"
export ROOT_NEW_PASSWD=
[ -f "$root_pwd_file" ] || {
echo "[INFO] Please set the password file."
echo "$HOME/.config/compass-ci/rootfs.passwd"
We can use one echo with 2 lines.
good idea.
exit 1
}
export ROOT_NEW_PASSWD=$(cat "$root_pwd_file")
+}
+#pull_docker +pull_docker() +{
- docker pull $image || return
- echo "finsh down image"
"finsh downloading image"
Ok.
Thanks, Chenglong
Thanks, Xijian
+}
diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/repolist b/rootfs/initfamfs/centos/aarch64/7/bin/repolist new file mode 100644 index 0000000..5d31c40 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/repolist @@ -0,0 +1,2 @@ +openssh-server +openssl diff --git a/rootfs/initfamfs/centos/aarch64/7/build b/rootfs/initfamfs/centos/aarch64/7/build new file mode 100755 index 0000000..36a8216 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/build @@ -0,0 +1,28 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+docker rm -f init_docker 2&> /dev/null +. ./bin/lib
+check_passwd_file "$root_pwd_file"
+DIR=$(dirname $(realpath $0)) +cmd=(
- docker run
- --name init_docker
- -v $DIR/bin/:/root/bin
- -v /srv/initrd/modules/:/root/modules
- -e ROOT_NEW_PASSWD=$ROOT_NEW_PASSWD
- -e image_name=$image_name
- $image
- /root/bin/creat
+)
+pull_docker
+${cmd[@]}
+docker cp -a init_docker:/${image_name} ./ +echo "build finished!!!"
-- 2.23.0
+#config passwd +pre_config_rootfs() {
- [ -n "$ROOT_NEW_PASSWD" ] && {
echo "Changing root password"
passwd_md5=$(openssl passwd -1 "$ROOT_NEW_PASSWD")
echo $passwd_md5
add a comment may be better
sed -i -r "s/^root:[^:]*:(.*)/root:${passwd_md5//\//\\/}:\1/" "$ROOTFS_DIR/etc/shadow"
sed -i 's/[# ]PermitRootLogin.*/PermitRootLogin yes/' "$ROOTFS_DIR/etc/ssh/sshd_config"
- }
+}
+#pack cgz package +pack_cgz() +{
- echo "Packing package. Please wait."
- cd /
ditto
- find ./ ! -path "./${image_name}" ! -path "./root/modules/modules-5.8.0.1.cgz" |cpio -o -Hnewc |gzip -9 >/${image_name}
- chmod 644 /${image_name}
+}
+make_rootfs +pre_config_rootfs +cat $ROOTFS_DIR/etc/shadow +pack_cgz
diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/dellist b/rootfs/initfamfs/centos/aarch64/7/bin/dellist new file mode 100644 index 0000000..ce079b9 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/dellist @@ -0,0 +1,8 @@
+++ b/rootfs/initfamfs/centos/aarch64/7/bin/lib @@ -0,0 +1,32 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+DIR="$(dirname $(realpath $0))" +image="centos:7"
you can get the current path, then split it to get the name and version
+name="$(echo "$image" | cut -d '/' -f 2 | cut -d ':' -f 1)" +version="$(echo "$image" | cut -d '/' -f 2 | cut -d ':' -f 2)" +image_name="${name}-${version}.cgz"
+#check passwd file
# check passwd file
+check_passwd_file() {
- root_pwd_file="$HOME/.config/compass-ci/rootfs.passwd"
export ROOT_NEW_PASSWD=
[ -f "$root_pwd_file" ] || {
echo "[INFO] Please set the password file."
format
echo "$HOME/.config/compass-ci/rootfs.passwd"
exit 1
}
export ROOT_NEW_PASSWD=$(cat "$root_pwd_file")
+}
+#pull_docker +pull_docker() +{
- docker pull $image || return
- echo "finsh down image"
finished down load image
+}
diff --git a/rootfs/initfamfs/centos/aarch64/7/bin/repolist b/rootfs/initfamfs/centos/aarch64/7/bin/repolist new file mode 100644 index 0000000..5d31c40 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/bin/repolist @@ -0,0 +1,2 @@ +openssh-server +openssl diff --git a/rootfs/initfamfs/centos/aarch64/7/build b/rootfs/initfamfs/centos/aarch64/7/build new file mode 100755 index 0000000..36a8216 --- /dev/null +++ b/rootfs/initfamfs/centos/aarch64/7/build @@ -0,0 +1,28 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+docker rm -f init_docker 2&> /dev/null
we have a function to del container, CCI_SRC/container/defconfig.sh
+. ./bin/lib
+check_passwd_file "$root_pwd_file"
+DIR=$(dirname $(realpath $0)) +cmd=(
- docker run
- --name init_docker
can add --rm ?
Thanks, Shenwei
- -v $DIR/bin/:/root/bin
- -v /srv/initrd/modules/:/root/modules
- -e ROOT_NEW_PASSWD=$ROOT_NEW_PASSWD
- -e image_name=$image_name
- $image
- /root/bin/creat
+)
+pull_docker
+${cmd[@]}
+docker cp -a init_docker:/${image_name} ./ +echo "build finished!!!"
-- 2.23.0
On Sat, Oct 10, 2020 at 03:36:14PM +0800, Xiao Shenwei wrote:
+#config passwd +pre_config_rootfs() {
- [ -n "$ROOT_NEW_PASSWD" ] && {
echo "Changing root password"
passwd_md5=$(openssl passwd -1 "$ROOT_NEW_PASSWD")
echo $passwd_md5
add a comment may be better
good idea.
sed -i -r "s/^root:[^:]*:(.*)/root:${passwd_md5//\//\\/}:\1/" "$ROOTFS_DIR/etc/shadow"
sed -i 's/[# ]PermitRootLogin.*/PermitRootLogin yes/' "$ROOTFS_DIR/etc/ssh/sshd_config"
- }
+}
+#pack cgz package +pack_cgz() +{
- echo "Packing package. Please wait."
- cd /
ditto
ok.
- find ./ ! -path "./${image_name}" ! -path "./root/modules/modules-5.8.0.1.cgz" |cpio -o -Hnewc |gzip -9 >/${image_name}
- chmod 644 /${image_name}
+}
+#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+DIR="$(dirname $(realpath $0))" +image="centos:7"
you can get the current path, then split it to get the name and version
Ok. good idea.
+name="$(echo "$image" | cut -d '/' -f 2 | cut -d ':' -f 1)" +version="$(echo "$image" | cut -d '/' -f 2 | cut -d ':' -f 2)" +image_name="${name}-${version}.cgz"
+#check passwd file
# check passwd file
+check_passwd_file() {
- root_pwd_file="$HOME/.config/compass-ci/rootfs.passwd"
export ROOT_NEW_PASSWD=
[ -f "$root_pwd_file" ] || {
echo "[INFO] Please set the password file."
format
Ok.
echo "$HOME/.config/compass-ci/rootfs.passwd"
exit 1
}
export ROOT_NEW_PASSWD=$(cat "$root_pwd_file")
+}
+#pull_docker +pull_docker() +{
- docker pull $image || return
- echo "finsh down image"
finished down load image
Ok
+} @@ -0,0 +1,28 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+docker rm -f init_docker 2&> /dev/null
we have a function to del container, CCI_SRC/container/defconfig.sh
Ok. good idea
+. ./bin/lib
+check_passwd_file "$root_pwd_file"
+DIR=$(dirname $(realpath $0)) +cmd=(
- docker run
- --name init_docker
can add --rm ?
Ok. I will add.
Thanks, Chenglong
Thanks, Shenwei
- -v $DIR/bin/:/root/bin
- -v /srv/initrd/modules/:/root/modules
- -e ROOT_NEW_PASSWD=$ROOT_NEW_PASSWD
- -e image_name=$image_name
- $image
- /root/bin/creat
+)
+pull_docker
+${cmd[@]}
+docker cp -a init_docker:/${image_name} ./ +echo "build finished!!!"
-- 2.23.0
+DIR=$(dirname $(realpath $0)) +cmd=(
- docker run
- --name init_docker
can add --rm ?
I tried to add --rm but got an error. it need to run "docker cp" on the host. if use "--rm" the container will death, "docker cp" will failed
Thanks, Shenwei
- -v $DIR/bin/:/root/bin
- -v /srv/initrd/modules/:/root/modules
- -e ROOT_NEW_PASSWD=$ROOT_NEW_PASSWD
- -e image_name=$image_name
- $image
- /root/bin/creat
+)
+pull_docker
+${cmd[@]}
+docker cp -a init_docker:/${image_name} ./ +echo "build finished!!!"
-- 2.23.0
On Sat, Oct 10, 2020 at 04:10:37PM +0800, Wang Chenglong wrote:
+DIR=$(dirname $(realpath $0)) +cmd=(
- docker run
- --name init_docker
can add --rm ?
I tried to add --rm but got an error. it need to run "docker cp" on the host. if use "--rm" the container will death, "docker cp" will failed
right, you can use another way to del it
docker_rm init_docker
Thanks, Shenwei
Thanks, Shenwei
- -v $DIR/bin/:/root/bin
- -v /srv/initrd/modules/:/root/modules
- -e ROOT_NEW_PASSWD=$ROOT_NEW_PASSWD
- -e image_name=$image_name
- $image
- /root/bin/creat
+)
+pull_docker
+${cmd[@]}
+docker cp -a init_docker:/${image_name} ./ +echo "build finished!!!"
-- 2.23.0
On Sat, Oct 10, 2020 at 04:13:15PM +0800, Xiao Shenwei wrote:
On Sat, Oct 10, 2020 at 04:10:37PM +0800, Wang Chenglong wrote:
+DIR=$(dirname $(realpath $0)) +cmd=(
- docker run
- --name init_docker
can add --rm ?
I tried to add --rm but got an error. it need to run "docker cp" on the host. if use "--rm" the container will death, "docker cp" will failed
right, you can use another way to del it
docker_rm init_docker
Ok.
Thanks, Chenglong
Thanks, Shenwei
Thanks, Shenwei
- -v $DIR/bin/:/root/bin
- -v /srv/initrd/modules/:/root/modules
- -e ROOT_NEW_PASSWD=$ROOT_NEW_PASSWD
- -e image_name=$image_name
- $image
- /root/bin/creat
+)
+pull_docker
+${cmd[@]}
+docker cp -a init_docker:/${image_name} ./ +echo "build finished!!!"
-- 2.23.0
All notes should be like "# xxx".
+#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+#Configure rootfs +make_rootfs() +{
- yum repolist
- yum -y install $(</root/bin/repolist)
- yum clean all
- rm -rf $(</root/bin/dellist)
- ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- cd /root/modules
- zcat modules-5.8.0.1.cgz | cpio -idmv >/dev/null
+}
+#config passwd +pre_config_rootfs() {
- [ -n "$ROOT_NEW_PASSWD" ] && {
echo "Changing root password"
passwd_md5=$(openssl passwd -1 "$ROOT_NEW_PASSWD")
echo $passwd_md5
sed -i -r "s/^root:[^:]*:(.*)/root:${passwd_md5//\//\\/}:\1/" "$ROOTFS_DIR/etc/shadow"
sed -i 's/[# ]PermitRootLogin.*/PermitRootLogin yes/' "$ROOTFS_DIR/etc/ssh/sshd_config"
Pls add some notes here.
Thanks, Xijian
On Sat, Oct 10, 2020 at 03:36:40PM +0800, Xu Xijian wrote:
All notes should be like "# xxx".
+#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+#Configure rootfs +make_rootfs() +{
- yum repolist
- yum -y install $(</root/bin/repolist)
- yum clean all
- rm -rf $(</root/bin/dellist)
- ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- cd /root/modules
- zcat modules-5.8.0.1.cgz | cpio -idmv >/dev/null
+}
+#config passwd +pre_config_rootfs() {
- [ -n "$ROOT_NEW_PASSWD" ] && {
echo "Changing root password"
passwd_md5=$(openssl passwd -1 "$ROOT_NEW_PASSWD")
echo $passwd_md5
sed -i -r "s/^root:[^:]*:(.*)/root:${passwd_md5//\//\\/}:\1/" "$ROOTFS_DIR/etc/shadow"
sed -i 's/[# ]PermitRootLogin.*/PermitRootLogin yes/' "$ROOTFS_DIR/etc/ssh/sshd_config"
Pls add some notes here.
Ok. got it.
Thanks, Chenglong
Thanks, Xijian