Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function xbld() {
- local dir="${1:-$HOME/void-packages}"
- if [[ ! -d "$dir/srcpkgs" ]]; then
- echo "Error: $dir does not look like a void-packages tree" >&2
- return 1
- fi
- (
- set -e
- cd "$dir" || exit 1
- git pull --rebase
- # Collect restricted package names cleanly
- local pkgs
- pkgs=$(
- shopt -s extglob nullglob
- cd srcpkgs 2>/dev/null || exit 1
- grep -l '^restricted=yes' **/template 2>/dev/null |
- awk -F/ '{print $1}' |
- sort -u
- )
- if [[ -z "$pkgs" ]]; then
- echo "No restricted packages found." >&2
- exit 0
- fi
- # fzf single select with bat preview
- local selection
- selection=$(
- echo "$pkgs" | fzf \
- --height 60% \
- --layout=reverse \
- --border \
- --prompt="Select restricted package to build+install → " \
- --header="Restricted packages in $(basename "$dir")" \
- --preview 'p={}; bat --color=always --style=numbers --line-range :500 "$PWD/srcpkgs/$p/template" ' \
- --preview-window=right:50%:wrap \
- --header='ctrl-u=check for updates' \
- --bind "ctrl-u:preview( ./xbps-src update-check {} )"
- )
- if [[ -z "$selection" ]]; then
- echo "Nothing selected."
- exit 0
- fi
- echo
- echo "→ Selected: $selection"
- echo " Building and installing..."
- # Optional: clean first if you often want fresh builds
- # ./xbps-src clean-restricted "$selection" # uncomment if desired
- if ./xbps-src pkg "$selection" && command -v xi >/dev/null 2>&1; then
- yes | xi "$selection"
- else
- echo "Build failed or 'xi' command not found." >&2
- return 1
- fi
- )
- return $?
- }
Advertisement