123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- #!/bin/bash
-
- ffoo import core
-
-
- guess_pkgnames() {
- #
- # Guess interesting names from a folder of RPMs
- #
- ls "$1" \
- | grep rpm\$ \
- | sed -e 's/-[0-9].*$//' \
- | sort \
- | uniq
- }
-
-
- guess_rtag() {
- #
- # Guess release tag from uname
- #
- uname -r | sed -e 's/^[.0-9-]*//; s/\..*$//'
- }
-
-
- guess_rtag_word() {
- #
- # Guess "word" part of release tag from uname
- #
- # Use guess_rtag and parse out the "word" part,
- # e.g. el from el6 or fc from fc18
- #
- echo $(guess_rtag) | sed -e 's/[0-9]*$//'
- }
-
-
- guess_rtag_num() {
- #
- # Guess "numeric" part of release tag from uname
- #
- # Use guess_rtag and parse out the "numeric" part,
- # e.g. 6 from el6 or 18 from fc18
- #
- echo $(guess_rtag) | sed -e 's/^[a-z]*//'
- }
-
-
- installed_versions() {
- #
- # For every prefix, print installed versions
- #
- cat - \
- | while read name;
- do rpm -qa "$name*";
- done \
- | sort \
- | uniq
- }
-
-
- nvc_parse() {
- #
- # Parse NVC and print element they asked for
- #
- local what="$1"
- local nvc="$2"
- test -n "$nvc" || what=USAGE # just provoke the * case
- local arch="${nvc##*.}"
- local rest="${nvc%%.$arch}"
- local release="${rest##*-}"
- local rest="${rest%%-$release}"
- local version="${rest##*-}"
- local name="${rest%-*}"
- case $what in
- arch)
- echo $arch
- ;;
- release)
- echo $release
- ;;
- version)
- echo $version
- ;;
- name)
- echo $name
- ;;
- *)
- usage_is "arch|release|version|name NVC"
- return 1
- esac
- }
-
-
- save_repo_for() {
- #
- # Fetch a repo for given target/release
- #
- # Find out release, take target and from repo_uris.ini,
- # choose correct repo URI, finally saving the repo file
- # to /etc/yum.repos.d
- #
- local target=$1
- local rtag_word=$(guess_rtag_word)
- local uri=$(iniread -s $rtag_word -k $target repo_uris.ini)
- think "adding repo for $target"
- debug -v target rtag_word uri
- case "$uri" in
- INCLUDED)
- ;;
- NONE)
- warn "no repo available for $target"
- return 1
- ;;
- *)
- pushd /etc/yum.repos.d/ >/dev/null
- wget -q "$uri"
- popd >/dev/null
- ;;
- esac
- }
-
-
- yum_preerase() {
- #
- # Read package names from stdin and pre-erase them
- #
- local pkg
- for pkg in "$@";
- do
- if rpm -q "$pkg" &> /dev/null;
- then
- think "pre-erasing $pkg"
- yum -q -y erase "$pkg"
- fi
- done
- }
-
-
- yum_install() {
- #
- # Mindlessly and silently install anything
- #
- yum -q -y install "$@" 2>&1 | mute_known yum
- }
-
-
- yum_install_if_needed() {
- #
- # yum_install unless it's already installed
- #
- local pkgs="$(select_args word $@)"
- local opts="$(select_args opt $@)"
- local pkg
- debug -v pkgs opts
- for pkg in $pkgs;
- do
- rpm -q $pkg >& /dev/null || yum_install $opts $pkg;
- done
- }
-
-
- yum_update() {
- #
- # Mindlessly and silently update anything
- #
- yum -q -y update "$@" 2>&1 | mute_known yum
- }
|