This commit is contained in:
parent
5662040673
commit
e9e9b7fc51
@ -1,11 +0,0 @@
|
|||||||
Types: deb
|
|
||||||
URIs: http://nexus.krd.sh/repository/proxy_apt_debian
|
|
||||||
Suites: bookworm bookworm-updates bookworm-proposed-updates bookworm-backports
|
|
||||||
Components: main
|
|
||||||
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
|
|
||||||
|
|
||||||
Types: deb
|
|
||||||
URIs: http://nexus.krd.sh/repository/proxy_apt_debian-security
|
|
||||||
Suites: bookworm-security
|
|
||||||
Components: main
|
|
||||||
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
|
|
@ -4,7 +4,6 @@
|
|||||||
!/.cache/zsh/compzwc/.keep
|
!/.cache/zsh/compzwc/.keep
|
||||||
!/.cache/zsh/ssh/.keep
|
!/.cache/zsh/ssh/.keep
|
||||||
!/.config/dotfiles/bin/.keep
|
!/.config/dotfiles/bin/.keep
|
||||||
!/.config/dotfiles/debian.sources
|
|
||||||
!/.config/dotfiles/gen-gitignore.sh
|
!/.config/dotfiles/gen-gitignore.sh
|
||||||
!/.config/dotfiles/gitattributes
|
!/.config/dotfiles/gitattributes
|
||||||
!/.config/dotfiles/gitignore
|
!/.config/dotfiles/gitignore
|
||||||
@ -18,7 +17,6 @@
|
|||||||
!/.config/zsh.dots/.zshenv
|
!/.config/zsh.dots/.zshenv
|
||||||
!/.config/zsh/_.zsh
|
!/.config/zsh/_.zsh
|
||||||
!/.config/zsh/_wip/enclave.zsh.wip
|
!/.config/zsh/_wip/enclave.zsh.wip
|
||||||
!/.config/zsh/_wip/starship.zsh.sample
|
|
||||||
!/.config/zsh/alias.zsh
|
!/.config/zsh/alias.zsh
|
||||||
!/.config/zsh/alias/containers.zsh
|
!/.config/zsh/alias/containers.zsh
|
||||||
!/.config/zsh/alias/diff.zsh
|
!/.config/zsh/alias/diff.zsh
|
||||||
|
@ -1,18 +1,14 @@
|
|||||||
steps:
|
steps:
|
||||||
- name: check
|
- name: check
|
||||||
image: quay.krd.sh/debian:bookworm-slim
|
image: docker.io/debian:bookworm-slim
|
||||||
environment:
|
environment:
|
||||||
DEBCONF_NONINTERACTIVE_SEEN: "true"
|
DEBCONF_NONINTERACTIVE_SEEN: 'true'
|
||||||
DEBIAN_FRONTEND: noninteractive
|
DEBIAN_FRONTEND: 'noninteractive'
|
||||||
DEBIAN_PRIORITY: critical
|
DEBIAN_PRIORITY: 'critical'
|
||||||
TERM: linux
|
TERM: 'linux'
|
||||||
MALLOC_ARENA_MAX: "4"
|
MALLOC_ARENA_MAX: '4'
|
||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
: # configure apt
|
|
||||||
find /etc/apt/sources.list.d/ -mindepth 1 -delete
|
|
||||||
: > /etc/apt/sources.list
|
|
||||||
cp .config/dotfiles/debian.sources /etc/apt/sources.list.d/
|
|
||||||
: # install required packages
|
: # install required packages
|
||||||
apt-get -y update
|
apt-get -y update
|
||||||
apt-get -y install file findutils git shellcheck zsh
|
apt-get -y install file findutils git shellcheck zsh
|
||||||
@ -36,7 +32,3 @@ steps:
|
|||||||
: # try shellcheck (except for *.zsh)
|
: # try shellcheck (except for *.zsh)
|
||||||
git ls-files | grep -Fv '.zsh' | sort -uV | xargs -r file -N -i | grep text/x-shellscript | cut -d: -f1 \
|
git ls-files | grep -Fv '.zsh' | sort -uV | xargs -r file -N -i | grep text/x-shellscript | cut -d: -f1 \
|
||||||
| xargs -r -n1 shellcheck
|
| xargs -r -n1 shellcheck
|
||||||
|
|
||||||
## personal tweaks :)
|
|
||||||
labels:
|
|
||||||
network: airgap
|
|
||||||
|
@ -1,205 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
## inspired by 'https://starship.rs/install.sh' as of 2021-03-07
|
|
||||||
|
|
||||||
ZSHU[starship_baseurl]='https://github.com/starship/starship/releases'
|
|
||||||
## ZSHU[starship_target] is auto-detected
|
|
||||||
## ZSHU[starship_path] defaults to ZSHU[d_bin] which is in PATH already
|
|
||||||
|
|
||||||
# export STARSHIP_CONFIG="$HOME/.config/starship.toml"
|
|
||||||
# export STARSHIP_CACHE="$HOME/.cache/starship"
|
|
||||||
|
|
||||||
__z_starship_auto_path() {
|
|
||||||
echo "${ZSHU[starship_path]:-${ZSHU[d_bin]}}"
|
|
||||||
}
|
|
||||||
|
|
||||||
__z_starship() {
|
|
||||||
local x=$(__z_starship_auto_path)
|
|
||||||
x="$x/starship"
|
|
||||||
[ -x "$x" ] || x=starship
|
|
||||||
[ -x "$x" ] || return 127
|
|
||||||
"$x" "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
__z_starship_test() { __z_starship -V &>/dev/null ; }
|
|
||||||
|
|
||||||
## NB: supply TARGET environment variable to call
|
|
||||||
__z_starship_url_latest() {
|
|
||||||
printf '%s/latest/download/starship-%s.tar.gz' \
|
|
||||||
"${ZSHU[starship_baseurl]}" "${TARGET}"
|
|
||||||
}
|
|
||||||
|
|
||||||
## NB: supply TARGET environment variable to call
|
|
||||||
## $1 - version (semver like '0.50.0')
|
|
||||||
__z_starship_url_versioned() {
|
|
||||||
printf '%s/download/v%s/starship-%s.tar.gz' \
|
|
||||||
"${ZSHU[starship_baseurl]}" "$1" "${TARGET}"
|
|
||||||
}
|
|
||||||
|
|
||||||
## NB: install starship somewhere in PATH ;)
|
|
||||||
__z_starship_ver_installed() {
|
|
||||||
__z_starship -V 2>/dev/null \
|
|
||||||
| sed -En '/^starship v?(\S.+)$/{s//\1/;p;}'
|
|
||||||
}
|
|
||||||
|
|
||||||
## NB: supply TARGET environment variable to call
|
|
||||||
__z_starship_ver_latest() {
|
|
||||||
local x=$(__z_starship_url_latest)
|
|
||||||
local y=$(__z_curl_location "$x")
|
|
||||||
## hackish strip, e.g.:
|
|
||||||
## from: https://github.com/starship/starship/releases/download/v0.50.0/starship-x86_64-unknown-linux-musl.tar.gz
|
|
||||||
## to: v0.50.0
|
|
||||||
y=${y:h:t}
|
|
||||||
[ "${y:0:1}" = 'v' ] && y=${y:1}
|
|
||||||
echo "$y"
|
|
||||||
}
|
|
||||||
|
|
||||||
__z_starship_detect_arch() {
|
|
||||||
local arch=${ZSHU[mach]}
|
|
||||||
case "${arch}" in
|
|
||||||
x86_64) [ "$(getconf LONG_BIT)" -eq 32 ] && arch=i686 ;;
|
|
||||||
aarch64) [ "$(getconf LONG_BIT)" -eq 32 ] && arch=arm ;;
|
|
||||||
esac
|
|
||||||
echo "${arch}"
|
|
||||||
}
|
|
||||||
|
|
||||||
__z_starship_detect_platform() {
|
|
||||||
local platform=${ZSHU[uname]}
|
|
||||||
case "${ZSHU[uname]}" in
|
|
||||||
msys_nt*) platform=pc-windows-msvc ;;
|
|
||||||
cygwin_nt*) platform=pc-windows-msvc ;;
|
|
||||||
mingw*) platform=pc-windows-msvc ;;
|
|
||||||
linux) platform=unknown-linux-musl ;; ## static builds
|
|
||||||
darwin) platform=apple-darwin ;;
|
|
||||||
freebsd) platform=unknown-freebsd ;;
|
|
||||||
esac
|
|
||||||
echo "${platform}"
|
|
||||||
}
|
|
||||||
|
|
||||||
## $1 - arch
|
|
||||||
## $2 - platform
|
|
||||||
__z_starship_detect_target() {
|
|
||||||
local target="$1-$2"
|
|
||||||
case "${target}" in
|
|
||||||
arm-unknown-linux-musl) target="${target}eabihf" ;;
|
|
||||||
esac
|
|
||||||
echo "${target}"
|
|
||||||
}
|
|
||||||
|
|
||||||
__z_starship_auto_target() {
|
|
||||||
[ -n "${ZSHU[starship_target]}" ] && echo "${ZSHU[starship_target]}" && return
|
|
||||||
local arch=$(__z_starship_detect_arch)
|
|
||||||
local platform=$(__z_starship_detect_platform)
|
|
||||||
local target=$(__z_starship_detect_target "${arch}" "${platform}")
|
|
||||||
echo "${target}"
|
|
||||||
}
|
|
||||||
|
|
||||||
__z_starship_install() {
|
|
||||||
local ver=${1:-latest}
|
|
||||||
local target url resp
|
|
||||||
target=$(__z_starship_auto_target)
|
|
||||||
if [ "${ver}" = 'latest' ] ; then
|
|
||||||
url=$(TARGET=${target} __z_starship_url_latest)
|
|
||||||
resp=$(__z_curl_response "${url}")
|
|
||||||
resp=${resp:-400}
|
|
||||||
[ ${resp} -ge 400 ] && return 1
|
|
||||||
else
|
|
||||||
url=$(TARGET=${target} __z_starship_url_versioned "${ver}")
|
|
||||||
resp=$(__z_curl_response "${url}")
|
|
||||||
resp=${resp:-400}
|
|
||||||
if [ ${resp} -ge 400 ] ; then
|
|
||||||
## last resort: try messing with version ;D
|
|
||||||
if [ "${ver:0:1}" = 'v' ] ; then
|
|
||||||
ver=${ver:1}
|
|
||||||
else
|
|
||||||
ver="v${ver}"
|
|
||||||
fi
|
|
||||||
url=$(TARGET=${target} __z_starship_url_versioned "${ver}")
|
|
||||||
resp=$(__z_curl_response "${url}")
|
|
||||||
resp=${resp:-400}
|
|
||||||
[ ${resp} -ge 400 ] && return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
local t=$(mktemp -d)
|
|
||||||
local f="$t/starship.tar.gz"
|
|
||||||
command curl -sqL "${url}" > "$f"
|
|
||||||
command tar -C "$t" -xf "$f" starship &>/dev/null
|
|
||||||
if [ $? -ne 0 ] ; then
|
|
||||||
## last resort
|
|
||||||
command tar -C "$t" --strip-components=1 --wildcards -xf "$f" '*/starship' &>/dev/null
|
|
||||||
if [ $? -ne 0 ] ; then
|
|
||||||
rm -rf "$t"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
local d=$(__z_starship_auto_path)
|
|
||||||
mv "$t/starship" "$d/"
|
|
||||||
local r=$?
|
|
||||||
if [ $r -eq 0 ] ; then
|
|
||||||
[ "${ver:0:1}" = 'v' ] && ver=${ver:1}
|
|
||||||
echo "starship: installed ${ver} version in $d/" 1>&2
|
|
||||||
fi
|
|
||||||
rm -rf "$t"
|
|
||||||
return $r
|
|
||||||
}
|
|
||||||
|
|
||||||
z-starship-target-available() {
|
|
||||||
local target url resp
|
|
||||||
target=$(__z_starship_auto_target)
|
|
||||||
url=$(TARGET=${target} __z_starship_url_latest)
|
|
||||||
resp=$(__z_curl_response "${url}")
|
|
||||||
resp=${resp:-400}
|
|
||||||
if [ ${resp} -lt 400 ] ; then
|
|
||||||
echo "starship: available for ${target}" 1>&2
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "starship: NOT available for ${target}" 1>&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
z-starship-update-available() {
|
|
||||||
local target=$(__z_starship_auto_target)
|
|
||||||
local installed=$(__z_starship_ver_installed)
|
|
||||||
local latest=$(TARGET=${target} __z_starship_ver_latest)
|
|
||||||
if [ -z "${latest}" ] ; then
|
|
||||||
echo "starship: update is NOT available" 1>&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [ -z "${installed}" ] ; then
|
|
||||||
echo "starship: NOT installed, install it 1st" 1>&2
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
local tailver=$(printf '%s\n' "${installed}" "${latest}" | sort -Vu | tail -n 1)
|
|
||||||
if [ "${installed}" = "${tailver}" ] ; then
|
|
||||||
if [ "${installed}" = "${latest}" ] ; then
|
|
||||||
echo "starship: local version is up to date" 1>&2
|
|
||||||
else
|
|
||||||
echo "starship: local version is newer! o_O" 1>&2
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
echo "starship: update is available (${installed} -> ${latest})" 1>&2
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
z-starship-init() {
|
|
||||||
[ -n "${ZSHU[starship_init]}" ] && return
|
|
||||||
__z_starship_test || return
|
|
||||||
eval "$(__z_starship init zsh)"
|
|
||||||
ZSHU[starship_init]=1
|
|
||||||
}
|
|
||||||
|
|
||||||
z-starship-install() {
|
|
||||||
z-starship-target-available || return
|
|
||||||
__z_starship_install || \
|
|
||||||
echo "starship: unable to install" 1>&2
|
|
||||||
}
|
|
||||||
|
|
||||||
z-starship-update() {
|
|
||||||
z-starship-update-available || return 0
|
|
||||||
__z_starship_install || \
|
|
||||||
echo "starship: unable to update" 1>&2
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user