Skip to content

Commit

Permalink
Updated scripts and tmpl
Browse files Browse the repository at this point in the history
  • Loading branch information
ulises-jeremias committed Dec 11, 2023
1 parent b195d3e commit 1940169
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 50 deletions.
37 changes: 0 additions & 37 deletions dots

This file was deleted.

13 changes: 0 additions & 13 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ ROOT="$(realpath "$(dirname "$0")")"
PKGNAME=${PKGNAME:-"dots"}

rm -rf "${PKGDIR}/opt/${PKGNAME}" \
"${PKGDIR}/usr/bin/dots" \
"${PKGDIR}/usr/share/licenses/${PKGNAME}/" \
"${PKGDIR}/usr/share/doc/${PKGNAME}/"

Expand All @@ -14,15 +13,3 @@ cp -Rf "${ROOT}"/lib "${PKGDIR}/opt/${PKGNAME}"

install -Dm644 "${ROOT}"/LICENSE -t "${PKGDIR}/usr/share/licenses/${PKGNAME}/"
install -Dm644 "${ROOT}"/README.md -t "${PKGDIR}/usr/share/doc/${PKGNAME}/"
install -Dm755 "${ROOT}"/dots -t "${PKGDIR}/opt/${PKGNAME}/"

mkdir -p "${PKGDIR}"/usr/bin

# Create dots binary at ${PKGDIR}/usr/bin/${PKGNAME} to wrap the file at ${PKGDIR}/opt/${PKGNAME}/dots
cat > "${PKGDIR}"/usr/bin/"${PKGNAME}" <<EOF
#!/usr/bin/env sh
${PKGDIR}/opt/${PKGNAME}/dots "\$@"
EOF

chmod +x "${PKGDIR}/usr/bin/${PKGNAME}"
30 changes: 30 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# -e: exit on error
# -u: exit on unset variables
set -eu

if ! chezmoi="$(command -v chezmoi)"; then
bin_dir="${HOME}/.local/bin"
chezmoi="${bin_dir}/chezmoi"
echo "Installing chezmoi to '${chezmoi}'" >&2
if command -v curl >/dev/null; then
chezmoi_install_script="$(curl -fsSL get.chezmoi.io)"
elif command -v wget >/dev/null; then
chezmoi_install_script="$(wget -qO- get.chezmoi.io)"
else
echo "To install chezmoi, you must have curl or wget installed." >&2
exit 1
fi
sh -c "${chezmoi_install_script}" -- -b "${bin_dir}"
unset chezmoi_install_script bin_dir
fi

# POSIX way to get script's dir: https://stackoverflow.com/a/29834779/12156188
script_dir="$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)"

set -- init --apply --source="${script_dir}"

echo "Running 'chezmoi $*'" >&2
# exec: replace current process with chezmoi
exec "$chezmoi" "$@"

0 comments on commit 1940169

Please sign in to comment.