Skip to content
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

add docker images for openeuler loongnix-server anolisos #126

Merged
Merged
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
4 changes: 4 additions & 0 deletions library/anolisos/23.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
From scratch
MAINTAINER [email protected]
ADD AnolisOS-23.rootfs.loongarch64.tar.gz /
CMD ["/bin/bash"]
30 changes: 30 additions & 0 deletions library/anolisos/23.2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file is generated by the template.

REGISTRY ?=lcr.loongnix.cn
ORGANIZATION ?=library
REPOSITORY ?=anolisos
TAG ?=23.2
LATEST ?=true

IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG)
LATEST_IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):latest

default: image

rootfs:
bash mkimage-rootfs.sh
image: rootfs
docker build \
--build-arg http_proxy=$(http_proxy) \
--build-arg https_proxy=$(https_proxy) \
-t $(IMAGE) \
.

push:
docker push $(IMAGE)
#latest image
@if [ $(LATEST) = "true" ]; \
then \
docker tag $(IMAGE) $(LATEST_IMAGE); \
docker push $(LATEST_IMAGE); \
fi
169 changes: 169 additions & 0 deletions library/anolisos/23.2/mkimage-rootfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#!/bin/sh
#
# for AnolisOS 23
# create rootfs.tar from repository
#
#set -x

set -e

arch=loongarch64
#release=$1
releasever=23
version=23
if [ -z $version ]
then
echo "releasever or version is empty!!!"
exit 1
fi

output="AnolisOS-${version}.rootfs.${arch}.tar.gz"

repos_baseos_url="https://build.openanolis.cn/kojifiles/output/nightly/anolis-23-20241209.4/compose/os/loongarch64/os/"

trap cleanup TERM EXIT

work_dir=$(mktemp -d $(pwd)/rootfs-image.XXXXXX)
rootfs=${work_dir}/rootfs

repo_dir="${work_dir}/yum.repo.d"
repo_conf="${repo_dir}/AnolisOS.repo"
setting_scripts=setting.sh

pkg_list="
basesystem bash ca-certificates anolis-gpg-keys anolis-release
anolis-repos chkconfig cracklib crypto-policies dnf passwd
expat gawk gdbm glib2 glibc gmp gnupg2 gpgme grep ima-evm-utils
json-c mpfr ncurses-base procps rpm-build git findutils dnf-plugins-core
npth p11-kit p11-kit-trust pcre pcre2 popt readline rootfiles
rpm sed setup systemd systemd-libs tzdata util-linux vim-minimal xz yum
"
#pkg_list="
# acl basesystem bash ca-certificates anolis-gpg-keys anolis-release
# anolis-repos chkconfig cracklib crypto-policies dnf
# expat gawk gdbm glib2 glibc gmp gnupg2 gpgme grep ima-evm-utils
# ipcalc iputils json-c kexec-tools kmod langpacks-en less lzo mpfr ncurses-base
# npth p11-kit p11-kit-trust pam pcre pcre2 popt procps-ng readline rootfiles
# rpm sed setup systemd-libs tzdata util-linux vim-minimal xz yum
#"

####################################################################
cleanup()
{
rm -rf ${work_dir}
}
####################################################################

mkdir -pv ${rootfs} || :
mkdir -pv ${repo_dir} || :

####################################################################
# gen repos conf
####################################################################
cat > ${repo_conf} << EOF
[baseos]
name=AnolisOS-$releasever-baseos
baseurl=${repos_baseos_url}
gpgcheck=0
enabled=1
priority=1
excludepkgs="${exclude_pkgs}"
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-LOONGNIX
EOF
####################################################################


####################################################################
DNF_OPTS="\
--setopt=install_weak_deps=False \
--setopt=reposdir=${repo_dir} \
--releasever=${releasever} \
--installroot=${rootfs} \
--nodocs"

echo "Install packages : $pkg_list"

rpmdb --root=${rootfs} --initdb
dnf ${DNF_OPTS} makecache --refresh
dnf ${DNF_OPTS} -y install ${pkg_list}
####################################################################

