Skip to content

Commit

Permalink
Handle apt repositories with chezmoi
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs committed Nov 21, 2021
1 parent 7839789 commit 3d40622
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 17 deletions.
11 changes: 11 additions & 0 deletions home/dot_local/bin/executable_chezmoi-root.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

readonly config_dir="${HOME}/.config/chezmoi"

readonly config="${config_dir}/root.config.json"
readonly persistent_state="${config_dir}/root.chezmoistate.boltdb"

exec sudo "{{ .chezmoi.executable }}" \
--config="${config}" \
--persistent-state="${persistent_state}" \
"$@"
18 changes: 3 additions & 15 deletions home/run_always_after_apply_root.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,8 @@

echo "Applying chezmoi to root..."

config_dir="${HOME}/.config/chezmoi"

config="${config_dir}/root.config.json"
persistent_state="${config_dir}/root.chezmoistate.boltdb"
executable="$HOME/.local/bin/chezmoi-root"
args=({{ range (rest .chezmoi.args) }} {{ . | quote }}{{ end }})

echo "Using args:" "${args[@]}"

if [[ -f "${config}" ]]; then
sudo "{{ .chezmoi.executable }}" \
--config="${config}" \
--persistent-state="${persistent_state}" \
"${args[@]}"
else
echo "The file '${config}' does not exist. Did you apply it?"
exit 1
fi
echo "Executing: $executable ${args[@]}"
exec "${executable}" "${args[@]}"
2 changes: 0 additions & 2 deletions home/run_onchange_before_1_setup_apt_packages.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ sudo apt install -y software-properties-common
{{ end -}}
echo "Setting up repositories"
sudo add-apt-repository --no-update -y ppa:git-core/ppa
echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ .chezmoi.osRelease.ubuntuCodename }} stable" | sudo tee /etc/apt/sources.list.d/docker.list
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_{{ .chezmoi.osRelease.versionID }}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -fsSL https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_{{ .chezmoi.osRelease.versionID }}/Release.key | sudo apt-key add -
{{ if eq .chezmoi.osRelease.versionID "18.04" -}}
Expand Down
13 changes: 13 additions & 0 deletions root/.chezmoiexternal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"usr/share/keyrings/docker-archive-keyring.gpg":
type: file
url: "https://download.docker.com/linux/{{ .chezmoi.osRelease.id }}/gpg"
filter:
command: gpg
args: ["--dearmor"]

"usr/share/keyrings/kubic-archive-keyring.gpg":
type: file
url: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_{{ .chezmoi.osRelease.versionID }}/Release.key"
filter:
command: gpg
args: ["--dearmor"]
4 changes: 4 additions & 0 deletions root/.chezmoiremove
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list.save
etc/apt/sources.list.d/git-core-ubuntu-ppa-*.list
etc/apt/sources.list.d/git-core-ubuntu-ppa-*.list.save
1 change: 1 addition & 0 deletions root/etc/apt/sources.list.d/docker.list.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deb [arch={{ .chezmoi.arch }} signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/{{ .chezmoi.osRelease.id }} {{ .chezmoi.osRelease.versionCodename }} stable
2 changes: 2 additions & 0 deletions root/etc/apt/sources.list.d/git-core.list.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deb [s] http://ppa.launchpad.net/git-core/ppa/ubuntu {{ .chezmoi.osRelease.ubuntuCodename }} main
# deb-src http://ppa.launchpad.net/git-core/ppa/ubuntu {{ .chezmoi.osRelease.ubuntuCodename }} main
1 change: 1 addition & 0 deletions root/etc/apt/sources.list.d/kubic.list.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deb [signed-by=/usr/share/keyrings/kubic-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_{{ .chezmoi.osRelease.versionID }}/ /

0 comments on commit 3d40622

Please sign in to comment.