From da31263a93675ecbcbe4c076ffb8472354eb416c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Sch=C3=B6nleber?= Date: Tue, 24 Aug 2021 13:46:18 +0200 Subject: [PATCH] fix(): image generation for new versions --- Dockerfile | 7 ++++++ README.md | 12 ++++------- build_image.sh | 35 ++++++++++++++++++++++++++++++ scripts/.gitignore | 4 ++++ scripts/clean_in_chroot.sh | 11 ++++------ scripts/generate.sh | 44 +++++++++++++++++++------------------- 6 files changed, 76 insertions(+), 37 deletions(-) create mode 100644 Dockerfile create mode 100755 build_image.sh create mode 100644 scripts/.gitignore diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..04dfd95 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM scratch + +ARG ARCH +ARG OS_VERSION + +ADD scripts/${ARCH}/EulerOS-${OS_VERSION}-${ARCH}.tar.xz / +CMD ["bash"] diff --git a/README.md b/README.md index df7c342..a1e736c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ ![EulerOS logo](logo.png "EulerOS logo") - # EulerOS EulerOS provides enhanced security, compatibility and easy-to-use features along with high reliability. It meets the increasing requirements of Linux OS in enterprise applications and provides a compelling choice of open IT platform for users. EulerOS integrates the advanced Linux technologies, delivers more value to enterprise users in terms of high capability, stability, usability and expansibility. And it helps you reallocate resources from maintaining the status quo to tackling new challenges. @@ -18,13 +17,10 @@ EulerOS is released under the GPLv2. See the ```LICENSE``` file in this reposito ## Release roadmap EulerOS Docker image will release a new version according to its associated [ISO](https://developer.huawei.com/ict/cn/rescenter/CMDA_FIELD_EULER_OS?developlan=Other). Generally Docker image releases a new version every three months, one month after ISO releasing. -One can use the following steps to generate Docker images from ISO. -* download iso and mount it to `/mnt/iso` -* `export ISO_PATH=/mnt/iso` -* download [scripts](scripts) into a proper dir, such as `~/images_scripts` -* `cd ~/images_scripts && export RPM_ROOT=$(pwd)/rootfs` -* export OS_VERSION such as `export OS_VERSION=2.3` -* `bash generate.sh` +## How to generate the docker image +```bash +./build_image.sh --arch=aarch64 --os-version=2.8 +``` ## Support Details Huawei offers 8x5 Comprehensive Support diff --git a/build_image.sh b/build_image.sh new file mode 100755 index 0000000..82539ef --- /dev/null +++ b/build_image.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +ARCH=$(uname -m) +OS_VERSION=2.5 + +for i in "$@"; do + case $i in + -a=*|--arch=*) + ARCH="${i#*=}" + shift + ;; + -o=*|--os-version=*) + OS_VERSION="${i#*=}" + shift + ;; + *) + ;; + esac +done +cd scripts + +id=`docker run -it -d --rm \ + -v $PWD:/euleros \ + -w /euleros \ + -v /var/run/docker.sock:/var/run/docker.sock \ + centos:8 bash` + +docker exec -t \ + -e RPM_ROOT="/euleros/rootfs" \ + $id /bin/bash -c "bash generate.sh $ARCH $OS_VERSION" + +docker kill $id + +cd .. +docker build -f Dockerfile --build-arg ARCH=$ARCH --build-arg OS_VERSION=$OS_VERSION . diff --git a/scripts/.gitignore b/scripts/.gitignore new file mode 100644 index 0000000..e61d6b8 --- /dev/null +++ b/scripts/.gitignore @@ -0,0 +1,4 @@ +x86_64 +aarch64 +rootfs +RPM-GPG-KEY-EulerOS \ No newline at end of file diff --git a/scripts/clean_in_chroot.sh b/scripts/clean_in_chroot.sh index 8605d1f..5e82b57 100755 --- a/scripts/clean_in_chroot.sh +++ b/scripts/clean_in_chroot.sh @@ -1,5 +1,6 @@ #!/bin/bash - +ARCH="$1" +OS_VERSION=$2 rm /var/cache/yum/* -rf rm /var/cache/yum/.* -rf @@ -8,12 +9,8 @@ rm /var/lib/yum/history/* -rf rm /root/.rpmdb -rf # set up yum.repo -repo="[base]\n -name=EulerOS-2.0SP3 base\n -baseurl=http://developer.huawei.com/ict/site-euleros/euleros/repo/yum/$OS_VERSION/os/$machine/\n -enabled=1\n -gpgcheck=1\n -gpgkey=http://developer.huawei.com/ict/site-euleros/euleros/repo/yum/$OS_VERSION/os/RPM-GPG-KEY-EulerOS" +# https://mirrors.huaweicloud.com/euler/2.5/os/x86_64/ +repo="[base]\nname=EulerOS base\nbaseurl=https://mirrors.huaweicloud.com/euler/$OS_VERSION/os/${ARCH}/\nenabled=1\ngpgcheck=1\ngpgkey=https://mirrors.huaweicloud.com/euler/$OS_VERSION/os/RPM-GPG-KEY-EulerOS" echo -e $repo > /etc/yum.repos.d/euleros.repo diff --git a/scripts/generate.sh b/scripts/generate.sh index f999c55..936ec00 100755 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -1,7 +1,9 @@ -machine=$(uname -m) +ARCH="$1" +OS_VERSION=$2 +echo $1 $2 $ARCH $OS_VERSION if [ -z $RPM_ROOT ]; then - rm -rf $machine + rm -rf $ARCH echo "please set PRM_ROOT" exit fi @@ -10,23 +12,19 @@ if [ "x$RPM_ROOT" != "x$(pwd)/rootfs" ]; then echo "should set PRM_ROOT to $(pwd)/rootfs" exit fi + if [ -z "$OS_VERSION" ]; then echo "should set OS_VERSION" exit fi -if [ -z $ISO_PATH ];then - echo "please set ISO_PATH as iso mountpoint" - exit -fi - -if [ "x$USER" != "xroot" ]; then - echo "please run as root" - exit -fi +# if [ "x$USER" != "xroot" ]; then +# echo "please run as root" +# exit +# fi if [ -e $RPM_ROOT ];then - echo "rootfs exist, remove it" + # echo "rootfs exist, remove it" rm -rf $RPM_ROOT fi @@ -40,13 +38,14 @@ rpm --root ${RPM_ROOT} --initdb mkdir -p ${RPM_ROOT}/etc/yum.repos.d euleros_repo=${RPM_ROOT}/etc/yum.repos.d/euleros.repo echo "[base]" > ${euleros_repo} -echo name=EulerOS-2.0SP3 base >> ${euleros_repo} -echo baseurl=file://${ISO_PATH} >> ${euleros_repo} +echo name=EulerOS base >> ${euleros_repo} +echo baseurl=https://mirrors.huaweicloud.com/euler/$OS_VERSION/os/${ARCH}/ >> ${euleros_repo} echo "enabled=1" >> ${euleros_repo} +curl https://mirrors.huaweicloud.com/euler/$OS_VERSION/os/RPM-GPG-KEY-EulerOS --output RPM-GPG-KEY-EulerOS # install rpm key -rpm --root ${RPM_ROOT} --import $ISO_PATH/RPM-GPG-KEY-EulerOS +rpm --root ${RPM_ROOT} --import RPM-GPG-KEY-EulerOS # install package @@ -58,7 +57,7 @@ yum -y --installroot=${RPM_ROOT} clean all cp ./clean_in_chroot.sh ${RPM_ROOT} # clean up -chroot $RPM_ROOT /clean_in_chroot.sh +chroot $RPM_ROOT /clean_in_chroot.sh $ARCH $OS_VERSION echo "return: $?" #if [ $? -ne 0 ]; then # echo "chroot failed" @@ -69,12 +68,13 @@ echo "return: $?" rm ${RPM_ROOT}/clean_in_chroot.sh echo "generate packages" -rm -rf $machine -mkdir $machine -echo "generate $machine/EulerOS-$OS_VERSION-${machine}.tar.xz" -tar -C $RPM_ROOT -cJf $machine/EulerOS-$OS_VERSION-${machine}.tar.xz . +rm -rf $ARCH +mkdir $ARCH +echo "generate $ARCH/EulerOS-$OS_VERSION-${ARCH}.tar.xz" +tar -C $RPM_ROOT -cJf $ARCH/EulerOS-$OS_VERSION-${ARCH}.tar.xz . -echo "enerate $machine/EulerOS-$OS_VERSION-${machine}-tar-xz.sha256" +echo "generate $ARCH/EulerOS-$OS_VERSION-${ARCH}-tar-xz.sha256" -sha256sum $machine/EulerOS-$OS_VERSION-${machine}.tar.xz > $machine/EulerOS-$OS_VERSION-${machine}-tar-xz.sha256 +sha256sum $ARCH/EulerOS-$OS_VERSION-${ARCH}.tar.xz > $ARCH/EulerOS-$OS_VERSION-${ARCH}-tar-xz.sha256 +rm -rf rootfs \ No newline at end of file