Skip to content

Commit 30e4e44

Browse files
committed
Add loongnix server 23.2
1 parent 5c6a97c commit 30e4e44

File tree

3 files changed

+206
-0
lines changed

3 files changed

+206
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
From scratch
2+
MAINTAINER zhangwenlong@loongson.cn
3+
ADD Loongnix-Server-23.2.rootfs.loongarch64.tar.gz /
4+
CMD ["/bin/bash"]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This file is generated by the template.
2+
3+
REGISTRY ?=lcr.loongnix.cn
4+
ORGANIZATION ?=loongnix
5+
REPOSITORY ?=loongnix-server
6+
TAG ?=23.2
7+
LATEST ?=false
8+
9+
IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG)
10+
LATEST_IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):latest
11+
12+
default: image
13+
14+
rootfs:
15+
docker run --rm --security-opt seccomp=unconfined \
16+
-v `pwd`:/wk lcr.loongnix.cn/loongnix/loongnix-server:23.1 \
17+
/bin/bash -c -- '/wk/mkimage-rootfs.sh;cp /*tar.gz* /wk'
18+
image: rootfs
19+
docker build \
20+
--build-arg http_proxy=$(http_proxy) \
21+
--build-arg https_proxy=$(https_proxy) \
22+
-t $(IMAGE) \
23+
.
24+
25+
push:
26+
docker push $(IMAGE)
27+
#latest image
28+
@if [ $(LATEST) = "true" ]; \
29+
then \
30+
docker tag $(IMAGE) $(LATEST_IMAGE); \
31+
docker push $(LATEST_IMAGE); \
32+
fi
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
#!/bin/sh
2+
#
3+
# for Loongnix-Server 23.2
4+
# create rootfs.tar from repository
5+
#
6+
#set -x
7+
8+
set -e
9+
10+
arch=loongarch64
11+
#release=$1
12+
releasever=23.2
13+
version=23.2
14+
if [ -z $version ]
15+
then
16+
echo "releasever or version is empty!!!"
17+
exit 1
18+
fi
19+
20+
output="Loongnix-Server-${version}.rootfs.${arch}.tar.gz"
21+
22+
repos_baseos_url="https://pkg.loongnix.cn/loongnix-server/23.2/os/loongarch64/"
23+
24+
trap cleanup TERM EXIT
25+
26+
work_dir=$(mktemp -d $(pwd)/rootfs-image.XXXXXX)
27+
rootfs=${work_dir}/rootfs
28+
29+
repo_dir="${work_dir}/yum.repo.d"
30+
repo_conf="${repo_dir}/Loongnix-server.repo"
31+
setting_scripts=setting.sh
32+
33+
pkg_list="
34+
basesystem bash ca-certificates loongnix-gpg-keys loongnix-release
35+
loongnix-repos chkconfig cracklib crypto-policies dnf passwd
36+
expat gawk gdbm glib2 glibc gmp gnupg2 gpgme grep ima-evm-utils
37+
json-c mpfr ncurses-base procps rpm-build git findutils dnf-plugins-core
38+
npth p11-kit p11-kit-trust pcre pcre2 popt readline rootfiles
39+
rpm sed setup systemd systemd-libs tzdata util-linux vim-minimal xz yum cracklib-dicts
40+
"
41+
#pkg_list="
42+
# acl basesystem bash ca-certificates loongnix-gpg-keys loongnix-release
43+
# loongnix-repos chkconfig cracklib crypto-policies dnf
44+
# expat gawk gdbm glib2 glibc gmp gnupg2 gpgme grep ima-evm-utils
45+
# ipcalc iputils json-c kexec-tools kmod langpacks-en less lzo mpfr ncurses-base
46+
# npth p11-kit p11-kit-trust pam pcre pcre2 popt procps-ng readline rootfiles
47+
# rpm sed setup systemd-libs tzdata util-linux vim-minimal xz yum
48+
#"
49+
50+
####################################################################
51+
cleanup()
52+
{
53+
rm -rf ${work_dir}
54+
}
55+
####################################################################
56+
57+
mkdir -pv ${rootfs} || :
58+
mkdir -pv ${repo_dir} || :
59+
60+
####################################################################
61+
# gen repos conf
62+
####################################################################
63+
cat > ${repo_conf} << EOF
64+
[baseos]
65+
name=Loongnix-Server-$releasever-baseos
66+
baseurl=${repos_baseos_url}
67+
gpgcheck=0
68+
enabled=1
69+
priority=1
70+
excludepkgs="${exclude_pkgs}"
71+
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-LOONGNIX
72+
EOF
73+
####################################################################
74+
75+
76+
####################################################################
77+
DNF_OPTS="\
78+
--setopt=install_weak_deps=False \
79+
--setopt=reposdir=${repo_dir} \
80+
--releasever=${releasever} \
81+
--installroot=${rootfs} \
82+
--nodocs"
83+
84+
echo "Install packages : $pkg_list"
85+
86+
rpmdb --root=${rootfs} --initdb
87+
dnf ${DNF_OPTS} clean packages
88+
dnf ${DNF_OPTS} makecache --refresh
89+
dnf ${DNF_OPTS} -y install ${pkg_list}
90+
####################################################################
91+
92+
####################################################################
93+
cat > ${rootfs}/${setting_scripts} << EOF
94+
#!/bin/bash
95+
96+
## config TERM is linux
97+
echo 'export TERM=linux' >> etc/bash.bashrc
98+
echo 'container' > /etc/dnf/vars/infra
99+
100+
#Generate installtime file record
101+
/bin/date +%Y%m%d_%H%M > /etc/BUILDTIME
102+
103+
# Limit languages to help reduce size.
104+
LANG="en_US"
105+
echo "%_install_langs $LANG" > /etc/rpm/macros.image-language-conf
106+
echo "LANG=en_US.UTF-8" > /etc/locale.conf
107+
108+
pushd /usr/share/locale > /dev/null
109+
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
110+
popd > /dev/null
111+
112+
# systemd fixes
113+
:> /etc/machine-id
114+
systemd-tmpfiles --create --boot
115+
# mask mounts and login bits
116+
systemctl mask systemd-logind.service getty.target console-getty.service
117+
systemctl mask sys-fs-fuse-connections.mount systemd-remount-fs.service dev-hugepages.mount
118+
119+
# Remove things we don't need
120+
yum clean all > /dev/null
121+
rm -rf /etc/udev/hwdb.bin
122+
rm -rf /usr/lib/udev/hwdb.d/
123+
rm -rf /boot
124+
rm -rf /var/lib/dnf/history.*
125+
rm -rf /usr/src/
126+
rm -rf /home/*
127+
rm -rf /var/log/*
128+
rm -rf /var/cache/*
129+
rm -rf /var/lib/yum/*
130+
## Introduced by binutils
131+
rm -rf /usr/bin/gdb
132+
rm -f \$0
133+
###########################################################################
134+
EOF
135+
####################################################################
136+
137+
chmod +x ${rootfs}/${setting_scripts}
138+
chroot ${rootfs} /${setting_scripts}
139+
140+
##解决在rootfs中su命令没有权限问题
141+
#file_list="fingerprint-auth password-auth postlogin smartcard-auth system-auth user-profile"
142+
#for file in ${file_list}
143+
#do
144+
# chroot ${rootfs} authselect create-profile ${file}
145+
# chroot ${rootfs} ln -s /etc/authselect/custom/${file} /etc/pam.d/${file}
146+
#done
147+
148+
##解决在chroot中/dev/null没有权限问题
149+
chroot ${rootfs} rm -rf /dev/null
150+
chroot ${rootfs} mknod /dev/null c 1 3
151+
chroot ${rootfs} chmod 666 /dev/null
152+
153+
cur_dir=$(pwd)
154+
pushd ${rootfs} > /dev/null
155+
if [ -e "${cur_dir}/${output}" ]; then
156+
echo "Remove old ${output}"
157+
rm -rf "${cur_dir}/${output}"
158+
fi
159+
160+
echo "Generating ${output} ...."
161+
# tar --numeric-owner --exclude='dev/*' -acf "${cur_dir}/${output}" .
162+
tar --numeric-owner -acf "${cur_dir}/${output}" .
163+
popd > /dev/null
164+
165+
echo "Generating ${output} md5sum...."
166+
sync && md5sum ${output} > ${output}.md5
167+
168+
######################################
169+
sync && echo -e "\n^^^^^^ done ^^^^^^^^^^\n"
170+
######################################

0 commit comments

Comments
 (0)