Skip to content

image generation for new versions and automate #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM scratch

ARG ARCH
ARG OS_VERSION

ADD scripts/${ARCH}/EulerOS-${OS_VERSION}-${ARCH}.tar.xz /
CMD ["bash"]
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down
35 changes: 35 additions & 0 deletions build_image.sh
Original file line number Diff line number Diff line change
@@ -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 .
4 changes: 4 additions & 0 deletions scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
x86_64
aarch64
rootfs
RPM-GPG-KEY-EulerOS
11 changes: 4 additions & 7 deletions scripts/clean_in_chroot.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

ARCH="$1"
OS_VERSION=$2

rm /var/cache/yum/* -rf
rm /var/cache/yum/.* -rf
Expand All @@ -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

Expand Down
44 changes: 22 additions & 22 deletions scripts/generate.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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"
Expand All @@ -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