summaryrefslogtreecommitdiffstats
path: root/.bashrc-fedora
blob: 3478d11fa9b2dffdcb8d216e4981033e96c31606 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# .bashrc-fedora

alias gkoji="cd ~/wrkspc/gkoji"

whichpkg() {
	local found=$(which "$1")
	[ -n "${found}" ] && found=$(man -w "$1" 2>/dev/null)
	[ -n "${found}" ] && rpm -qf "${found}" || { echo; repoquery -f "*/$1";}
}

# see https://bugzilla.redhat.com/show_bug.cgi?id=852197
pkgdep() {
	TMPFILE=$(mktemp rpqXXXX);
	repoquery --tree-requires -- "$1" \
 	  | grep -v -eglibc -e$(rpm -q python) -e$(rpm -q python-libs) \
	  | sed -n '$q;/^.*bash/bend;p;d;:end n;bend' \
	  | tac >${TMPFILE}
	while sed -i \
 	  's/^\([ ]*\)|\([^|\\]*\)/\1 \2/;t;1bbad;:ok $q0;n;bok;:bad $q1;n;bbad' \
	  ${TMPFILE}; do : ; done
	cat -- ${TMPFILE} | tac
	rm -f -- ${TMPFILE}
}

# see http://superuser.com/questions/194928/view-configuration-file-changes-with-rpm-or-yum
pkgdiff() {
	rpm -V "$1" | cut -d/ -f2- | xargs -I{} rpmpeek \
	  <(curl -- $(yumdownloader --urls $(rpm -q "$1") | sed -n '/^http/{s|//|/|2;p}')) \
	  colordiff -u /{} ./{} 2>/dev/null
}

# something like "fedpkg prep"
rpmbuild-patch() {
        local filter=cat verbose= arg=
        if [ "$1" = "-v" ]; then
                verbose="--define \"_default_patch_flags $(rpm --eval %{_default_patch_flags}) --verbose\""
                shift
        fi
	[ $# -eq 0 ] && arg="$(basename "$(pwd)").spec"
	[ -t 1 ] && filter='sed s|^\(Hunk.*\)|\x1b[1;31m\1\x1b[0m|'
	{ LC=C eval rpmbuild -bp --nodeps \
	  --define \"_builddir $(pwd)\" \
	  --define \"_sourcedir $(pwd)\" \
	  ${verbose} "${@}" "${arg}"
	} | ${filter}
}