From ba0df1252260d8bc47c987ce0af3883b953588ea Mon Sep 17 00:00:00 2001 From: semantic-release Date: Thu, 29 Feb 2024 00:31:16 +0000 Subject: [PATCH 1/9] chore(release): :rocket: 0.37.3 [skip ci] Automatically generated by python-semantic-release --- CHANGELOG.md | 6 ++++++ chezmoi/.chezmoidata.yaml | 2 +- pyproject.toml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b17ebd..ab83128 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ +## v0.37.3 (2024-02-29) + +### Fix + +* **chezmoi:** Update version retrieval in .chezmoidata.yaml and executable_install-go.tmpl ([`9bd3f86`](https://github.com/entelecheia/dotfiles/commit/9bd3f86e113e159f337c9e04552ec2de16b516e2)) + ## v0.37.2 (2024-02-28) ### Fix diff --git a/chezmoi/.chezmoidata.yaml b/chezmoi/.chezmoidata.yaml index 775a08b..1ec9444 100644 --- a/chezmoi/.chezmoidata.yaml +++ b/chezmoi/.chezmoidata.yaml @@ -1,4 +1,4 @@ -DOTFILES_VERSION: 0.37.2 +DOTFILES_VERSION: 0.37.3 packages: - name: 1password-cli apt: true diff --git a/pyproject.toml b/pyproject.toml index feb8ba1..d6cdbf2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dotfiles" -version = "0.37.2" +version = "0.37.3" description = "Easily manage and synchronize your dotfiles across multiple environments with the Dotfiles project, streamlining your development setup and CI/CD pipeline." authors = ["Young Joon Lee "] license = "MIT" From fbafa10c252c6be6a0ed9e186e4bfdf1021b1ae7 Mon Sep 17 00:00:00 2001 From: Young Joon Lee Date: Thu, 29 Feb 2024 09:37:37 +0900 Subject: [PATCH 2/9] Release (#111) From 40ef134c0885e19085c5e7afa2bd8a588c369037 Mon Sep 17 00:00:00 2001 From: Young Joon Lee Date: Sat, 16 Mar 2024 14:36:12 +0900 Subject: [PATCH 3/9] refactor(chezmoi): simplify package installation scripts --- chezmoi/.chezmoitemplates/install-apt-prerequisites | 6 +++--- .../dot_local/bin/executable_dotfiles-install-apt-pkgs.tmpl | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/chezmoi/.chezmoitemplates/install-apt-prerequisites b/chezmoi/.chezmoitemplates/install-apt-prerequisites index bacefd1..4f431b2 100644 --- a/chezmoi/.chezmoitemplates/install-apt-prerequisites +++ b/chezmoi/.chezmoitemplates/install-apt-prerequisites @@ -13,8 +13,8 @@ else echo "${output}" exit 1 fi -c sudo DEBIAN_FRONTEND=noninteractive apt-get install --yes -qq -o=Dpkg::Use-Pty=0 --no-install-recommends ca-certificates -c sudo DEBIAN_FRONTEND=noninteractive apt-get install --yes -qq -o=Dpkg::Use-Pty=0 --no-install-recommends curl wget gnupg \ +c sudo apt-get install --yes -qq -o=Dpkg::Use-Pty=0 --no-install-recommends ca-certificates +c sudo apt-get install --yes -qq -o=Dpkg::Use-Pty=0 --no-install-recommends curl wget gnupg \ software-properties-common zsh locales locales-all jq gettext autoconf apt-transport-https zip bzip2 unzip # Add APT repositories for newer versions of Git. @@ -24,7 +24,7 @@ c sudo DEBIAN_FRONTEND=noninteractive apt-get install --yes -qq -o=Dpkg::Use-Pty c sudo rm -f etc/apt/sources.list.d/git-core-*.list* c sudo add-apt-repository ppa:git-core/ppa --yes c sudo apt-get update --yes -c sudo DEBIAN_FRONTEND=noninteractive apt-get install --yes -qq -o=Dpkg::Use-Pty=0 --no-install-recommends git +c sudo apt-get install --yes -qq -o=Dpkg::Use-Pty=0 --no-install-recommends git # Set up locales # check if locale is already set up by running locale | grep LC_ALL | grep en_US.UTF-8 diff --git a/chezmoi/dot_local/bin/executable_dotfiles-install-apt-pkgs.tmpl b/chezmoi/dot_local/bin/executable_dotfiles-install-apt-pkgs.tmpl index 98c1c6c..04a4d85 100644 --- a/chezmoi/dot_local/bin/executable_dotfiles-install-apt-pkgs.tmpl +++ b/chezmoi/dot_local/bin/executable_dotfiles-install-apt-pkgs.tmpl @@ -142,9 +142,9 @@ done if [[ ${#missing_packages[@]} -gt 0 ]] || [[ ${#upgrade_packages[@]} -gt 0 ]]; then # This script also gets called when running rootmoi if [ "$USER" = "root" ]; then - apt_command=(DEBIAN_FRONTEND=noninteractive apt-get) + apt_command=(apt-get) else - apt_command=(sudo DEBIAN_FRONTEND=noninteractive apt-get) + apt_command=(sudo apt-get) fi c "${apt_command[@]}" update --yes -qq -o=Dpkg::Use-Pty=0 From 133ca3f7ed9c92fb08c8ba535113a729519e3d7a Mon Sep 17 00:00:00 2001 From: Young Joon Lee Date: Sat, 16 Mar 2024 15:04:25 +0900 Subject: [PATCH 4/9] refactor(chezmoi): update Python version prompt and output message --- chezmoi/.chezmoi.yaml.tmpl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/chezmoi/.chezmoi.yaml.tmpl b/chezmoi/.chezmoi.yaml.tmpl index 0f8b239..0fa72be 100644 --- a/chezmoi/.chezmoi.yaml.tmpl +++ b/chezmoi/.chezmoi.yaml.tmpl @@ -223,6 +223,11 @@ # {{- $use_code = .code.enabled -}} # {{- end -}} +# {{- $python_version := or (env "DOTFILES_PYTHON_VERSION") "3.10" -}} +# {{- if and (hasKey . "python") (hasKey .python "version") .python.version -}} +# {{- $python_version = .python.version -}} +# {{- end -}} + # {{- $use_python_tools := true -}} # {{- if eq (env "DOTFILES_USE_PYTHON_TOOLS") "false" "False" "FALSE" "0" -}} # {{- $use_python_tools = false -}} @@ -979,6 +984,18 @@ # {{- writeToStdout "❎ visual studio code disabled\n" -}} # {{- end -}} +# {{- if $interactive -}} +# {{- $question := "❔ What version of Python do you want to use" -}} +# {{- $answer := "" -}} +# {{- if $python_version -}} +# {{- $answer = promptString $question $python_version -}} +# {{- else -}} +# {{- $answer = promptString $question -}} +# {{- end -}} +# {{- $python_version = $answer -}} +# {{- end -}} +# {{- writeToStdout (printf "✅ Python version set as '%s'\n" $python_version) -}} + # {{- if $use_python_tools -}} # {{- writeToStdout "✅ python tools enabled\n" -}} # {{- else -}} @@ -1216,6 +1233,7 @@ data: install_packages: user: {{ $pkgs_user }} python: + version: {{ $python_version | quote }} tools_enabled: {{ $use_python_tools }} workon_home: {{ $python_workon_home | quote }} ruby: From 00c1128f2dbc2578754ba60bde8634d27c538fbe Mon Sep 17 00:00:00 2001 From: Young Joon Lee Date: Sat, 16 Mar 2024 15:04:44 +0900 Subject: [PATCH 5/9] feat(prerequisites): add python installation command --- .../run_once_before_00-install-prerequisites.sh.tmpl | 1 + 1 file changed, 1 insertion(+) diff --git a/chezmoi/.chezmoiscripts/run_once_before_00-install-prerequisites.sh.tmpl b/chezmoi/.chezmoiscripts/run_once_before_00-install-prerequisites.sh.tmpl index 0781cba..e2b81d9 100644 --- a/chezmoi/.chezmoiscripts/run_once_before_00-install-prerequisites.sh.tmpl +++ b/chezmoi/.chezmoiscripts/run_once_before_00-install-prerequisites.sh.tmpl @@ -2,4 +2,5 @@ # {{- if and (eq .chezmoi.os "linux") (.system.apply_rootmoi) (.system.is_sudoer) }} # {{- template "scripts-library" }} # {{- template "install-apt-prerequisites" }} +c sudo apt-get install --yes -qq -o=Dpkg::Use-Pty=0 --no-install-recommends "python{{ .python.version }}" # {{- end }} From 0a1294d72f8bdf5c1543f26105cd6ac04421af4a Mon Sep 17 00:00:00 2001 From: Young Joon Lee Date: Sat, 16 Mar 2024 15:04:50 +0900 Subject: [PATCH 6/9] feat(chezmoi): add Deadsnakes PPA Python versions --- chezmoi/.chezmoitemplates/install-apt-prerequisites | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chezmoi/.chezmoitemplates/install-apt-prerequisites b/chezmoi/.chezmoitemplates/install-apt-prerequisites index 4f431b2..a58576e 100644 --- a/chezmoi/.chezmoitemplates/install-apt-prerequisites +++ b/chezmoi/.chezmoitemplates/install-apt-prerequisites @@ -26,6 +26,10 @@ c sudo add-apt-repository ppa:git-core/ppa --yes c sudo apt-get update --yes c sudo apt-get install --yes -qq -o=Dpkg::Use-Pty=0 --no-install-recommends git +# Add the Deadsnakes PPA for older or newer Python versions. +c sudo add-apt-repository ppa:deadsnakes/ppa --yes +c sudo apt-get update --yes + # Set up locales # check if locale is already set up by running locale | grep LC_ALL | grep en_US.UTF-8 if ! locale | grep LC_ALL | grep -q en_US.UTF-8; then From b0d97caf7c4924ff501f9a5e8dc4bbe2e0f50282 Mon Sep 17 00:00:00 2001 From: Young Joon Lee Date: Sat, 16 Mar 2024 15:05:02 +0900 Subject: [PATCH 7/9] feat(configuration): add Python version to dotfiles --- chezmoi/dot_config/shrc/00-dotfiles-export.tmpl | 1 + 1 file changed, 1 insertion(+) diff --git a/chezmoi/dot_config/shrc/00-dotfiles-export.tmpl b/chezmoi/dot_config/shrc/00-dotfiles-export.tmpl index acfc106..bf081c5 100644 --- a/chezmoi/dot_config/shrc/00-dotfiles-export.tmpl +++ b/chezmoi/dot_config/shrc/00-dotfiles-export.tmpl @@ -72,6 +72,7 @@ export WORKSPACE_REFERENCE_DIR="{{ .workspace.reference_dir }}" export WORKSPACE_CONTAINER_DIR="{{ .workspace.container_dir }}" export WORKSPACE_MODEL_DIR="{{ .workspace.model_dir }}" export WORKSPACE_DATASET_DIR="{{ .workspace.dataset_dir }}" +export DOTFILES_PYTHON_VERSION="{{ .python.version }}" export DOTFILES_USE_CLOUDFLARED="{{ .cloudflared.enabled }}" export CLOUDFLARED_CONFIG="{{ .cloudflared.config_file }}" From 1b4799528c55b863c4945c7d25a645ee1510552e Mon Sep 17 00:00:00 2001 From: Young Joon Lee Date: Sat, 16 Mar 2024 15:05:07 +0900 Subject: [PATCH 8/9] feat(chezmoi): add script to install Python and manage Python versions. --- .../bin/executable_install-python.tmpl | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 chezmoi/dot_local/bin/executable_install-python.tmpl diff --git a/chezmoi/dot_local/bin/executable_install-python.tmpl b/chezmoi/dot_local/bin/executable_install-python.tmpl new file mode 100644 index 0000000..b6d82df --- /dev/null +++ b/chezmoi/dot_local/bin/executable_install-python.tmpl @@ -0,0 +1,54 @@ +#!/bin/bash + +# Function to install Python dependencies +install_dependencies() { + sudo apt update + sudo apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev \ + libssl-dev libreadline-dev libffi-dev wget +} + +# Function to download and install Python +install_python() { + local python_version=$1 + local python_url="https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tgz" + + wget "$python_url" + tar -xf "Python-${python_version}.tgz" + cd "Python-${python_version}" || exit + + ./configure --enable-optimizations + make -j "$(nproc)" + sudo make altinstall + + cd .. + rm -rf "Python-${python_version}" "Python-${python_version}.tgz" +} + +# Function to update alternatives for Python +update_alternatives() { + local python_version=$1 + local python_priority=$2 + + sudo update-alternatives --install /usr/bin/python python "/usr/local/bin/python${python_version%.*}" "$python_priority" + sudo update-alternatives --install /usr/bin/pip pip "/usr/local/bin/pip${python_version%.*}" "$python_priority" +} + +# Main script +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root or with sudo." + exit 1 +fi + +read -rp "Enter the Python version to install (e.g., 3.9.7): " python_version +read -rp "Enter the priority for the Python version (e.g., 1): " python_priority + +echo "Installing Python dependencies..." +install_dependencies + +echo "Installing Python $python_version..." +install_python "$python_version" + +echo "Updating alternatives for Python..." +update_alternatives "$python_version" "$python_priority" + +echo "Python $python_version installation completed." From 924b17db0b7b8a9c1a4dd8950433a9c5d0626eba Mon Sep 17 00:00:00 2001 From: Young Joon Lee Date: Sat, 16 Mar 2024 15:33:08 +0900 Subject: [PATCH 9/9] feat(shell-scripts): add script to create user with password and data directory --- .../dot_local/bin/executable_create-user.tmpl | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 chezmoi/dot_local/bin/executable_create-user.tmpl diff --git a/chezmoi/dot_local/bin/executable_create-user.tmpl b/chezmoi/dot_local/bin/executable_create-user.tmpl new file mode 100644 index 0000000..fcbd378 --- /dev/null +++ b/chezmoi/dot_local/bin/executable_create-user.tmpl @@ -0,0 +1,57 @@ +#!/bin/bash + +# Function to create user and set password +create_user() { + local username=$1 + local password=$2 + + sudo useradd -m -s /bin/bash "$username" + echo "$username:$password" | sudo chpasswd +} + +# Function to add user to groups +add_user_to_groups() { + local username=$1 + shift + local groups=("$@") + + for group in "${groups[@]}"; do + sudo usermod -aG "$group" "$username" + done +} + +# Function to create data directory and symlink +create_data_directory() { + local username=$1 + local data_root=$2 + + local data_directory="$data_root/$username" + sudo mkdir -p "$data_directory" + sudo chown "$username:$username" "$data_directory" + + local home_directory="/home/$username" + ln -s "$data_directory" "$home_directory/data" +} + +# Main script +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root or with sudo." + exit 1 +fi + +read -rp "Enter the username: " username +read -s -rp "Enter the password: " password +echo +read -rp "Enter the groups (separated by space): " -a groups +read -rp "Enter the root directory for data (e.g., /raid/data): " data_root + +echo "Creating user $username..." +create_user "$username" "$password" + +echo "Adding user $username to groups: ${groups[*]}" +add_user_to_groups "$username" "${groups[@]}" + +echo "Creating data directory and symlink for user $username..." +create_data_directory "$username" "$data_root" + +echo "User $username created successfully."