Skip to content

Commit

Permalink
debian:buster remove loongson gpu
Browse files Browse the repository at this point in the history
  • Loading branch information
znley committed Nov 9, 2023
1 parent fa49c09 commit 5190579
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
1 change: 1 addition & 0 deletions loongson/loongnix/20/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
rootfs.tar.gz
rootfs.tar.xz
4 changes: 2 additions & 2 deletions loongson/loongnix/20/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TAG?=20
IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG)
ALIAS=cr.loongnix.cn/library/debian:buster

ROOTFS=rootfs.tar.gz
ROOTFS=rootfs.tar.xz

default: image

Expand All @@ -27,4 +27,4 @@ $(ROOTFS):
docker run --rm \
-v `pwd`:/work \
cr.loongnix.cn/library/debian:buster \
/bin/bash -c "/work/make_rootfs.sh /work"
/bin/bash -c "/work/make_rootfs.sh"
47 changes: 42 additions & 5 deletions loongson/loongnix/20/make_rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ set -ex

: ${MIRROR_ADDRESS:="http://pkg.loongnix.cn/loongnix"}
: ${RELEASE:="DaoXiangHu-stable"}
: ${ROOTFS:="rootfs.tar.gz"}
: ${ROOTFS:="rootfs.tar.xz"}
: ${APT_CONF_URL:="https://raw.githubusercontent.com/GoogleContainerTools/base-images-docker/master/debian/reproducible/overlay/etc/apt/apt.conf.d/"}

DISTRO=loongnix

WKDIR=$1
cd ${WKDIR?}
OUTPUT=$(cd $(dirname $0); pwd)
cd ${OUTPUT?}

apt update
apt install -y debootstrap
apt install -y curl debootstrap xz-utils
# loongnix do not have $RELEASE file, fix it!
if [ ! -f /usr/share/debootstrap/scripts/$RELEASE ]; then
ln -s /usr/share/debootstrap/scripts/sid /usr/share/debootstrap/scripts/$RELEASE
Expand All @@ -24,5 +26,40 @@ TMPDIR=`mktemp -d`
debootstrap --no-check-gpg --variant=minbase --components=main,non-free,contrib --arch=loongarch64 --foreign $RELEASE $TMPDIR $MIRROR_ADDRESS
chroot $TMPDIR debootstrap/debootstrap --second-stage
chroot $TMPDIR rm -rf /tmp/* /var/cache/apt/* /var/lib/apt/lists/*

# https://github.com/GoogleContainerTools/base-images-docker/tree/master/debian/reproducible/overlay/etc/apt/apt.conf.d
apt_conf=(
apt-retry
docker-autoremove-suggests
docker-clean
docker-gzip-indexes
)

for apt_file in ${apt_conf[@]};do
curl -o $TMPDIR/etc/apt/apt.conf.d/${apt_file} -sSL ${APT_CONF_URL}/${apt_file}
done

pkgExcludes='loongnix-gpu-driver-service,loonggpu-compiler,loonggl-dev'
pkgIncludes='libncursesw6,libseccomp2,sysvinit-utils'
chroot $TMPDIR bash -c '
apt-get -o apt-get -o Acquire::Check-Valid-Until=false update -qq
if apt-mark --help &> /dev/null; then
apt-mark auto ".*" > /dev/null
fi
if [ -n "$1" ]; then
IFS=","; includePackages=( $1 ); unset IFS
apt-get install -y --no-install-recommends "${includePackages[@]}"
fi
if [ -n "$2" ]; then
IFS=","; excludePackages=( $2 ); unset IFS
apt-get autoremove -y --purge --allow-remove-essential "${excludePackages[@]}"
fi
for user in systemd-timesync systemd-network systemd-resolve; do
if id $user >/dev/null; then
userdel --force --remove $user
fi
done
' -- $pkgIncludes $pkgExcludes

# package rootfs.tar.gz
tar -zcvf $ROOTFS -C $TMPDIR .
tar -cJvf $ROOTFS -C $TMPDIR .

0 comments on commit 5190579

Please sign in to comment.