1#!/usr/bin/env bash 2# FOSSology utils.sh script 3# Copyright (C) 2008-2014 Hewlett-Packard Development Company, L.P. 4# This program is free software; you can redistribute it and/or 5# modify it under the terms of the GNU General Public License 6# version 2 as published by the Free Software Foundation. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License along 14# with this program; if not, write to the Free Software Foundation, Inc., 15# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16# 17# This script helps you install build and runtime dependencies on a system. 18# It is NOT indented to replace package dependencies, it's just a tool to 19# make testing the "upstream" build and install process. If you determine 20# this script isn't installing something you think it should, consult 21# the packaging metadata for the system in question as that is the 22# canonical location for such info, then fix it there first and also 23# update this file and the INSTALL document. 24 25must_run_as_root() { 26 # This must run as root. 27 if [[ $(id -u) -ne 0 ]] ; then 28 echo >&2 "ERROR: fo-installdeps must run as root." 29 echo >&2 "Aborting." 30 exit 1 31 fi 32} 33 34need_lsb_release() { 35 hash lsb_release 2>/dev/null || { cat >&2 <<EOF 36ERROR: this program requires the lsb_release command. On Debian based 37 systems this is probably in the lsb-release package, on 38 Fedora/RedHat systems it is probably the redhat-lsb package. 39Aborting. 40EOF 41 exit 1; } 42} 43 44show_help_for_mod_deps() { 45 cat <<EOF 46Usage: mod_deps [options] 47 -r or --runtime : install runtime dependencies 48 -b or --buildtime : install buildtime dependencies 49 -e or --everything : install all dependencies (default) 50 -y : Automatic yes to prompts 51 -h or --help : this help text 52EOF 53} 54 55VERSION_PATTERN='([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+)(-?rc[[:digit:]]+)?-([[:digit:]]+)-[[:alnum:]]*' 56VERSION_COMMAND="git describe --tags > /dev/null 2>&1 && git describe --tags | head -1 | sed -re 's/${VERSION_PATTERN}/\\1.\\3\\2/'" 57