]> git.ipfire.org Git - pakfire.git/blob - src/scripts/find-prerequires
9ace9b7c80db112e7ef89cd65c576c4a6162c094
[pakfire.git] / src / scripts / find-prerequires
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # Pakfire - The IPFire package management system #
5 # Copyright (C) 2021 Pakfire development team #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 error() {
23 echo "$@" >&2
24 }
25
26 main() {
27 local scriptlet="${1}"
28
29 if [ ! -r "${scriptlet}" ]; then
30 error "Input file is not readable"
31 return 1
32 fi
33
34 # We require a shell
35 echo "/bin/sh"
36
37 local req
38 while read -r req; do
39 case "${req}" in
40 /*)
41 echo "${req}"
42 ;;
43 *)
44 which "${req}" 2>/dev/null
45 ;;
46 esac
47 done < <(bash --rpm-requires < "${scriptlet}" | sed -e "s/^.*(//;s/)$//" | sort -u)
48
49 return 0
50 }
51
52 main "$@" || exit $?