diff options
| author | Yuqian Yang <crupest@outlook.com> | 2025-06-29 15:07:57 +0800 | 
|---|---|---|
| committer | Yuqian Yang <crupest@outlook.com> | 2025-06-29 15:08:47 +0800 | 
| commit | 66a0836ba12ed12c29353ae75134654c6f2013cc (patch) | |
| tree | aeca0ebfca99f50f305f8948f512abf1760f8540 /store/debian-dev/setup | |
| parent | 43d6c1f08a38ae4e8584e3915f0cbdbc3cfd05e9 (diff) | |
| download | crupest-66a0836ba12ed12c29353ae75134654c6f2013cc.tar.gz crupest-66a0836ba12ed12c29353ae75134654c6f2013cc.tar.bz2 crupest-66a0836ba12ed12c29353ae75134654c6f2013cc.zip  | |
debian-dev: refactor all.
Diffstat (limited to 'store/debian-dev/setup')
| -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 | 
9 files changed, 121 insertions, 0 deletions
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  | 
