summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2004-05-31 15:22:43 +0000
committerAndreas Gruenbacher <agruen@suse.de>2004-05-31 15:22:43 +0000
commitb704611db0b3e9bf4e9402745430aae1a68004dd (patch)
tree81b305eff4ba5f5dfc225bc0d8f4fe558bc331ba /scripts
parentced252dabbef9fd962a2f0d268a818c37815b8b4 (diff)
downloadquilt-b704611db0b3e9bf4e9402745430aae1a68004dd.tar.gz
- Rewrite spec2series to return what the new `quilt setup' needs,
and rename it to inspect. - `quilt setup': Rewrite so that it supports multiple archives per spec file. Always make the patches directory a symlink to the original patch files instead of copying the patches. - Update German translation.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/inspect.in182
-rwxr-xr-xscripts/spec2series.in227
2 files changed, 182 insertions, 227 deletions
diff --git a/scripts/inspect.in b/scripts/inspect.in
new file mode 100644
index 0000000..4fcfba3
--- /dev/null
+++ b/scripts/inspect.in
@@ -0,0 +1,182 @@
+#! @BASH@
+
+# This script is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# See the COPYING and AUTHORS files for more details.
+
+if ! [ -r @SCRIPTS@/patchfns ]
+then
+ echo "Cannot read library @SCRIPTS@/patchfns" >&2
+ exit 1
+fi
+. @SCRIPTS@/patchfns
+cd ${SUBDIR:-.}
+
+usage() {
+ echo "Usage: ${0##*/} specfile"
+ exit 1
+}
+
+if [ "$1" = -v ]
+then
+ verbose=1
+ shift
+fi
+
+specfile=$1
+if [ $# -ne 1 -o ! -f "$specfile" ]
+then
+ usage
+fi
+
+if [ "${specfile:0:1}" != / ]
+then
+ specfile="$PWD/$specfile"
+fi
+sourcedir=${specfile%/*}
+
+tmpdir="$(gen_tempfile -d ${TMPDIR-/tmp}/${0##*/})"
+mkdir -p $tmpdir || exit 1
+trap "rm -rf $tmpdir" EXIT
+mkdir -p $tmpdir/build
+mkdir -p $tmpdir/bin
+
+# Redirect file descriptors
+if [ -n "$verbose" ]
+then
+ exec 3>&1 4>/dev/null
+else
+ exec 3>&1 4>&2 2>/dev/null
+fi
+
+# create md5 sums, also for uncompressed files
+echo -n "### md5sum: " >&4
+shopt -s nullglob
+for file in *
+do
+ file=${file##*/}
+ case "$file" in
+ ready|bigpack|MD5SUMS|MD5SUMS.meta|*.spec|*.changes)
+ continue
+ ;;
+ esac
+ [ -f "$file" ] || continue
+ echo -n "." >&4
+ echo "md5sum < $file" >&2
+ set -- $(md5sum < $file)
+ echo "$1 $file"
+ case "$(file -b $file)" in
+ compress*|gzip*)
+ echo -n "g" >&4
+ echo "md5sum < <(gzip -cd $file)" >&2
+ set -- $(gzip -cd $file | md5sum)
+ echo "$1 $file"
+ ;;
+ bzip2*)
+ echo -n "b" >&4
+ echo "md5sum < <(bzip2 -cd $file)" >&2
+ set -- $(bzip2 -cd $file | md5sum)
+ echo "$1 $file"
+ ;;
+ esac
+done > $tmpdir/md5sum
+echo >&4
+shopt -u nullglob
+
+RPM=( @RPMBUILD@ --eval "%define _sourcedir $sourcedir" \
+ --eval "%define _specdir $sourcedir" \
+ --eval "%define _builddir $tmpdir/build" )
+PATH="$tmpdir/bin:$PATH"
+
+# wrapper script for patch and tar
+cat <<-'EOF' > $tmpdir/bin/wrapper
+ #! @BASH@
+
+ # search the path for command $1
+ path_search() {
+ local cmd=$1 dir
+ IFS=:
+ set -- $PATH
+ shift
+
+ for dir in "$@"; do
+ if [ -x $dir/$cmd ]
+ then
+ echo $dir/$cmd
+ return 0
+ fi
+ done
+ return 1
+ }
+
+ # find original data file by md5sum
+ original_file() {
+ local file=$1
+
+ set -- $(md5sum < $file)
+ while read md5sum file
+ do
+ if [ $1 = $md5sum ]
+ then
+ echo $file
+ return 0
+ fi
+ done < $tmpdir/md5sum
+ return 1
+ }
+
+ # Extract the -p option from the command line
+ strip_option() {
+ while [ $# -ne 0 -a "${1:0:2}" != -p ]
+ do
+ shift
+ done
+ if [ "${1:0:2}" = -p ]
+ then
+ [ "$1" = -p ] && set -- "$1$2"
+ [ "$1" != -p1 ] && echo $1
+ fi
+ }
+
+ # put data into tmpfile
+ tmpdir=${RPM_BUILD_DIR%/*}
+ cat > $tmpdir/data
+
+ unpackfile="$(original_file $tmpdir/data)"
+ if [ -n "$unpackfile" ]
+ then
+ dir=${PWD/$RPM_BUILD_DIR}
+ dir=${dir##/}
+
+ case "${0##*/}" in
+ patch)
+ echo -n p >&4
+ echo "${0##*/} ${dir:-.} $unpackfile" \
+ $(strip_option "$@") >&3
+ ;;
+ tar)
+ echo -n t >&4
+ echo "${0##*/} ${dir:-.} $unpackfile" >&3
+ ;;
+ esac
+ fi
+
+ realcmd="$(path_search ${0##*/})" \
+ && $realcmd "$@" < $tmpdir/data
+EOF
+chmod 755 $tmpdir/bin/wrapper
+ln -s wrapper $tmpdir/bin/patch
+ln -s wrapper $tmpdir/bin/tar
+
+# let rpm do all the dirty specfile stuff ...
+set -- @RPMBUILD@
+echo -n "### ${1##*/}: " >&4
+
+"${RPM[@]}" --nodeps -bp "$specfile" < /dev/null > /dev/null
+echo >&4
+### Local Variables:
+### mode: shell-script
+### End:
+# vim:filetype=sh
diff --git a/scripts/spec2series.in b/scripts/spec2series.in
deleted file mode 100755
index 729c3a2..0000000
--- a/scripts/spec2series.in
+++ /dev/null
@@ -1,227 +0,0 @@
-#! @BASH@
-
-# This script is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# See the COPYING and AUTHORS files for more details.
-
-# defaults
-debug=0
-specfile=""
-outfile=""
-
-function usage() {
-cat <<EOF
-Usage: quilt spec2series [ options ] specfile
-
--h print this text
--d debug mode (prints lots additional info
- as comments into the output file)
--o <file>
- specify output file, stdout if unspecified
-
-EOF
-}
-
-# parse args
-while test "$1" != ""; do
- case "$1" in
- -h | --help)
- usage; exit 0
- ;;
- -d | --debug)
- debug=1; shift
- ;;
- -o | --outfile)
- outfile="$2"; shift; shift
- ;;
- *)
- specfile="$1"
- break;
- ;;
- esac
-done
-
-if test ! -f "$specfile"; then
- usage
- exit 1
-fi
-
-# get absolute patch for specfile location
-specdir=`dirname $specfile`
-specfile=`basename $specfile`
-case "$specdir" in
- .) specdir="`pwd`"
- ;;
- /*) # nothing
- ;;
- *) specdir="`pwd`/$specdir"
- ;;
-esac
-
-# create tmp work dir
-WORK="${TMPDIR-/tmp}/rpmlog-$$"
-mkdir -p "$WORK" || exit 1
-trap 'rm -rf "$WORK"' EXIT
-mkdir -p "$WORK/build"
-mkdir -p "$WORK/bin"
-
-# create md5 sums, also for uncompressed files
-echo -n "### md5: " >&2
-(cd $specdir; for file in /dev/null *; do
- case "$file" in
- ready | bigpack | MD5SUMS | MD5SUMS.meta | *.spec | *.changes)
- continue
- ;;
- esac
- type="`file -b $file | cut -d" " -f1`"
- case "$type" in
- compress*)
- echo -n "z" >&2
- set -- `zcat $file | md5sum`
- echo "$1 zcat ${file}"
- ;;
- gzip)
- echo -n "g" >&2
- set -- `zcat $file | md5sum`
- echo "$1 zcat ${file}"
- ;;
- bzip2)
- echo -n "b" >&2
- set -- `bzcat $file | md5sum`
- echo "$1 bzcat ${file}"
- ;;
- esac
- echo -n "." >&2
- set -- `md5sum < $file`
- echo "$1 cat ${file}"
-done) > $WORK/md5sum
-echo $" done" >&2
-
-# prepare rpm dir fixups and hooks
-RPM="@RPMBUILD@ --rcfile=/usr/lib/rpm/rpmrc:$WORK/rpmrc"
-PATH="$WORK/bin:$PATH"
-grep ^macrofiles /usr/lib/rpm/rpmrc \
- | @SED@ -e "/macrofiles/s|$|:$WORK/rpmmacros|" \
- > $WORK/rpmrc
-cat <<-EOF > "$WORK/rpmmacros"
- %_sourcedir $specdir
- %_specdir $specdir
- %_builddir $WORK/build
-EOF
-
-# wrapper script for patch and tar
-cat <<-'EOF' > "$WORK/bin/patch"
- #!/bin/sh
-
- # save stuff for log
- unpackcmd=`basename $0`
- unpackdir=`pwd`
- unpackargs="$*"
- uncompress="false"
- unpackfile="[oops]"
-
- # sort of progress bar
- case $unpackcmd in
- tar) echo -n "t" >&2;;
- patch) echo -n "p" >&2;;
- *) echo -n "?" >&2;;
- esac
-
- # find real binary
- realcmd=""
- test -x "/bin/$unpackcmd" && realcmd="/bin/$unpackcmd"
- test -x "/usr/bin/$unpackcmd" && realcmd="/usr/bin/$unpackcmd"
- test "$realcmd" = "" && exit 1
-
- # put data into tmpfile, exec real cmd, return on failure
- WORK=`dirname $RPM_BUILD_DIR`
- cat > "$WORK/data"
- if test -x /bin/$unpackcmd; then
- cmddir="/bin"
- fi
- $realcmd $* < "$WORK/data"
- retval="$?"
- test "$retval" != "0" && exit $retval
-
- # find original data file by md5sum
- set -- `md5sum < "$WORK/data"`
- unpackfile="[$1]"
- set -- `cat "$WORK/md5sum"`
- while test "$1" != ""; do
- if test "[$1]" = "$unpackfile"; then
- uncompress="$2"
- unpackfile="$3"
- break
- fi
- shift
- done
-
- # print results
- unpackdir=`echo $unpackdir | @SED@ -e "s|$RPM_BUILD_DIR|BUILD|"`
- echo -n "# log: [$unpackdir] $uncompress $unpackfile" >>$WORK/cmdlog
- echo " | $unpackcmd $unpackargs" >>$WORK/cmdlog
- if test "$unpackcmd" = "patch" -a \
- -f "$RPM_SOURCE_DIR/$unpackfile"; then
- patchdir="${unpackdir#BUILD/}"
- if test ! -f "$WORK/patchdir"; then
- echo -n $patchdir > $WORK/patchdir
- fi
- if test "`cat $WORK/patchdir`" = "$patchdir"; then
- level=`echo $unpackargs | tr " " "\n" | grep ^-p`
- echo "$unpackfile $level" >> $WORK/patchlog
- fi
- fi
- if test "$unpackcmd" = "tar" -a \
- -f "$RPM_SOURCE_DIR/$unpackfile"; then
- echo -n "# Source: $unpackfile" >>$WORK/tarlog
- if test "$unpackdir" != "BUILD"; then
- echo -n " -C ${unpackdir#BUILD/}" >>$WORK/tarlog
- fi
- echo "" >>$WORK/tarlog
- fi
-EOF
-chmod 755 "$WORK/bin/patch"
-ln -s patch "$WORK/bin/tar"
-
-# let rpm do all the dirty specfile stuff ...
-echo -n "### $(basename @RPMBUILD@): " >&2
-touch $WORK/patchlog
-$RPM --nodeps --quiet -bp "$specdir/$specfile" </dev/null >/dev/null
-echo $" done" >&2
-
-# print results saved by the wrapper script
-(
- # header
- echo "# Patch series file for quilt, created by $0"
- echo "#"
- echo "# Sourcedir: $specdir"
- echo "# Specfile: $specfile"
- if test -f $WORK/patchdir; then
- echo "# Patchdir: `cat $WORK/patchdir`"
- fi
- echo "#"
-
- # additional info for trouble shooting
- if test "$debug" = "1"; then
- cat $WORK/md5sum | @SED@ -e 's/^/# md5: /'
- echo "#"
-
- test -f $WORK/cmdlog && cat $WORK/cmdlog && echo "#"
- fi
-
- # list tarballs + patches
- test -f $WORK/tarlog && cat $WORK/tarlog && echo "#"
- test -f $WORK/patchlog && cat $WORK/patchlog
-)|(
- if test "$outfile" != ""; then
- cat > "$outfile"
- else
- cat
- fi
-)
-### Local Variables:
-### mode: shell-script
-### End:
-# vim:filetype=sh