On Thu, Nov 26, 2020 at 09:58:07AM +0800, Xiao Shenwei wrote:
how about: generate the cgz file in container
Good.
Reply-To: In-Reply-To: 20201126012754.3857939-3-18509160991@163.com
On Thu, Nov 26, 2020 at 09:27:52AM +0800, Wang Chenglong wrote:
Install packages, set rootfs, pack images package and other actions in docker.
Signed-off-by: Wang Chenglong 18509160991@163.com
container/osimage/openeuler/create-image | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 container/osimage/openeuler/create-image
diff --git a/container/osimage/openeuler/create-image b/container/osimage/openeuler/create-image new file mode 100755 index 0000000..58fe0b1 --- /dev/null +++ b/container/osimage/openeuler/create-image @@ -0,0 +1,40 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+install_packages() +{
- yum repolist
- yum -y install --skip-broken $(</tmp/packages-to-install)
- yum clean all
+}
where use /tmp/file-to-exclude
In pack_cgz()
Thanks, Chenglong
Thanks, Shenwei
+setup_rootfs() +{
- ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- rm -f /etc/machine-id
- rm -f /var/lib/dbus/machine-id
- systemd-machine-id-setup
+}
+setup_login() {
- [ -n "$ROOT_PASSWD" ] || return
- echo "Changing root password"
- passwd_md5=$(openssl passwd -1 "$ROOT_PASSWD")
- 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() +{
- echo "Packing package. Please wait."
- find / ! -path "/tmp/${IMAGE_NAME}" | grep -vf /tmp/files-to-exclude | cpio -o -Hnewc | gzip -9 > /tmp/${IMAGE_NAME}
- chmod 644 /tmp/${IMAGE_NAME}
+}
+install_packages +setup_rootfs +setup_login
+pack_cgz
2.23.0