diff options
Diffstat (limited to 'store/debian-dev')
-rw-r--r-- | store/debian-dev/Dockerfile | 22 | ||||
-rwxr-xr-x | store/debian-dev/setup/apt.bash | 33 | ||||
-rw-r--r-- | store/debian-dev/setup/bashrc | 3 | ||||
-rwxr-xr-x | store/debian-dev/setup/cmake.bash | 9 | ||||
-rwxr-xr-x | store/debian-dev/setup/code-server.bash | 17 | ||||
-rwxr-xr-x | store/debian-dev/setup/for-container.bash | 14 | ||||
-rwxr-xr-x | store/debian-dev/setup/llvm.bash | 11 | ||||
-rwxr-xr-x | store/debian-dev/setup/package.bash | 10 | ||||
-rw-r--r-- | store/debian-dev/setup/quiltrc-dpkg | 13 | ||||
-rwxr-xr-x | store/debian-dev/setup/user.bash | 11 |
10 files changed, 143 insertions, 0 deletions
diff --git a/store/debian-dev/Dockerfile b/store/debian-dev/Dockerfile new file mode 100644 index 0000000..d5e25ba --- /dev/null +++ b/store/debian-dev/Dockerfile @@ -0,0 +1,22 @@ +ARG VERSION=latest +FROM debian:${VERSION} + +ARG USER= +ARG CHINA= + +ENV CRUPEST_DEBIAN_DEV_USER=${USER} +ENV CRUPEST_DEBIAN_DEV_CHINA=${CHINA} + +ADD setup /setup +RUN export DEBIAN_FRONTEND=noninteractive; \ + /setup/apt.bash && /setup/package.bash && \ + /setup/for-container.bash && \ + rm -rf /var/lib/apt/lists/* + + +ENV LANG=en_US.utf8 +USER ${USER} +WORKDIR /home/${USER} +RUN env DEBIAN_FRONTEND=noninteractive /setup/user.bash + +VOLUME [ "/home/${USER}" ] diff --git a/store/debian-dev/setup/apt.bash b/store/debian-dev/setup/apt.bash new file mode 100755 index 0000000..e841351 --- /dev/null +++ b/store/debian-dev/setup/apt.bash @@ -0,0 +1,33 @@ +#! /usr/bin/env bash + +set -e -o pipefail + +china_mirror="mirrors.ustc.edu.cn" +try_files=("/etc/apt/sources.list" "/etc/apt/sources.list.d/debian.sources") +files=() + +for try_file in "${try_files[@]}"; do + if [[ -f "$try_file" ]]; then + files+=("$try_file") + fi +done + +for file in "${files[@]}"; do + echo "copy $file to $file.bak" + cp "$file" "$file.bak" +done + +if [[ -n "$CRUPEST_DEBIAN_DEV_CHINA" ]]; then + echo "use China mirrors" + for file in "${files[@]}"; do + sed -i "s|deb.debian.org|${china_mirror}|g" "$file" + done +fi + +echo "use https" +apt-get update +apt-get install -y apt-transport-https ca-certificates + +for file in "${files[@]}"; do + sed -i 's|http://|https://|g' "$file" +done diff --git a/store/debian-dev/setup/bashrc b/store/debian-dev/setup/bashrc new file mode 100644 index 0000000..00c9d11 --- /dev/null +++ b/store/debian-dev/setup/bashrc @@ -0,0 +1,3 @@ +alias dquilt='quilt "--quiltrc=${HOME}/.quiltrc-dpkg"' +. /usr/share/bash-completion/completions/quilt +complete -F _quilt_completion $_quilt_complete_opt dquilt diff --git a/store/debian-dev/setup/cmake.bash b/store/debian-dev/setup/cmake.bash new file mode 100755 index 0000000..dd7307e --- /dev/null +++ b/store/debian-dev/setup/cmake.bash @@ -0,0 +1,9 @@ +#! /usr/bin/env bash + +set -e -o pipefail + +CMAKE_VERSION=$(curl -s https://api.github.com/repos/Kitware/CMake/releases/latest | \ + grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') + +curl -fsSL "https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-linux-x86_64.sh" | \ + sh -s -- --skip-license --prefix=/usr diff --git a/store/debian-dev/setup/code-server.bash b/store/debian-dev/setup/code-server.bash new file mode 100755 index 0000000..1151dc2 --- /dev/null +++ b/store/debian-dev/setup/code-server.bash @@ -0,0 +1,17 @@ +#! /usr/bin/env bash + +set -e -o pipefail + +if [[ $# != 1 ]]; then + echo "Require exactly one argument, the password of the code server." >&2 + exit 1 +fi + +curl -fsSL https://code-server.dev/install.sh | sh + +apt update && apt install argon2 +mkdir -p "${HOME}/.config/code-server" +echo -e "auth: password\nhashed-password: " >> "${HOME}/.config/code-server/config.yaml" +echo -n "$1" | \ + argon2 "$(shuf -i 10000000-99999999 -n 1 --random-source /dev/urandom)" -e \ + >> "${HOME}/.config/code-server/config.yaml" diff --git a/store/debian-dev/setup/for-container.bash b/store/debian-dev/setup/for-container.bash new file mode 100755 index 0000000..0aa47b0 --- /dev/null +++ b/store/debian-dev/setup/for-container.bash @@ -0,0 +1,14 @@ +#! /usr/bin/env bash + +set -e -o pipefail + +echo "set up locale" +localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 + +echo "set up sudo" +sed -i.bak 's|%sudo[[:space:]]\+ALL=(ALL:ALL)[[:space:]]\+ALL|%sudo ALL=(ALL:ALL) NOPASSWD: ALL|' /etc/sudoers + +if ! id "username" &>/dev/null; then + echo "create user $CRUPEST_DEBIAN_DEV_USER" + useradd -m -G sudo -s /usr/bin/bash "$CRUPEST_DEBIAN_DEV_USER" +fi diff --git a/store/debian-dev/setup/llvm.bash b/store/debian-dev/setup/llvm.bash new file mode 100755 index 0000000..ca6d4bf --- /dev/null +++ b/store/debian-dev/setup/llvm.bash @@ -0,0 +1,11 @@ +#! /usr/bin/env bash + +set -e -o pipefail + +if [[ -n "$CRUPEST_DEBIAN_DEV_CHINA" ]]; then + base_url=https://mirrors.tuna.tsinghua.edu.cn/llvm-apt +else + base_url=https://apt.llvm.org +fi + +curl -fsSL "$base_url/llvm.sh" | sh -s -- all -m "$base_url" diff --git a/store/debian-dev/setup/package.bash b/store/debian-dev/setup/package.bash new file mode 100755 index 0000000..5ad7b7a --- /dev/null +++ b/store/debian-dev/setup/package.bash @@ -0,0 +1,10 @@ +#! /usr/bin/env bash + +set -e -o pipefail + +echo "install packages" +apt-get update +apt-get install -y \ + locales lsb-release software-properties-common \ + sudo procps bash-completion man less gnupg curl wget \ + vim build-essential git devscripts debhelper quilt diff --git a/store/debian-dev/setup/quiltrc-dpkg b/store/debian-dev/setup/quiltrc-dpkg new file mode 100644 index 0000000..e8fc3c5 --- /dev/null +++ b/store/debian-dev/setup/quiltrc-dpkg @@ -0,0 +1,13 @@ +d=. +while [ ! -d $d/debian -a `readlink -e $d` != / ]; + do d=$d/..; done +if [ -d $d/debian ] && [ -z $QUILT_PATCHES ]; then + # if in Debian packaging tree with unset $QUILT_PATCHES + QUILT_PATCHES="debian/patches" + QUILT_PATCH_OPTS="--reject-format=unified" + QUILT_DIFF_ARGS="-p ab --no-timestamps --no-index --color=auto" + QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index" + QUILT_COLORS="diff_hdr=1;32:diff_add=1;34:diff_rem=1;31:diff_hunk=1;33:" + QUILT_COLORS="${QUILT_COLORS}diff_ctx=35:diff_cctx=33" + if ! [ -d $d/debian/patches ]; then mkdir $d/debian/patches; fi +fi diff --git a/store/debian-dev/setup/user.bash b/store/debian-dev/setup/user.bash new file mode 100755 index 0000000..4e13804 --- /dev/null +++ b/store/debian-dev/setup/user.bash @@ -0,0 +1,11 @@ +#! /usr/bin/env bash + +set -e -o pipefail + +base_dir="$(dirname "$0")" +dot_files=("bashrc" "quiltrc-dpkg") + +for file in "${dot_files[@]}"; do + echo "copy $base_dir/$file $HOME/.$file" + cp "$base_dir/$file" "$HOME/.$file" +done |