]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
naoki: Add REQUIRES and PROVIDES information to packages.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 2 Apr 2010 17:30:47 +0000 (19:30 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 2 Apr 2010 17:44:01 +0000 (19:44 +0200)
tools/common-functions [new file with mode: 0644]
tools/compressor

diff --git a/tools/common-functions b/tools/common-functions
new file mode 100644 (file)
index 0000000..d887a5c
--- /dev/null
@@ -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" " "
+}
index ac2a848d330582541deeac98969162cb50d46768..659b28c7610767ea1b389f4227f2ce680aff6d9f 100755 (executable)
@@ -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 }')"