#!/bin/bash #.Y / 70 83 / / / / 105 / / / / / / ;A4_QUER.Y #.YT 3 2 0 0 3 3 1 / / / #.H!a!0:linux//dos_/rpm_/THIS!0.!c # #/*************************************************************************** # dos_ rpm_ THIS # ++++++++++++++ # # purpose : rpm-functions # # begin : Sat Aug 24 19:18:47 CEST 2013 # # changes : - # # copyright : (C) 2013 by Thomas Bruecker # # email : public0x05bf@bluewin.ch # # version : 0.0.0 # #***************************************************************************/ #/*************************************************************************** # * * # * This program is free software; you can redistribute it and/or modify * # * it under the terms of the GNU General Public License as published by * # * the Free Software Foundation; either version 2 of the License, or * # * (at your option) any later version. * # * * # * This program is distributed in the hope that it will be useful, but * # * WITHOUT ANY WARRANTY; without even the implied warranty of * # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * # * General Public License for more details. * # * * # * You should have received a copy of the GNU General Public License * # * along with this program; if not, write to the Free Software * # * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * # * * # ***************************************************************************/ # MyHash("linux//dos_/rpm_/THIS") = 0x0AF9 # # * for every function: # * if returned result is not commented, the function returns 0 on no-error. Copyright0x0AF9="Copyright (C) 2013 by Thomas Bruecker," Copyright0x0AF9="$Copyright0x0AF9 " SCRIPTS=root/bin ThisPath0x0AF9="/${SCRIPTS}/dos_/rpm_/THIS" Title0x0AF9="rpm-functions" Version0x0AF9="Version 0.0.0" . /$SCRIPTS/dos_/GLOBALS dos_rpm_() { # prints information to stdout. local Information # introduction: Information="\nTo learn more about \"$ThisPath0x0AF9\", read the following" Information="${Information} contents of that\nfile:\n\n" # + file contents: Information="${Information}Contents of \"$ThisPath0x0AF9\":\n\n" Information="${Information}$(cat $ThisPath0x0AF9)" echo -e "$Information" | less } dos_rpm_-v() { # prints version-information to stdout. echo "$Title0x0AF9, $Version0x0AF9" echo $Copyright0x0AF9 } dos_rpm_isTheExecutable() { # * returns true (0) and prints the full path of the executable "rpm" to stdout, # if the executable exists somewhere in the system. dos_isExecutable rpm # return result of the above } # command. dos_rpm_Executable2PackageName() { # $1 : maybe-name of executable to check. # * if the executable belongs to an installed package: returns true (0) and # prints the package-name of the packet, to which the executable belongs, # to stdout, # * else: returns 1 . local qExecutableName qExecutablePath # * ?ExecutableName: # maybe-executable-name, # * ?ExecutablePath. # maybe-executable-path. qExecutableName="$1" qExecutablePath=$(dos_isExecutable "$qExecutableName") || \ return $IncorrectExecutable0x09E8 # return if executable is # else # not in the system. dos_rpm_FilePath2PackageName "$qExecutablePath" return # return result of above } # command. dos_rpm_FilePath2PackageName() { # $1 : absolute path to a file in an rpm-package. # * if the file belongs to an installed package: returns true (0) and prints # the package-name of the package, to which the file belongs, to stdout, # * else: returns 1 local FilePath Result ResultString RpmPath FilePath="$1" RpmPath="$(dos_rpm_isTheExecutable)" || return 254 # return 254 if the execu- # table "rpm" is not found. ResultString=$( $RpmPath -qf --qf "%{NAME}\n" "$FilePath" 2>/dev/null ) Result=$? # do not print errors. if [ "0" == "$Result" ]; then # here: file is owned by some package; print package-name to stdout: echo "$ResultString" fi return $Result }