summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
Diffstat (limited to 'support')
-rwxr-xr-xsupport/scripts/apply-patches.sh55
-rwxr-xr-xsupport/scripts/check-host-rpath71
2 files changed, 101 insertions, 25 deletions
diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
index af6df9ec72..2edf05466f 100755
--- a/support/scripts/apply-patches.sh
+++ b/support/scripts/apply-patches.sh
@@ -16,8 +16,9 @@
# '*'. Pattern(s) describing the patch names you want to apply.
#
# The script will look recursively for patches from the patch directory. If a
-# file is named 'series' then only patches mentionned into it will be applied.
-# If not, the script will look for file names matching pattern(s). If the name
+# file named 'series' exists then the patches mentioned in it will be applied
+# as plain patches, regardless of their file name. If no 'series' file exists,
+# the script will look for file names matching pattern(s). If the name
# ends with '.tar.*', '.tbz2' or '.tgz', the file is considered as an archive
# and will be uncompressed into a directory named
# '.patches-name_of_the_archive-unpacked'. It's the turn of this directory to
@@ -64,28 +65,32 @@ find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print0 | \
function apply_patch {
path=$1
patch=$2
- case "$patch" in
- *.gz)
- type="gzip"; uncomp="gunzip -dc"; ;;
- *.bz)
- type="bzip"; uncomp="bunzip -dc"; ;;
- *.bz2)
- type="bzip2"; uncomp="bunzip2 -dc"; ;;
- *.xz)
- type="xz"; uncomp="unxz -dc"; ;;
- *.zip)
- type="zip"; uncomp="unzip -d"; ;;
- *.Z)
- type="compress"; uncomp="uncompress -c"; ;;
- *.diff*)
- type="diff"; uncomp="cat"; ;;
- *.patch*)
- type="patch"; uncomp="cat"; ;;
- *)
- echo "Unsupported file type for ${path}/${patch}, skipping";
- return 0
- ;;
- esac
+ if [ "$3" ]; then
+ type="series"; uncomp="cat"
+ else
+ case "$patch" in
+ *.gz)
+ type="gzip"; uncomp="gunzip -dc"; ;;
+ *.bz)
+ type="bzip"; uncomp="bunzip -dc"; ;;
+ *.bz2)
+ type="bzip2"; uncomp="bunzip2 -dc"; ;;
+ *.xz)
+ type="xz"; uncomp="unxz -dc"; ;;
+ *.zip)
+ type="zip"; uncomp="unzip -d"; ;;
+ *.Z)
+ type="compress"; uncomp="uncompress -c"; ;;
+ *.diff*)
+ type="diff"; uncomp="cat"; ;;
+ *.patch*)
+ type="patch"; uncomp="cat"; ;;
+ *)
+ echo "Unsupported file type for ${path}/${patch}, skipping";
+ return 0
+ ;;
+ esac
+ fi
if [ -z "$silent" ] ; then
echo ""
echo "Applying $patch using ${type}: "
@@ -111,7 +116,7 @@ function scan_patchdir {
# to apply patches. Skip line starting with a dash.
if [ -e "${path}/series" ] ; then
for i in `grep -Ev "^#" ${path}/series 2> /dev/null` ; do
- apply_patch "$path" "$i"
+ apply_patch "$path" "$i" series
done
else
for i in `cd $path; ls -d $patches 2> /dev/null` ; do
diff --git a/support/scripts/check-host-rpath b/support/scripts/check-host-rpath
new file mode 100755
index 0000000000..dc9e17fe57
--- /dev/null
+++ b/support/scripts/check-host-rpath
@@ -0,0 +1,71 @@
+#!/usr/bin/env bash
+
+# This script scans $(HOST_DIR)/{bin,sbin} for all ELF files, and checks
+# they have an RPATH to $(HOST_DIR)/usr/lib if they need libraries from
+# there.
+
+# Override the user's locale so we are sure we can parse the output of
+# readelf(1) and file(1)
+export LC_ALL=C
+
+main() {
+ local pkg="${1}"
+ local hostdir="${2}"
+ local file ret
+
+ # Remove duplicate and trailing '/' for proper match
+ hostdir="$( sed -r -e 's:/+:/:g;' <<<"${hostdir}" )"
+
+ ret=0
+ while read file; do
+ elf_needs_rpath "${file}" "${hostdir}" || continue
+ check_elf_has_rpath "${file}" "${hostdir}" && continue
+ if [ ${ret} -eq 0 ]; then
+ ret=1
+ printf "***\n"
+ printf "*** ERROR: package %s installs executables without proper RPATH:\n" "${pkg}"
+ fi
+ printf "*** %s\n" "${file}"
+ done < <( find "${hostdir}"/usr/{bin,sbin} -type f -exec file {} + 2>/dev/null \
+ |sed -r -e '/^([^:]+):.*\<ELF\>.*\<executable\>.*/!d' \
+ -e 's//\1/' \
+ )
+
+ return ${ret}
+}
+
+elf_needs_rpath() {
+ local file="${1}"
+ local hostdir="${2}"
+ local lib
+
+ while read lib; do
+ [ -e "${hostdir}/usr/lib/${lib}" ] && return 0
+ done < <( readelf -d "${file}" \
+ |sed -r -e '/^.* \(NEEDED\) .*Shared library: \[(.+)\]$/!d;' \
+ -e 's//\1/;' \
+ )
+
+ return 1
+}
+
+check_elf_has_rpath() {
+ local file="${1}"
+ local hostdir="${2}"
+ local rpath dir
+
+ while read rpath; do
+ for dir in ${rpath//:/ }; do
+ # Remove duplicate and trailing '/' for proper match
+ dir="$( sed -r -e 's:/+:/:g; s:/$::;' <<<"${dir}" )"
+ [ "${dir}" = "${hostdir}/usr/lib" ] && return 0
+ done
+ done < <( readelf -d "${file}" \
+ |sed -r -e '/.* \(R(UN)?PATH\) +Library r(un)?path: \[(.+)\]$/!d' \
+ -e 's//\3/;' \
+ )
+
+ return 1
+}
+
+main "${@}"
OpenPOWER on IntegriCloud