aboutsummaryrefslogtreecommitdiff
path: root/docker/debian-dev/bootstrap
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2023-11-13 13:46:35 +0800
committercrupest <crupest@outlook.com>2023-11-13 13:47:29 +0800
commite780b089b6d86941f6c03061a2a7a54ae4ec36de (patch)
tree2d186fe0c334ebd7d4e35e2a3983e60ffc53d375 /docker/debian-dev/bootstrap
parented1df454af6e3c8726a80f32cc6db8e9d42d046f (diff)
downloadcrupest-e780b089b6d86941f6c03061a2a7a54ae4ec36de.tar.gz
crupest-e780b089b6d86941f6c03061a2a7a54ae4ec36de.tar.bz2
crupest-e780b089b6d86941f6c03061a2a7a54ae4ec36de.zip
(docker:debian-dev) Refactor sources management. Improve build scripts.
Diffstat (limited to 'docker/debian-dev/bootstrap')
-rw-r--r--docker/debian-dev/bootstrap/apt-source/china-source.txt1
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/get-domain.bash6
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/replace-domain.bash7
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/replace-http.bash10
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/setup.bash12
-rw-r--r--docker/debian-dev/bootstrap/bash-profile/cp-no-git.bash2
-rw-r--r--docker/debian-dev/bootstrap/bash-profile/dev.bash13
-rwxr-xr-xdocker/debian-dev/bootstrap/replace-mirrors.bash15
-rwxr-xr-xdocker/debian-dev/bootstrap/setup-base.bash1
-rwxr-xr-xdocker/debian-dev/bootstrap/setup-dev-tools.bash3
-rwxr-xr-xdocker/debian-dev/bootstrap/setup-sbuild.bash6
-rw-r--r--docker/debian-dev/bootstrap/source-http.txt11
-rw-r--r--docker/debian-dev/bootstrap/source-https.txt11
-rw-r--r--docker/debian-dev/bootstrap/source-link.txt1
14 files changed, 48 insertions, 51 deletions
diff --git a/docker/debian-dev/bootstrap/apt-source/china-source.txt b/docker/debian-dev/bootstrap/apt-source/china-source.txt
new file mode 100644
index 0000000..3821ffc
--- /dev/null
+++ b/docker/debian-dev/bootstrap/apt-source/china-source.txt
@@ -0,0 +1 @@
+mirrors.ustc.edu.cn
diff --git a/docker/debian-dev/bootstrap/apt-source/get-domain.bash b/docker/debian-dev/bootstrap/apt-source/get-domain.bash
new file mode 100755
index 0000000..c9b93b1
--- /dev/null
+++ b/docker/debian-dev/bootstrap/apt-source/get-domain.bash
@@ -0,0 +1,6 @@
+#! /usr/bin/env bash
+
+set -e
+
+sed "s|.*https\?://\([-_.a-zA-Z0-9]\+\)/.*|\\1|;q" /etc/apt/sources.list
+
diff --git a/docker/debian-dev/bootstrap/apt-source/replace-domain.bash b/docker/debian-dev/bootstrap/apt-source/replace-domain.bash
new file mode 100755
index 0000000..cef36a3
--- /dev/null
+++ b/docker/debian-dev/bootstrap/apt-source/replace-domain.bash
@@ -0,0 +1,7 @@
+#! /usr/bin/env bash
+
+set -e
+
+sed -i.bak "s|\(https\?://\)[-_.a-zA-Z0-9]\+/|\\1$1/|" /etc/apt/sources.list
+apt-get update
+
diff --git a/docker/debian-dev/bootstrap/apt-source/replace-http.bash b/docker/debian-dev/bootstrap/apt-source/replace-http.bash
new file mode 100755
index 0000000..b5f6cca
--- /dev/null
+++ b/docker/debian-dev/bootstrap/apt-source/replace-http.bash
@@ -0,0 +1,10 @@
+#! /usr/bin/env bash
+
+set -e
+
+apt-get update
+apt-get install -y apt-transport-https ca-certificates
+
+sed -i.bak 's/https?/https/' /etc/apt/sources.list
+apt-get update
+
diff --git a/docker/debian-dev/bootstrap/apt-source/setup.bash b/docker/debian-dev/bootstrap/apt-source/setup.bash
new file mode 100755
index 0000000..9f74cb6
--- /dev/null
+++ b/docker/debian-dev/bootstrap/apt-source/setup.bash
@@ -0,0 +1,12 @@
+#! /usr/bin/env bash
+
+set -e
+
+dir=$(dirname $0)
+
+if [[ -n $IN_CHINA ]]; then
+ "$dir/replace-domain.bash" $(cat "$dir/china-source.txt")
+fi
+
+"$dir/replace-http.bash"
+
diff --git a/docker/debian-dev/bootstrap/bash-profile/cp-no-git.bash b/docker/debian-dev/bootstrap/bash-profile/cp-no-git.bash
deleted file mode 100644
index bb4d346..0000000
--- a/docker/debian-dev/bootstrap/bash-profile/cp-no-git.bash
+++ /dev/null
@@ -1,2 +0,0 @@
-alias cp-no-git="rsync -a --exclude='.git'"
-
diff --git a/docker/debian-dev/bootstrap/bash-profile/dev.bash b/docker/debian-dev/bootstrap/bash-profile/dev.bash
index 291eadf..93019ed 100644
--- a/docker/debian-dev/bootstrap/bash-profile/dev.bash
+++ b/docker/debian-dev/bootstrap/bash-profile/dev.bash
@@ -1,6 +1,11 @@
-alias apt-get-build-dep-arm64="apt-get build-dep -aarm64 --arch-only"
+alias cp-no-git="rsync -a --exclude='**/.git'"
+
+alias apt-get-build-dep-arm64="apt-get build-dep -a arm64 --arch-only"
alias apt-get-build-dep-indep="apt-get build-dep --indep-only"
-alias dpkg-buildpackage-arm64="CONFIG_SITE=/etc/dpkg-cross/cross-config.arm64 DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -aarm64 -Pcross,nocheck"
-alias dpkg-buildpackage-arm64-build="dpkg-buildpackage-arm64 -T binary-arch"
-alias dpkg-buildpackage-indep-build="dpkg-buildpackage -T binary-indep"
+alias dpkg-buildpackage-build="dpkg-buildpackage -j$(nproc) -nc -b"
alias dpkg-buildpackage-clean="dpkg-buildpackage -T clean"
+alias dpkg-buildpackage-arm64="CONFIG_SITE=/etc/dpkg-cross/cross-config.arm64 DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -a arm64 -P cross,nocheck"
+alias dpkg-buildpackage-arm64-build="dpkg-buildpackage-arm64 -j$(nproc) -nc -T binary-arch"
+alias dpkg-buildpackage-arm64-clean="dpkg-buildpackage-arm64 -T clean"
+alias dpkg-buildpackage-indep-build="dpkg-buildpackage -j$(nproc) -nc -T binary-indep"
+
diff --git a/docker/debian-dev/bootstrap/replace-mirrors.bash b/docker/debian-dev/bootstrap/replace-mirrors.bash
deleted file mode 100755
index 8380bda..0000000
--- a/docker/debian-dev/bootstrap/replace-mirrors.bash
+++ /dev/null
@@ -1,15 +0,0 @@
-#! /usr/bin/env bash
-
-set -e
-
-cp /etc/apt/sources.list /etc/apt/sources.list.bak
-
-cp /bootstrap/source-http.txt /etc/apt/sources.list
-apt-get update
-apt-get install -y apt-transport-https ca-certificates
-
-cp /bootstrap/source-https.txt /etc/apt/sources.list
-apt-get update
-
-cp /bootstrap/source-link.txt /etc/crupest-apt-source
-
diff --git a/docker/debian-dev/bootstrap/setup-base.bash b/docker/debian-dev/bootstrap/setup-base.bash
index 15328ab..5b63fbe 100755
--- a/docker/debian-dev/bootstrap/setup-base.bash
+++ b/docker/debian-dev/bootstrap/setup-base.bash
@@ -5,5 +5,4 @@ set -e
apt-get install -y vim less man curl bash-completion rsync
cat /bootstrap/bash-profile/bash-completion.bash >> /root/.bash_profile
-cat /bootstrap/bash-profile/cp-no-git.bash >> /root/.bash_profile
diff --git a/docker/debian-dev/bootstrap/setup-dev-tools.bash b/docker/debian-dev/bootstrap/setup-dev-tools.bash
index ee1be07..34bae8c 100755
--- a/docker/debian-dev/bootstrap/setup-dev-tools.bash
+++ b/docker/debian-dev/bootstrap/setup-dev-tools.bash
@@ -2,7 +2,8 @@
set -e
-apt-get install -y build-essential devscripts debhelper quilt cpio kmod git bc python bison flex rsync libelf-dev libssl-dev libncurses-dev dwarves
+apt-get install -y build-essential git devscripts debhelper quilt \
+ cpio kmod bc python bison flex rsync libelf-dev libssl-dev libncurses-dev dwarves
cat /bootstrap/bash-profile/dev.bash >> /root/.bash_profile
diff --git a/docker/debian-dev/bootstrap/setup-sbuild.bash b/docker/debian-dev/bootstrap/setup-sbuild.bash
index b67fb38..f9f1933 100755
--- a/docker/debian-dev/bootstrap/setup-sbuild.bash
+++ b/docker/debian-dev/bootstrap/setup-sbuild.bash
@@ -2,10 +2,6 @@
set -e
-if [[ -f /etc/crupest-apt-source ]]; then
- CRUPEST_DEB_MIRROR=$(cat /etc/crupest-apt-source)
-fi
-
if [[ -z "${SBUILD_ARCH}" ]]; then
SBUILD_ARCH="amd64"
fi
@@ -14,5 +10,5 @@ apt-get install -y sbuild schroot debootstrap
cp /bootstrap/sbuildrc /root/.sbuildrc
-sbuild-createchroot --arch=${SBUILD_ARCH} bullseye /srv/chroot/bullseye-${SBUILD_ARCH}-sbuild ${CRUPEST_DEB_MIRROR}
+sbuild-createchroot --arch=${SBUILD_ARCH} bullseye /srv/chroot/bullseye-${SBUILD_ARCH}-sbuild "https://$(/bootstrap/apt-source/get-domain.bash)/debian"
diff --git a/docker/debian-dev/bootstrap/source-http.txt b/docker/debian-dev/bootstrap/source-http.txt
deleted file mode 100644
index 0814020..0000000
--- a/docker/debian-dev/bootstrap/source-http.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-deb http://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
-deb-src http://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
-
-deb http://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
-deb-src http://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
-
-deb http://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
-deb-src http://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
-
-deb http://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib non-free
-deb-src http://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib non-free
diff --git a/docker/debian-dev/bootstrap/source-https.txt b/docker/debian-dev/bootstrap/source-https.txt
deleted file mode 100644
index 8a1346f..0000000
--- a/docker/debian-dev/bootstrap/source-https.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-deb https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
-deb-src https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
-
-deb https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
-deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
-
-deb https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
-deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
-
-deb https://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib non-free
-deb-src https://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib non-free
diff --git a/docker/debian-dev/bootstrap/source-link.txt b/docker/debian-dev/bootstrap/source-link.txt
deleted file mode 100644
index 78ce79c..0000000
--- a/docker/debian-dev/bootstrap/source-link.txt
+++ /dev/null
@@ -1 +0,0 @@
-https://mirrors.ustc.edu.cn/debian