From: Michael Tremer Date: Fri, 2 Apr 2010 17:30:47 +0000 (+0200) Subject: naoki: Add REQUIRES and PROVIDES information to packages. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c57a28f869e7c01dde98b71ed10d9732987a172;p=ipfire-3.x.git naoki: Add REQUIRES and PROVIDES information to packages. --- diff --git a/tools/common-functions b/tools/common-functions new file mode 100644 index 000000000..d887a5c08 --- /dev/null +++ b/tools/common-functions @@ -0,0 +1,75 @@ +#!/bin/bash + +LIBARY_PATHS="${BUILDROOT}/lib ${BUILDROOT}/usr/lib" +BINARY_PATHS="${LIBARY_PATHS} ${BUILDROOT}/bin ${BUILDROOT}/sbin" +BINARY_PATHS="${BINARY_PATHS} ${BUILDROOT}/usr/bin ${BUILDROOT}/usr/sbin" + +get_interpreter() { + local file=${1} + + readelf -l ${file} | grep "program interpreter" | \ + tr -d "]" | awk '{ print $NF }' +} + +get_needed() { + local file=${1} + + readelf -d ${file} | grep NEEDED | \ + tr -d "[]" | awk '{ print $NF }' +} + +get_soname() { + local file=${1} + + readelf -d ${file} | grep SONAME | \ + tr -d "[]" | awk '{ print $NF }' +} + +find_requires() { + local output + local file + local files=$(find_elf_files ${BINARY_PATHS}) + + for file in ${files}; do + output="${output} $(get_needed ${file})" + done + + listsort ${output} +} + +find_provides() { + local output + local file + local files=$(find_elf_files ${LIBARY_PATHS}) + + for file in ${files}; do + output="${output} $(get_soname ${file})" + done + + listsort ${output} +} + +find_elf_files() { + local dir + local dirs=$@ + + local file + local files + + for dir in ${dirs}; do + for file in $(find ${dir} -maxdepth 1 -type f 2>/dev/null); do + if file ${file} | grep -q ELF; then + files="${files} ${file}" + fi + done + done + + echo ${files} +} + +listsort() { + local item + for item in $@; do + echo "${item}" + done | sort -u | tr "\n" " " +} diff --git a/tools/compressor b/tools/compressor index ac2a848d3..659b28c76 100755 --- a/tools/compressor +++ b/tools/compressor @@ -19,6 +19,8 @@ # # ############################################################################### +. $(dirname ${0})/common-functions + PACKAGE_VERSION="0" TAR_OPTIONS="--posix --acls --no-recursion --sparse" @@ -188,7 +190,9 @@ PKG_DESCRIPTION="$PKG_DESCRIPTION" # Dependency info PKG_DEPS="$PKG_DEPS" -PKG_BUILD_DEPS="$PKG_BUILD_DEPS" + +PKG_PROVIDES="$(find_provides)" +PKG_REQUIRES="$(find_requires)" PKG_DATA_SHA1="$(sha1sum ${archieve} | awk '{ print $1 }')"