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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
#!/bin/bash
# d-devlibdeps -- get list of build-time dependencies
# Copyright (C) 2002-2003 Junichi Uekawa
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# 2002 May 3. Created.
# automatic depends line generator.
set -e
function getname () {
local SONAMELIBNAME
local SONAMEVERSION
local SONAME
SONAME="$1"
SONAMELIBNAME=$(echo $SONAME | sed 's/\.so\..*$//')
SONAMEVERSION=$(echo $SONAME | sed 's/^.*\.so\.//')
case "$SONAMELIBNAME" in
*[0-9])
RETURN="$SONAMELIBNAME-$SONAMEVERSION"
;;
*)
RETURN="$SONAMELIBNAME$SONAMEVERSION"
;;
esac
}
function overridedevlibdeps () {
# overrides necessary until the scheme is adopted.
sed \
-e 's/libX11-6-dev/libx11-dev | xlibs-dev (<< 4.3.0)/' \
-e 's/libXext6-dev/libxext-dev | xlibs-dev (<< 4.3.0)/' \
-e 's/libXi6-dev/libxi-dev | xlibs-dev (<< 4.3.0)/' \
-e 's/libXpm4-dev/libxpm-dev | xlibs-dev (<< 4.3.0)/' \
-e 's/libICE6-dev/libice-dev | xlibs-dev (<< 4.3.0)/' \
-e 's/libSM6-dev/libsm-dev | xlibs-dev (<< 4.3.0)/' \
-e 's/libGL1-dev/xlibmesa-gl-dev | xlibs-dev (<< 4.3.0)/' \
-e 's/libGLU1-dev/xlibmesa-glu-dev | xlibs-dev (<< 4.3.0)/' \
-e 's/libcrypt1-dev//' \
-e 's/libcrypt1\.1-dev//' \
-e 's/libdl2-dev//' \
-e 's/libdl2.1-dev//' \
-e 's/libm6-dev//' \
-e 's/libm6.1-dev//' \
-e 's/libm1-dev//' \
-e 's/libnsl1-dev//' \
-e 's/libnsl1\.1-dev//' \
-e 's/libpthread0-dev//' \
-e 's/libpthread.*-dev/libpthread-dev/' \
-e 's/libresolv2-dev//' \
-e 's/libglib-1.2-0-dev/libglib1.2-dev/' \
-e 's/libgthread-1.2-0-dev/libglib1.2-dev/' \
-e 's/libgmodule-1.2-0-dev/libglib1.2-dev/' \
-e 's/libgtk-1.2-0-dev/libgtk1.2-dev/' \
-e 's/libpam0-dev/libpam0g-dev/' \
-e 's/libgdk-1.2-0-dev/libgtk1.2-dev/' \
-e 's/libz1-dev/zlib1g-dev/' \
-e 's/libgcc_s1-dev//' \
-e 's/libcrypto.*-dev/libssl-dev/' \
-e 's/libssl.*-dev/libssl-dev/' \
-e 's/libcomerr2//' \
-e 's/libcom_err2-dev/comerr-dev/' \
-e 's/libgssapi_krb5-2-dev/libkrb5-dev/' \
-e 's/libk5crypto3-dev/libkrb5-dev/' \
-e 's/libkrb5-3-dev/libkrb5-dev/' \
-e 's/libparted-1.6-0-dev/libparted1.6-dev/' \
-e 's/libSDL-1.2-0-dev/libsdl1.2-dev/' \
-e 's/libvorbis0-dev/libvorbis-dev/' \
-e 's/libcrack2-dev/cracklib2-dev/' \
-e 's/libkrb1-dev/kerberos4kth-dev/' \
-e 's/libtheora0-dev/libtheora-dev/' \
-e 's/libvorbisenc2-dev/libvorbis-dev/' \
-e 's/libogg0-dev/libogg-dev/' \
}
function validate_package () {
# validate if package foo exists, this relies on apt.
if [ -z "$1" ]; then
# ignore empty.
return;
fi
if grep "^Package: $1\$" debian/control > /dev/null 2> /dev/null ; then
# ignore package that is going to be created.
echo " --> $1 package from same source package." >&2
return
fi
case $(echo $(apt-cache show $1 2> /dev/null| wc -l ) ) in
0)
case $(echo $(apt-cache showpkg $1 2> /dev/null | awk ' /^Reverse Provides: $/,/^$/ {if ($0 !~ /:/) {print $0}}' | wc -l) ) in
0)
echo "devlibs error: There is no package matching [$1] and noone provides it, please report bug to d-shlibs maintainer" >&2
return 1;;
*) echo " --> $1 is provided by a package." >&2 ;;
esac;;
*) echo " --> $1 package exists." >&2 ;;
esac
return 0;
}
if [ -z "$2" ]; then
echo "$0: Please read manpage for help, not enough options given"
exit 1
fi
OUTPUTFILE="$1"
shift;
DEPENDS=
for A in $*; do
DEPENDS="$DEPENDS $(objdump -p ${A} |sed -n 's/^.*NEEDED *//p')"
done
outputtmp=$(tempfile)
(
set -e
if [ -f "$OUTPUTFILE" ] ; then
if grep -v "^devlibs:Depends=" "$OUTPUTFILE"; then
:
fi
fi
printf "devlibs:Depends="
for A in $DEPENDS; do
getname "$A"
echo $RETURN-dev | overridedevlibdeps
done | \
sort | \
uniq | \
while read B; do
# abuse that only first part of multi-entry overrides is considered
if validate_package $B ; then
printf "%s " $B ;
else
echo "ERROR_DEVLIB "
fi
done | sed -e 's/\([a-z0-9)]\) \+\([a-z]\)/\1, \2/g' -e 's/ \+/ /g' -e 's/^ //' -e 's/ $//'
printf "\n"
) > "${outputtmp}"
if grep "ERROR_DEVLIB" "$outputtmp" > /dev/null; then
exit 1
fi
mv "${outputtmp}" $OUTPUTFILE
|