Package: devscripts
Version: 2.10.19
Severity: wishlist

Hello,

I'd like to propose my dcmd script for inclusion in devscripts.
For the motivations behind it, please see the following posts:

  http://blog.orebokech.com/2007/06/dscchanges-aware-scp.html
  http://blog.orebokech.com/2007/06/dcmd.html

I find it very convenient, and from the feedback I got I think other
maintainers may find it helpful.  AIUI devscripts only includes
Perl and shell scripts so I rewrote it in shell, avoiding the
python/python-debian dependency.

I'm attaching to this message:
- the script itself
- its man page
- a diff against devscripts SVN adding dcmd to the package

Thanks,
-- 
Romain Francoise <[EMAIL PROTECTED]>
http://people.debian.org/~rfrancoise/

#!/bin/sh
#
# dcmd: expand file lists of .dsc/.changes files in the command line
#
# Copyright (C) 2008 Romain Francoise <[EMAIL PROTECTED]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

# Usage:
#
# dcmd replaces any reference to a .dsc or .changes file in the command
# line with the list of files in its 'Files' section, plus the
# .dsc/.changes file itself.
#
# $ dcmd sha1sum rcs_5.7-23_amd64.changes
# f61254e2b61e483c0de2fc163321399bbbeb43f1  rcs_5.7-23.dsc
# 7a2b283b4c505d8272a756b230486a9232376771  rcs_5.7-23.diff.gz
# e3bac970a57a6b0b41c28c615f2919c931a6cb68  rcs_5.7-23_amd64.deb
# c531310b18773d943249cfaa8b539a9b6e14b8f4  rcs_5.7-23_amd64.changes
# $

usage()
{
    printf "Usage: %s [command] [dsc or changes file] [...]\n" `basename $0`
}

endswith()
{
    [ $(basename "$1" $2)$2 = $(basename "$1") ]
}

# Instead of parsing the file completely as the previous Python
# implementation did (using python-debian), let's just select lines
# that look like they might be part of the file list.
RE="^ [0-9a-f]{32} [0-9]+ ([a-z]+ [a-z]+ )?(.*)$"

maybe_expand()
{
    local dir
    if [ -f "$1" ] && (endswith "$1" .changes || endswith "$1" .dsc); then
	dir=$(dirname "$1")
	sed -rn "s,$RE,$dir/\2,p" <"$1" | sed 's,^\./,,'
    fi
}

if [ $# -lt 2 ]; then
    usage
    exit 1
fi

cmd=$1
shift

args=""
for arg in "$@"; do
    args="$args $(maybe_expand "$arg") $arg"
done

exec $cmd $args
.TH DCMD 1 "Debian Utilities" "DEBIAN" \" -*- nroff -*-
.SH NAME
dcmd \- expand file lists of .dsc/.changes files in the command line
.SH SYNOPSIS
\fBdcmd\fR [command] [\fIchanges-file\fR|\fIdsc-file\fR] [...]
.SH DESCRIPTION
\fBdcmd\fR replaces any reference to a .dsc or .changes file in the
command line with the list of files in its 'Files' section, plus the
file itself.  It allows easy manipulation of all the files involved in
an upload (for changes files) or a source package (for dsc files).
.SH "EXAMPLES"
Copy the result of a build to another machine:

.nf
$ dcmd scp rcs_5.7-23_amd64.changes elegiac:/tmp
rcs_5.7-23.dsc                  100%  490     0.5KB/s   00:00
rcs_5.7-23.diff.gz              100%   12KB  11.7KB/s   00:00
rcs_5.7-23_amd64.deb            100%  363KB 362.7KB/s   00:00
rcs_5.7-23_amd64.changes        100% 1095     1.1KB/s   00:00
$
.fi

Check the contents of a source package:

.nf
$ dcmd md5sum rcs_5.7-23.dsc 
8fd09ea9654cda128f8d5c337d3b8de7  rcs_5.7.orig.tar.gz
f0ceeae96603e823eacba6721a30b5c7  rcs_5.7-23.diff.gz
5241db1e231b1f43ae5514b63d2523f8  rcs_5.7-23.dsc
$
.fi

.SH "SEE ALSO"
.BR dpkg-source (1),
.BR dpkg-genchanges (1).
.SH AUTHOR
This program was written by Romain Francoise <[EMAIL PROTECTED]> and
is released under the GPL, version 2 or later.
Index: debian/control
===================================================================
--- debian/control	(revision 1192)
+++ debian/control	(working copy)
@@ -47,6 +47,7 @@
     dupload | dput, ssh]
   - cvs-debuild: run cvs-buildpackage using debuild (see below) as the
     package building program [cvs-buildpackage, fakeroot, lintian, gnupg]
+  - dcmd: expand file lists of .dsc/.changes files in the command line
   - dd-list: given a list of packages, pretty-print it ordered by maintainer
   - debc: display the contents of just-built .debs
   - debchange/dch: automagically add entries to debian/changelog files
Index: po4a/devscripts-po4a.conf
===================================================================
--- po4a/devscripts-po4a.conf	(revision 1192)
+++ po4a/devscripts-po4a.conf	(working copy)
@@ -29,6 +29,8 @@
 	fr:fr/cvs-debrelease.fr.1 add_fr:add_fr/translator_man.add
 [type:man] ../scripts/cvs-debuild.1 \
 	fr:fr/cvs-debuild.fr.1 add_fr:add_fr/translator_man.add
+[type:man] ../scripts/dcmd.1 \
+	fr:fr/dcmd.fr.1 add_fr:add_fr/translator_man.add
 [type:man] ../scripts/dd-list.1 \
 	fr:fr/dd-list.fr.1 add_fr:add_fr/translator_man.add
 [type:man] ../scripts/debc.1 \
Index: README
===================================================================
--- README	(revision 1192)
+++ README	(working copy)
@@ -48,6 +48,8 @@
   wrapper for cvs-buildpackage to use debuild as its package building
   program.
 
+- dcmd: Expand file lists of .dsc/.changes files in the command line.
+
 - dd-list: Given a list of packages, pretty-print it ordered by maintainer.
 
 - debc: List contents of current package.  Do this after a successful
Index: conf.default.in
===================================================================
--- conf.default.in	(revision 1192)
+++ conf.default.in	(working copy)
@@ -125,6 +125,10 @@
 # 
 # No variables currently
 
+##### dcmd
+# 
+# No variables currently
+
 ##### debc
 # 
 # debc recognises the DEBRELEASE_DEBS_DIR variable; see debrelease

Reply via email to