ambevar-dotfiles/.scripts/.pacman-init

32 lines
1.0 KiB
Bash

#!/bin/sh
# This file is not supposed to be executed directly. It is a common resource file
# for all pacman functions.
# Support: pacman 4.1
if [ -z "$(command -v pacman)" ]; then
echo "You need to have the pacman package manager installed."
exit
fi
if [ -z "$(command -v makepkg)" ]; then
echo "You need to have makepkg (the pacman package builder) installed."
exit
fi
## We use tzdata as reference for the output fields, because it is almost always
## installed. This let's us access the entry of pacman's output independently of
## the current locale.
pacman_var_list="$(pacman -Qi tzdata | cut -f1 -d':')"
if [ -z "$pacman_var_list" ]; then
echo "Could not get pacman's variables."
exit 2
fi
pacman_name="$(echo "$pacman_var_list" | sed -n '1{p;q}')"
pacman_deps="$(echo "$pacman_var_list" | sed -n '9{p;q}')"
pacman_deps_none="$(pacman -Qi tzdata | sed -n '9{s/.*: //;p;q}')"
pacman_optdeps="$(echo "$pacman_var_list" | sed -n '10{p;q}')"
pacman_size="$(echo "$pacman_var_list" | sed -n '15{p;q}')"