5 # Time-stamp: <96/05/03 13:59:41 root>
6 prog
="`basename \"${0}\"`"
7 version
="1.2.3"; # This line modified by Makefile
8 purpose
="rename Debian packages to full package names"
11 echo "# ${prog} ${version} -- ${purpose}
12 # Copyright (C) 1995,1996 Erick Branderhorst <branderh@debian.org>.
14 # This is free software; you can redistribute it and/or modify it
15 # under the terms of the GNU General Public License as published by the
16 # Free Software Foundation; either version 2, or (at your option) any
19 # This is distributed in the hope that it will be useful, but
20 # WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
22 # /usr/doc/copyright/GPL for more details."
26 echo "${prog}: $@" >/dev
/stderr
;
30 echo "${prog} version ${version} -- ${purpose}";
34 echo "Usage: ${prog} file[s]
36 file.deb changes to <package>_<version>_<architecture>.deb
37 according to the ``underscores convention''.
38 -a|--no-architecture No architecture part in filename
39 -o|--overwrite Overwrite if file exists
40 -s|--subdir [dir] Move file into subdir (Use with care)
41 -c|--create-dir Create target dir if not there (Use with care)
42 -h|--help|-v|--version|-l|--license Show help/version/license"
50 stderr
"can't find \`"$1"'";
56 if p
=`dpkg-deb -f -- "$1" package`;
58 v
=`dpkg-deb -f -- "$1" version`;
59 r
=`dpkg-deb -f -- "$1" revision`;
62 r
=`dpkg-deb -f -- "$1" package_revision`;
70 a
=`dpkg-deb -f -- "$1" architecture`;
71 a
=`echo $a|sed -e 's/ *//g'`;
72 if [ -z "$a" -a -n "$noarchitecture" ]; # arch field empty, or ignored
74 a
=`dpkg --print-architecture`;
75 stderr
"assuming architecture \`"$a"' for \`"$1"'";
77 if [ -z "$noarchitecture" ];
84 name
=`echo $tname|sed -e 's/ //g'`
85 if [ "$tname" != "$name" ]; # control fields have spaces
87 stderr
"bad package control information for \`"$1"'"
94 if [ -z "$destinationdir" ];
99 s
=`dpkg-deb -f -- "$1" section`;
103 stderr
"assuming section \`"no-section
"' for \`"$1"'";
105 if [ "$s" != "non-free" -a "$s" != "contrib" -a "$s" != "no-section" ];
107 dir
=`echo unstable/binary-$a/$s`;
109 dir
=`echo $s/binary-$a`;
118 if fileexists
"$arg";
124 if [ -n "$createdir" ];
128 stderr
"created directory \`$dir'";
130 stderr
"failed creating directory \`$dir'";
134 stderr
"no such dir \`$dir'";
135 stderr
"try --create-dir (-c) option";
139 newname
=`echo $dir/$name`;
140 if [ $newname -ef "$1" ]; # same device and inode numbers
142 stderr
"skipping \`"$1"'";
143 elif [ -f $newname -a -z "$overwrite" ];
145 stderr
"can't move \`"$1"' to existing file";
146 elif `mv -- "$1" $newname`;
148 echo "moved \``basename "$1"`' to \`$newname'";
150 stderr
"mkdir can be used to create directory";
156 if [ $# = 0 ]; then usage
; exit 0; fi
159 if [ -n "$subdirset" ];
170 --version|
-v) show_version
; exit 0;;
171 --help|
-[h?
]) usage
; exit 0;;
172 --licen[cs
]e|
-l) license
; exit 0;;
173 --create-dir|
-c) createdir
=1;;
174 --subdir|
-s) subdirset
=1;;
175 --overwrite|
-o) overwrite
=1 ;;
176 --no-architecture|
-a) noarchitecture
=1 ;;