####################################################################
cat > ${rootfs}/${setting_scripts} << EOF
#!/bin/bash

## config TERM is linux
echo 'export TERM=linux' >> etc/bash.bashrc
echo 'container' > /etc/dnf/vars/infra

#Generate installtime file record
/bin/date +%Y%m%d_%H%M > /etc/BUILDTIME

# Limit languages to help reduce size.
LANG="en_US"
echo "%_install_langs $LANG" > /etc/rpm/macros.image-language-conf
echo "LANG=en_US.UTF-8" > /etc/locale.conf

pushd /usr/share/locale > /dev/null
ls | egrep -x -v "en|en@arabic|en@boldquot|en@cyrillic|en@greek|en@hebrew|en@piglatin|en@quot|en@shaw|en_CA|en_GB|en_US|locale.alias" | xargs rm -rf
popd > /dev/null

# systemd fixes
:> /etc/machine-id
systemd-tmpfiles --create --boot
# mask mounts and login bits
systemctl mask systemd-logind.service getty.target console-getty.service
systemctl mask sys-fs-fuse-connections.mount systemd-remount-fs.service dev-hugepages.mount

# Remove things we don't need
yum clean all > /dev/null
rm -rf /etc/udev/hwdb.bin
rm -rf /usr/lib/udev/hwdb.d/
rm -rf /boot
rm -rf /var/lib/dnf/history.*
rm -rf /usr/src/
rm -rf /home/*
rm -rf /var/log/*
rm -rf /var/cache/*
rm -rf /var/lib/yum/*
## Introduced by binutils
rm -rf /usr/bin/gdb
rm -f \$0
###########################################################################
EOF
####################################################################

chmod +x ${rootfs}/${setting_scripts}
chroot ${rootfs} /${setting_scripts}

##解决在rootfs中su命令没有权限问题
#file_list="fingerprint-auth password-auth postlogin smartcard-auth system-auth user-profile"
#for file in ${file_list}
#do
# chroot ${rootfs} authselect create-profile ${file}
# chroot ${rootfs} ln -s /etc/authselect/custom/${file} /etc/pam.d/${file}
#done

##解决在chroot中/dev/null没有权限问题
chroot ${rootfs} rm -rf /dev/null
chroot ${rootfs} mknod /dev/null c 1 3
chroot ${rootfs} chmod 666 /dev/null

cur_dir=$(pwd)
pushd ${rootfs} > /dev/null
if [ -e "${cur_dir}/${output}" ]; then
echo "Remove old ${output}"
rm -rf "${cur_dir}/${output}"
fi

echo "Generating ${output} ...."
# tar --numeric-owner --exclude='dev/*' -acf "${cur_dir}/${output}" .
tar --numeric-owner -acf "${cur_dir}/${output}" .
popd > /dev/null

echo "Generating ${output} md5sum...."
sync && md5sum ${output} > ${output}.md5

######################################
sync && echo -e "\n^^^^^^ done ^^^^^^^^^^\n"
######################################
4 changes: 4 additions & 0 deletions library/loongnix-server/23.1-beta2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
From scratch
MAINTAINER [email protected]
ADD Loongnix-Server-23.rootfs.loongarch64.tar.gz /
CMD ["/bin/bash"]
30 changes: 30 additions & 0 deletions library/loongnix-server/23.1-beta2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file is generated by the template.

REGISTRY ?=lcr.loongnix.cn
ORGANIZATION ?=library
REPOSITORY ?=loongnix-server
TAG ?=23.1-beta2
LATEST ?=true

IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG)
LATEST_IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):latest

default: image

rootfs:
bash mkimage-rootfs.sh
image: rootfs
docker build \
--build-arg http_proxy=$(http_proxy) \
--build-arg https_proxy=$(https_proxy) \
-t $(IMAGE) \
.

push:
docker push $(IMAGE)
#latest image
@if [ $(LATEST) = "true" ]; \
then \
docker tag $(IMAGE) $(LATEST_IMAGE); \
docker push $(LATEST_IMAGE); \
fi
Loading
Loading