diff --git a/find-debuginfo.sh b/find-debuginfo.sh new file mode 100755 index 0000000..e62c5ae --- /dev/null +++ b/find-debuginfo.sh @@ -0,0 +1,334 @@ +#!/bin/bash +#find-debuginfo.sh - automagically generate debug info and file list +#for inclusion in an rpm spec file. +# +# Usage: find-debuginfo.sh [-g] [--strict-build-id] +# [-o debugfiles.list] +# [[-l filelist]... [-p 'pattern'] -o debuginfo.list] +# [builddir] +# +# The -g flag says to use strip -g instead of full strip on DSOs. +# The --strict-build-id flag says to exit with failure status if +# any ELF binary processed fails to contain a build-id note. +# +# A single -o switch before any -l or -p switches simply renames +# the primary output file from debugfiles.list to something else. +# A -o switch that follows a -p switch or some -l switches produces +# an additional output file with the debuginfo for the files in +# the -l filelist file, or whose names match the -p pattern. +# The -p argument is an egrep-style regexp matching the a file name, +# and must not use anchors (^ or $). +# +# All file names in switches are relative to builddir (. if not given). +# + +# With -g arg, pass it to strip on libraries. +strip_g=false + +# Barf on missing build IDs. +# XXX temporarily on by default +strict=true + +BUILDDIR=. +out=debugfiles.list +nout=0 +while [ $# -gt 0 ]; do + case "$1" in + --strict-build-id) + strict=true + ;; + -g) + strip_g=true + ;; + -o) + if [ -z "${lists[$nout]}" -a -z "${ptns[$nout]}" ]; then + out=$2 + else + outs[$nout]=$2 + ((nout++)) + fi + shift + ;; + -l) + lists[$nout]="${lists[$nout]} $2" + shift + ;; + -p) + ptns[$nout]=$2 + shift + ;; + *) + BUILDDIR=$1 + shift + break + ;; + esac + shift +done + +i=0 +while ((i < nout)); do + outs[$i]="$BUILDDIR/${outs[$i]}" + l='' + for f in ${lists[$i]}; do + l="$l $BUILDDIR/$f" + done + lists[$i]=$l + ((++i)) +done + +LISTFILE=$BUILDDIR/$out +SOURCEFILE=$BUILDDIR/debugsources.list +LINKSFILE=$BUILDDIR/debuglinks.list + +> $SOURCEFILE +> $LISTFILE +> $LINKSFILE + +debugdir="${RPM_BUILD_ROOT}/usr/lib/debug" + +strip_to_debug() +{ + local g= + $strip_g && case "$(file -bi "$2")" in + application/x-sharedlib,*) g=-g ;; + esac + eu-strip --remove-comment -f "$1" "$2" || exit +} + +# Make a relative symlink to $1 called $3$2 +shopt -s extglob +link_relative() +{ + local t="$1" f="$2" pfx="$3" + local fn="${f#/}" tn="${t#/}" + local fd td d + + while fd="${fn%%/*}"; td="${tn%%/*}"; [ "$fd" = "$td" ]; do + fn="${fn#*/}" + tn="${tn#*/}" + done + + d="${fn%/*}" + if [ "$d" != "$fn" ]; then + d="${d//+([!\/])/..}" + tn="${d}/${tn}" + fi + + mkdir -p "$(dirname "$pfx$f")" && ln -snf "$tn" "$pfx$f" +} + +# Make a symlink in /usr/lib/debug/$2 to $1 +debug_link() +{ + local l="/usr/lib/debug$2" + local t="$1" + echo >> $LINKSFILE "$l $t" + link_relative "$t" "$l" "$RPM_BUILD_ROOT" +} + +# Make a build-id symlink for id $1 with suffix $3 to file $2. +make_id_link() +{ + local id="$1" file="$2" + local idfile=".build-id/${id:0:2}/${id:2}" + [ $# -eq 3 ] && idfile="${idfile}$3" + local root_idfile="$RPM_BUILD_ROOT/usr/lib/debug/$idfile" + + if [ ! -L "$root_idfile" ]; then + debug_link "$file" "/$idfile" + return + fi + + [ $# -eq 3 ] && return 0 + + local other=$(readlink -m "$root_idfile") + other=${other#$RPM_BUILD_ROOT} + if cmp -s "$root_idfile" "$RPM_BUILD_ROOT$file" || + eu-elfcmp -q "$root_idfile" "$RPM_BUILD_ROOT$file" 2> /dev/null; then + # Two copies. Maybe one has to be setuid or something. + echo >&2 "*** WARNING: identical binaries are copied, not linked:" + echo >&2 " $file" + echo >&2 " and $other" + else + # This is pathological, break the build. + echo >&2 "*** ERROR: same build ID in nonidentical files!" + echo >&2 " $file" + echo >&2 " and $other" + exit 2 + fi +} + +get_debugfn() +{ + dn=$(dirname "${1#$RPM_BUILD_ROOT}") + bn=$(basename "$1" .debug).debug + + debugdn=${debugdir}${dn} + debugfn=${debugdn}/${bn} +} + +set -o pipefail + +strict_error=ERROR +$strict || strict_error=WARNING + +# Strip ELF binaries +find $RPM_BUILD_ROOT ! -path "${debugdir}/*.debug" -type f \ + \( -perm -0100 -or -perm -0010 -or -perm -0001 \) \ + -print | +file -N -f - | sed -n -e 's/^\(.*\):[ ]*.*ELF.*, not stripped/\1/p' | +xargs stat -c '%h %D_%i %n' | +while read nlinks inum f; do + get_debugfn "$f" + [ -f "${debugfn}" ] && continue + + # If this file has multiple links, keep track and make + # the corresponding .debug files all links to one file too. + if [ $nlinks -gt 1 ]; then + eval linked=\$linked_$inum + if [ -n "$linked" ]; then + link=$debugfn + get_debugfn "$linked" + echo "hard linked $link to $debugfn" + ln -nf "$debugfn" "$link" + continue + else + eval linked_$inum=\$f + echo "file $f has $[$nlinks - 1] other hard links" + fi + fi + + echo "extracting debug info from $f" + id=$(/usr/lib/rpm/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug \ + -i -l "$SOURCEFILE" "$f") || exit + if [ -z "$id" ]; then + echo >&2 "*** ${strict_error}: No build ID note found in $f" + $strict && exit 2 + fi + + # A binary already copied into /usr/lib/debug doesn't get stripped, + # just has its file names collected and adjusted. + case "$dn" in + /usr/lib/debug/*) + [ -z "$id" ] || make_id_link "$id" "$dn/$(basename $f)" + continue ;; + esac + + mkdir -p "${debugdn}" + if test -w "$f"; then + strip_to_debug "${debugfn}" "$f" + else + chmod u+w "$f" + strip_to_debug "${debugfn}" "$f" + chmod u-w "$f" + fi + + if [ -n "$id" ]; then + make_id_link "$id" "$dn/$(basename $f)" + make_id_link "$id" "/usr/lib/debug$dn/$bn" .debug + fi +done || exit + +# For each symlink whose target has a .debug file, +# make a .debug symlink to that file. +find $RPM_BUILD_ROOT ! -path "${debugdir}/*" -type l -print | +while read f +do + t=$(readlink -m "$f").debug + f=${f#$RPM_BUILD_ROOT} + t=${t#$RPM_BUILD_ROOT} + if [ -f "$debugdir$t" ]; then + echo "symlinked /usr/lib/debug$t to /usr/lib/debug${f}.debug" + debug_link "/usr/lib/debug$t" "${f}.debug" + fi +done + +mkdir -p ${RPM_BUILD_ROOT}/usr/src/debug +LC_ALL=C sort -z -u $SOURCEFILE | egrep -v -z '(|)$' | +(cd $RPM_BUILD_DIR; cpio -pd0mL ${RPM_BUILD_ROOT}/usr/src/debug) +# stupid cpio creates new directories in mode 0700, fixup +find ${RPM_BUILD_ROOT}/usr/src/debug -type d -print0 | xargs -0 chmod a+rx + +gendirs=src +((nout > 0)) || gendirs='lib src' +for d in $gendirs; do + (cd ${RPM_BUILD_ROOT}/usr/$d; find debug -type d) | + sed "s,^,%dir /usr/$d/," >> $LISTFILE +done + +(cd ${RPM_BUILD_ROOT}/usr + find lib/debug ! -type d + find src/debug -mindepth 1 -maxdepth 1 +) | sed 's,^,/usr/,' >> $LISTFILE + +# Append to $1 only the lines from stdin not already in the file. +append_uniq() +{ + fgrep -f "$1" -x -v >> "$1" +} + +# Helper to generate list of corresponding .debug files from a file list. +filelist_debugfiles() +{ + local extra="$1" + shift + sed 's/^%[a-z0-9_][a-z0-9_]*([^)]*) *// +s/^%[a-z0-9_][a-z0-9_]* *// +/^$/d +'"$extra" "$@" +} + +# Write an output debuginfo file list based on given input file lists. +filtered_list() +{ + local out="$1" + shift + test $# -gt 0 || return + fgrep -f <(filelist_debugfiles 's,^.*$,/usr/lib/debug&.debug,' "$@") \ + -x $LISTFILE >> $out + sed -n -f <(filelist_debugfiles 's/[\\.*+#]/\\&/g +h +s,^.*$,s# &$##p,p +g +s,^.*$,s# /usr/lib/debug&.debug$##p,p +' "$@") $LINKSFILE | append_uniq "$out" +} + +# Write an output debuginfo file list based on an egrep-style regexp. +pattern_list() +{ + local out="$1" ptn="$2" + test -n "$ptn" || return + egrep -x -e "$ptn" $LISTFILE >> $out + sed -n -r "\#^$ptn #s/ .*\$//p" $LINKSFILE | append_uniq "$out" +} + +# +# When given multiple -o switches, split up the output as directed. +# +i=0 +while ((i < nout)); do + > ${outs[$i]} + filtered_list ${outs[$i]} ${lists[$i]} + pattern_list ${outs[$i]} "${ptns[$i]}" + fgrep -vx -f ${outs[$i]} $LISTFILE > ${LISTFILE}.new + mv ${LISTFILE}.new $LISTFILE + ((++i)) +done +if ((nout > 0)); then + # Now add the right %dir lines to each output list. + (cd ${RPM_BUILD_ROOT}; find usr/{lib,src}/debug -type d) | + sed 's#^.*$#\\@^/&/@{h;s@^.*$@%dir /&@p;g;}#' | + LC_ALL=C sort -ur > ${LISTFILE}.dirs.sed + i=0 + while ((i < nout)); do + sed -n -f ${LISTFILE}.dirs.sed ${outs[$i]} | sort -u > ${outs[$i]}.new + cat ${outs[$i]} >> ${outs[$i]}.new + mv -f ${outs[$i]}.new ${outs[$i]} + ((++i)) + done + sed -n -f ${LISTFILE}.dirs.sed ${LISTFILE} | sort -u > ${LISTFILE}.new + cat $LISTFILE >> ${LISTFILE}.new + mv ${LISTFILE}.new $LISTFILE +fi diff --git a/rpm-4.4.2.1-arm-typos.patch b/rpm-4.4.2.1-arm-typos.patch new file mode 100644 index 0000000..45da076 --- /dev/null +++ b/rpm-4.4.2.1-arm-typos.patch @@ -0,0 +1,33 @@ +changeset: 6214:ccfaf1c37a56 +user: Panu Matilainen +date: Mon Aug 06 14:47:43 2007 +0300 +files: installplatform rpmrc.in +description: +Couple of ARM-related typo fixes from Lennert Buytenhek. + + +diff -r f0a6328331a5 -r ccfaf1c37a56 installplatform +--- a/installplatform Mon Aug 06 14:47:10 2007 +0300 ++++ b/installplatform Mon Aug 06 14:47:43 2007 +0300 +@@ -32,7 +32,7 @@ case "$arch" in + case "$arch" in + i[3456]86|pentium[34]|athlon) SUBSTS='s_i386_i386_ s_i386_i486_ s_i386_i586_ s_i386_i686_ s_i386_pentium3_ s_i386_pentium4_ s_i386_athlon_' ;; + alpha*) SUBSTS='s_alpha_alpha_ s_alpha_alphaev5_ s_alpha_alphaev56_ s_alpha_alphapca56_ s_alpha_alphaev6_ s_alpha_alphaev67_' ;; +- arm*) SUBSTS='s_arm_armv3l_ s_arm_arm4l_ s_arm_armv4tl_ s_arm_armv5tel_ s_arm_armv5tejl_ s_arm_armv6l_' ;; ++ arm*) SUBSTS='s_arm_armv3l_ s_arm_armv4l_ s_arm_armv4tl_ s_arm_armv5tel_ s_arm_armv5tejl_ s_arm_armv6l_' ;; + sparc*) SUBSTS='s_sparc\(64\|v9\)_sparc_ s_sparc64_sparcv9_;s_sparc\([^v]\|$\)_sparcv9\1_ s_sparcv9_sparc64_;s_sparc\([^6]\|$\)_sparc64\1_' ;; + powerpc*|ppc*) SUBSTS='s_ppc64_ppc_ s_ppc\([^6ip]\|$\)_ppc64\1_ s_ppc\([^6ip]\|$\)_ppciseries_ s_ppc\([^6ip]\|$\)_ppcpseries_ s_ppc\([^6ip]\|$\)_ppc64iseries_ s_ppc\([^6ip]\|$\)_ppc64pseries_' ;; + s390*) SUBSTS='s_s390x_s390_ s_s390\([^x]\|$\)_s390x\1_' ;; +diff -r f0a6328331a5 -r ccfaf1c37a56 rpmrc.in +--- a/rpmrc.in Mon Aug 06 14:47:10 2007 +0300 ++++ b/rpmrc.in Mon Aug 06 14:47:43 2007 +0300 +@@ -230,7 +230,7 @@ buildarchtranslate: armv4l: armv4l + buildarchtranslate: armv4l: armv4l + buildarchtranslate: armv4tl: armv4tl + buildarchtranslate: armv5tel: armv5tel +-buildarchtranslate: armv5tejl: armv4tejl ++buildarchtranslate: armv5tejl: armv5tejl + buildarchtranslate: armv6l: armv6l + + buildarchtranslate: atarist: m68kmint + diff --git a/rpm.spec b/rpm.spec index 0a187ac..9a80f25 100644 --- a/rpm.spec +++ b/rpm.spec @@ -14,7 +14,7 @@ Summary: The RPM package management system Name: rpm Version: 4.4.2.1 %{expand: %%define rpm_version %{version}} -Release: 1%{?dist} +Release: 2%{?dist} Group: System Environment/Base Url: http://www.rpm.org/ Source: rpm-%{rpm_version}.tar.gz @@ -29,7 +29,10 @@ Patch8: rpm-4.4.2.1-checkterminate.patch Patch9: rpm-4.4.2.1-python-exithook.patch Patch10: rpm-4.4.2.1-checkterminate-noexit.patch Patch11: rpm-4.4.2.1-gnueabi.patch -License: GPL +Patch12: rpm-4.4.2.1-arm-typos.patch +# XXX Beware, this is one murky license, partially GPL/LGPL dual-licensed +# and several different components with their own licenses included... +License: (GPLv2 and LGPLv2 with exceptions) and BSD and MIT and Sleepycat Requires(pre): shadow-utils Requires(postun): shadow-utils Requires(post): coreutils @@ -37,6 +40,9 @@ Requires: popt = 1.10.2.1 Requires: crontabs Requires: logrotate +# XXX temporary +Source2: find-debuginfo.sh + BuildRequires: autoconf BuildRequires: elfutils-devel >= 0.112 BuildRequires: elfutils-libelf-devel-static @@ -95,7 +101,8 @@ will manipulate RPM packages and databases. %package build Summary: Scripts and executable programs used to build packages Group: Development/Tools -Requires: rpm = %{version}-%{release}, patch >= 2.5, file, elfutils +Requires: rpm = %{version}-%{release}, patch >= 2.5, file +Requires: elfutils >= 0.128 Requires: findutils Provides: rpmbuild(VendorConfig) = 4.1-1 @@ -120,6 +127,7 @@ programs that will manipulate RPM packages and databases. Summary: A C library for parsing command line parameters Group: Development/Libraries Version: 1.10.2.1 +License: MIT %description -n popt Popt is a C library for parsing command line parameters. Popt was @@ -144,6 +152,8 @@ shell-like rules. %patch9 -p1 -b .py-exithook %patch10 -p1 -b .checkterminate-noexit %patch11 -p1 -b .gnueabi +%patch12 -p1 -b .armtypo +cp -f %{SOURCE2} scripts/find-debuginfo.sh %build @@ -446,6 +456,13 @@ exit 0 %{__includedir}/popt.h %changelog +* Wed Aug 8 2007 Panu Matilainen - 4.4.2.1-2 +- ARM-related typo fixes from Lennert Buytenhek +- License clarifications + +* Mon Aug 6 2007 Roland McGrath +- new find-debuginfo.sh script, requires elfutils >= 0.128 + * Mon Jul 23 2007 Panu Matilainen 4.4.2.1-1 - 4.4.2.1 final - reintroduce disttag