--- abcde-2.0.1.orig/debian/conffiles
+++ abcde-2.0.1/debian/conffiles
@@ -0,0 +1 @@
+/etc/abcde.conf
--- abcde-2.0.1.orig/debian/changelog
+++ abcde-2.0.1/debian/changelog
@@ -0,0 +1,468 @@
+abcde (2.0.1-1) unstable; urgency=low
+
+  * The I-Don't-Listen-To-Sssca Release
+  * Example abcde.conf fixes, closes: #111580
+  * So much for bladeenc's l3enc compatibility, closes: #110863
+  * CDDB submit fixes (to enable CDDB submitting, put
+    UNINTENTIONALLY_ANGER_THE_FREEDB_PEOPLE=y in your abcde.conf),
+    closes: #111478, #111500
+  * Minor mungefilename() cleanup
+  * Small manpage fix
+  * Works with oggenc when POSIXLY_CORRECT is defined, thanks to Juhapekka
+    Tolvanen
+  * Quote remote locations when calling distmp3
+  * Allow remote encoding of oggs
+  * Only remove wav files if the encoding succeeded
+  * No-local-encoding via -j 0 fixed, thanks to Hans-Joachim Baader
+  * CD read errors are trapped/resumed cleanly now thanks to Pete,
+    closes: #111618
+  * devfs device check fix, thanks to Clint Adams
+  * Check for seq command - some BSD's have jot instead and abcde can't
+    use that yet
+  * Various Artists playlist generation fixed, thanks to William Lash
+
+ -- Robert Woodcock <rcw@debian.org>  Tue,  6 Nov 2001 18:34:25 -0800
+
+abcde (2.0-1) unstable; urgency=low
+
+  * The Psychiatrist-Says-I'm-Stable-Again Release
+  * Renamed to 2.0
+  * Minor documentation updates
+
+ -- Robert Woodcock <rcw@debian.org>  Wed, 15 Aug 2001 15:26:54 -0700
+
+abcde (1.9.10-1) unstable; urgency=low
+
+  * The Waiter-There's-A-Proof-In-My-Pudding Release
+  * Fixed some quoting issues preventing abcde from using a temp directory
+    containing spaces, closes: #89682
+  * Now purges encodetracklocation notes from the status file when resuming.
+  * -a playlist now implies -a cddb
+  * Manpage and default config file updates, closes: #78726, #100841, #100845
+  * Applied checkstatus patch by Itai Zukerman, fixes certain track number
+    status checking situations, closes: #93395
+  * Check to see if things run through run_command return a nonzero error
+    code and present the command and error code to the user later,
+    closes: #93485
+  * Devfs fixup - If /dev/cdrom doesn't exist, try /dev/cdroms/cdrom0,
+    closes: #101933
+  * If a background process returned an error, log it. If it was an encode
+    process, abandon that encode location and don't wait for the encode
+    process to finish. Display the commandlines that resulted in error exits
+    with their exit codes before aborting.
+  * do_tag handles vorbis commenting failures idempotently
+  * -n works again
+  * Resumes encoding if all files have ripped, closes: #101843
+  * do_cddbedit code checks to see if it's already been run
+
+ -- Robert Woodcock <rcw@debian.org>  Wed,  1 Aug 2001 20:20:41 -0700
+
+abcde (1.9.9-1) unstable; urgency=low
+
+  * The Not-Quite-Last-In-The-Development-Series Release
+  * I broke ID3v1 comments in 1.9.8, it's fixed now, thanks to Christian
+    Beyerlein for noticing this, closes: #89519
+
+ -- Robert Woodcock <rcw@debian.org>  Tue, 13 Mar 2001 07:53:10 -0800
+
+abcde (1.9.8-1) unstable; urgency=low
+
+  * The Groundshaking Release
+  * Now defaults to using FreeDB instead of Gracenote. Pricks.
+  * New VAOUTPUTFORMAT variable for those who like their various artists
+    discs named in a different format
+  * Accomodates the fact that OpenBSD xargs does not eat whitespace, thanks
+    to Marcus Daniel for discovering this
+  * New scheduler for distmp3, thanks to David Bergeron
+  * xingmp3enc support, thanks to Brian Gannon
+  * Stripped down cddb-tool a little bit so that abcde no longer requires
+    mktemp
+  * New -C option to let people continue where they left off if they no
+    longer have the CD handy
+  * ID3COMMENT is now COMMENT
+  * Ogg commenting is now done separately so resuming doesn't break it
+  * More documentation updates
+
+ -- Robert Woodcock <rcw@debian.org>  Sat, 10 Mar 2001 22:51:39 -0800
+
+abcde (1.9.7-1) unstable; urgency=low
+
+  * The Overcast Partial Eclipse Release
+  * Supports ID3v2
+  * Various Artists heuristics patch by Kevin Everets
+  * New -c option to specify an extra configuration file, closes: #76252
+  * Does not try to check if a tagger exists unless OUTPUTTYPE=mp3,
+    closes: #78540
+  * cddb-tool template output fixes
+  * Yet more documentation updates, closes #78632, #78726
+  * Avoids id3v2's -c option for now
+  * Adds support for another Various Artists format, "Artist: Title", thanks
+    to Wolfgang Borgert, closes: #78292
+  * Fixed typo that was breaking remote encoding support, closes: #81183
+  * Hitting control-c while there's nothing in the foreground no longer
+    causes abcde to delete all its work upon exit
+
+ -- Robert Woodcock <rcw@debian.org>  Sun,  7 Jan 2001 21:17:32 -0800
+
+abcde (1.9.6-1) unstable; urgency=low
+
+  * The Squishy Release
+  * Updated getopts call to remove obsoleted options
+  * More documentation fixes, closes: #77957
+  * Single inexact match spurious question fix
+  * Fixed encoder trigger timing when using -l, closes: #77854
+
+ -- Robert Woodcock <rcw@debian.org>  Sun, 26 Nov 2000 18:37:18 -0800
+
+abcde (1.9.5-1) unstable; urgency=low
+
+  * The "Run Towards Trick Or Treaters With Scissors" Release
+  * Some documentation updates, closes: #75707, #75927
+  * mungefilename quoting fix, closes: #75556
+  * Implemented -a, which replaces -p, -P, and a number of other things,
+    closes: #75507
+
+ -- Robert Woodcock <rcw@debian.org>  Wed, 25 Oct 2000 21:16:38 -0700
+
+abcde (1.9.4-1) unstable; urgency=low
+
+  * The "Run With Scissors" Release
+  * Various Artists support by Kevin Everets
+  * Specifying track numbers on the command line should work again, bash was
+    getting a wee bit confuzzled with the way I had things before.
+  * A couple more error output changes and miscellaneous fixes
+  * OUTPUTDIR works again
+
+ -- Robert Woodcock <rcw@debian.org>  Thu, 28 Sep 2000 23:11:35 -0700
+
+abcde (1.9.3-1) unstable; urgency=low
+
+  * The ugh Release
+  * Brown Paper Bag fix for mp3enc users
+  * Recreated the rest of the variable environment in do_playlist, fixes
+    TRACKNUM availability for real this time, closes: #72535
+
+ -- Robert Woodcock <rcw@debian.org>  Tue, 26 Sep 2000 22:08:27 -0700
+
+abcde (1.9.2-1) unstable; urgency=low
+
+  * The "Very Long Changelog Entries Can Become Addicting" Release.
+  * Switched default output type to ogg, default encoder to oggenc
+  * Since 1.9.x prompts for CDDB edits by default there is now a -N switch
+    for non-interactivity.
+  * Handles cddb entries with random sprinklings of CR's and LF's
+  * You can now specify niceness for the reader and encoders, thanks to
+    Kevin Everets <kevin.everets@alcatel.com>
+  * -j 0 will now disable local encoding, thanks to Antonio Fiol
+    <Antonio.FIOL@enst-bretagne.fr>
+  * Vorbize should actually work now, thanks to Kevin Everets and James
+    LewisMoss
+  * Oggenc/Vorbize commenting support
+  * Made TRACKNUM available for playlist generation
+  * Fleshed out the TODO list a bit more
+  * mungefilename() now translates ':' to ' -' by default. Rationale: You
+    can't put ':' on a FAT filesystem. It also wreaks havoc with Samba.
+
+ -- Robert Woodcock <rcw@debian.org>  Mon, 25 Sep 2000 19:31:35 -0700
+
+abcde (1.9.1-1) unstable; urgency=low
+
+  * The "Don't Fraun" Release.
+  * Fixed a half-dozen minor buglets
+  * A little less debug output, a lot more normal output
+  * Resuming operation works better now
+  * Patched up offline usage again
+  * Broke OUTPUTFORMAT - if you plan on ever using Ogg support, and you've
+    overridden the OUTPUTFORMAT default, change the ".mp3" to
+    ".${OUTPUTTYPE}"
+  * Beginnings of Ogg Vorbis support (vorbize and oggenc) - warning:
+    completely untested
+
+ -- Robert Woodcock <rcw@debian.org>  Thu, 17 Aug 2000 21:03:00 -0700
+
+abcde (1.9-1) unstable; urgency=low
+
+  * The "" Release.
+  * Completely redone tmpfile handling, abcde can now continue where you left
+    off. closes: #42970, #50883, #66668
+  * Restructured program execution scheduling around central status file
+  * Moved cddb-tool interactivity to abcde, 'cddb-tool get' no longer exists,
+    it is now 'cddb-tool query' and 'cddb-tool read'.
+  * Removed -e, -v, and -V, since abcde will now prompt you if you want to
+    edit or otherwise muck with the data after you have a chance to see it.
+
+ -- Robert Woodcock <rcw@debian.org>  Thu, 22 Jun 2000 18:13:01 -0700
+
+abcde (1.1.1-1) unstable; urgency=low
+
+  * The "That wasn't chicken" Release.
+  * Remote distributed encoding had a bad bug in 1.1 - work to be done
+    remotely was duplicated locally (everything still turned out ok -
+    there was just no speedup). Fixed that.
+  * Restructured encode_and_tag function.
+
+ -- Robert Woodcock <rcw@debian.org>  Sun,  7 May 2000 20:10:10 -0700
+
+abcde (1.1-1) unstable; urgency=low
+
+  * The "We heard Mr. Garrison say them a couple of times" Release.
+  * New -r and REMOTEHOSTS option to use distmp3 to encode to multiple
+    hosts at once.
+  * Command-line track range specification (f.e. "abcde 1-12"
+    (Thanks: Vincent Ho)
+  * Now displays minutes/seconds for each track while displaying track titles
+    at the start
+
+ -- Robert Woodcock <rcw@debian.org>  Tue, 18 Apr 2000 23:59:09 -0700
+
+abcde (1.0.6-1) unstable; urgency=low
+
+  * The "Inspected by #17" Release.
+  * New EJECTCD option to eject the CD after all tracks are read (thanks:
+    Hrafnkell F Hlodversson)
+
+ -- Robert Woodcock <rcw@debian.org>  Sun,  2 Apr 2000 23:23:44 -0700
+
+abcde (1.0.5-1) unstable; urgency=low
+
+  * The "...So we can both watch X-Files..." Release.
+  * Quoting fix for setups without space->underscore filename munging
+  * README file URL fixes/updates
+
+ -- Robert Woodcock <rcw@debian.org>  Thu, 16 Mar 2000 18:34:38 -0800
+
+abcde (1.0.4-1) unstable; urgency=low
+
+  * The "Plop, Plop, Fizz Fizz" Release
+  * CDPARANOIAOPTS and CDDA2WAVOPTS should work now.
+
+ -- Robert Woodcock <rcw@debian.org>  Sun, 20 Feb 2000 18:44:08 -0800
+
+abcde (1.0.3-1) unstable; urgency=low
+
+  * The "This Space Intentionally Left Blank" Release
+  * Support for reverse and dashed Various Artists discs
+  * More elegant way of passing backtick data
+  * Replaced all `foo` commands with $(foo)
+  * Custom filename munging, closes: #38448
+
+ -- Robert Woodcock <rcw@debian.org>  Wed,  9 Feb 2000 20:26:22 -0800
+
+abcde (1.0.2-1) unstable; urgency=low
+
+  * Now eats backticks in CDDB input (thanks to Steve Beattie)
+  * mp3enc support (thanks to Richard Jelinek and Chris Ruvolo),
+    closes: #56189
+  * cddb-tool more gracefully handles no net connection for those with
+    local caching name servers
+  * Fixed HELLOINFO documentation bug, closes: #56268
+
+ -- Robert Woodcock <rcw@debian.org>  Wed, 26 Jan 2000 19:45:06 -0800
+
+abcde (1.0.1-1) unstable; urgency=low
+
+  * The "s/ever/ Three Days/" Release
+  * Now properly handles double-quotes in Artist and Album data
+    (thanks to Clint Adams), closes: #54888
+
+ -- Robert Woodcock <rcw@debian.org>  Thu, 13 Jan 2000 23:34:24 -0800
+
+abcde (1.0-1) unstable; urgency=low
+
+  * The "But a 1.0 is Forever" Release
+  * Backed out cddb-tool quoting change, closes: #54005
+  * Now strips carriage returns from CDDB data, closes: #53815
+  * Added ID3COMMENT config option
+
+ -- Robert Woodcock <rcw@debian.org>  Mon, 10 Jan 2000 20:48:24 -0800
+
+abcde (0.8.9-1) unstable; urgency=low
+
+  * The "Get it Before the World Implodes" Release
+  * Added -D (debugging option, outputs debugging information to stderr).
+    Very useful for submitting bug reports, hint hint hint :)
+    Just do 'abcde -D 2>logfile' and include logfile in your bug report.
+  * Now uses id3's new -T option to embed track numbers in ID3 tags.
+  * Fixed cddb-tool output for FreeDB submissions, closes: #51986.
+    Thanks to Clint Adams for spotting the problem
+  * New -v switch for Various Artist CD's (thanks to Magenta Hari Nezumi)
+    closes: #43581
+  * Fixed minor cddb-tool manpage buglet
+  * Fixed cddb-tool output for shell quoting, thanks to Philipp Meier.
+    closes: #52469
+
+ -- Robert Woodcock <rcw@debian.org>  Fri, 31 Dec 1999 14:12:35 -0800
+
+abcde (0.8.8-1) unstable; urgency=low
+
+  * Added gogo explainations to manpages and example config file
+  * Added code by Stuart Ballard <sballard@netreach.net> to intelligently
+    use relative paths for playlist files, closes #51351
+  * Added PLAYLISTDATAPREFIX config option for those who wish to prefix
+    their playlist data with things like URL's
+  * Fixed bug added in 0.8 where the multiple inexact match choice
+    selection would be hidden to the user (cddb-tool wasn't sending all
+    user output to stderr as it should), closes #51434, #50786
+
+ -- Robert Woodcock <rcw@debian.org>  Sun, 28 Nov 1999 16:02:24 -0800
+
+abcde (0.8.7-1) unstable; urgency=low
+
+  * Removed some parallelization from encode_and_tag, closes: #50246
+
+ -- Robert Woodcock <rcw@debian.org>  Tue, 16 Nov 1999 18:49:29 -0800
+
+abcde (0.8.6-1) unstable; urgency=low
+
+  * Removed remaining bashisms
+
+ -- Robert Woodcock <rcw@debian.org>  Sun, 14 Nov 1999 08:46:14 -0800
+
+abcde (0.8.5-1) unstable; urgency=low
+
+  * Fixed some background encoding issues that cropped up in 0.8.3.
+
+ -- Robert Woodcock <rcw@debian.org>  Sun,  7 Nov 1999 01:08:27 -0800
+
+abcde (0.8.4-1) unstable; urgency=low
+
+  * New name. cdgrab was already taken - the original cdgrab name
+    belongs to a CDDA reading program for DOS dating back to 1993.
+    It's still in use and active development, so I'm changing the
+    name of cdgrab instead. See this URL for a description of the
+    original cdgrab: http://www.scn.rain.com/pub/cdrom/cdgrab.txt
+
+    Your old /etc/cdgrab.conf and/or ~/.cdgrab.conf can simply be
+    renamed to /etc/abcde.conf and ~/.abcde.conf.
+
+    The program name is now 'abcde'.
+
+ -- Robert Woodcock <rcw@debian.org>  Tue,  2 Nov 1999 22:28:19 -0800
+
+cdgrab (0.8.3-1) unstable; urgency=low
+
+  * 0.8.2 would leave around cdgrab.xxxxxx tempfiles with -j.
+    Fixed that.
+  * Fixed quoting issues regarding spaces in output files
+    closes: #38449
+
+ -- Robert Woodcock <rcw@debian.org>  Thu, 28 Oct 1999 20:08:22 -0700
+
+cdgrab (0.8.2-1) unstable; urgency=low
+
+  * Fixes a cddb-tool quoting issue - closes: #46979
+  * Adds support for gogo
+
+ -- Robert Woodcock <rcw@debian.org>  Sun, 10 Oct 1999 11:24:50 -0700
+
+cdgrab (0.8.1-1) unstable; urgency=low
+
+  * Clears up a few bashisms from the merged-in cddb-tool patches
+    closes: #45512, #45514
+  * FHS compliance
+
+ -- Robert Woodcock <rcw@debian.org>  Sun, 19 Sep 1999 12:21:40 -0700
+
+cdgrab (0.8-1) unstable; urgency=low
+
+  * New Release - closes: #43579, #42997, #38325, #42971
+  * Removes dependancy for now non-existant cdparanoia-bin package
+
+ -- Robert Woodcock <rcw@debian.org>  Thu, 26 Aug 1999 22:34:29 -0700
+
+cdgrab (0.7.7-1) unstable; urgency=low
+
+  * one-liner patch re-release :)
+
+ -- Robert Woodcock <rcw@debian.org>  Thu, 12 Aug 1999 07:29:50 -0700
+
+cdgrab (0.7.6-1) unstable; urgency=low
+
+  * New Release - closes: #42734
+
+ -- Robert Woodcock <rcw@debian.org>  Mon,  9 Aug 1999 21:11:30 -0700
+
+cdgrab (0.7.5-1) unstable; urgency=low
+
+  * New Release - closes: #40179, #41086
+
+ -- Robert Woodcock <rcw@debian.org>  Tue, 13 Jul 1999 19:20:53 -0700
+
+cdgrab (0.7.4-1) unstable; urgency=low
+
+  * New Release
+
+ -- Robert Woodcock <rcw@debian.org>  Mon,  7 Jun 1999 22:12:20 -0700
+
+cdgrab (0.7.3-1) unstable; urgency=low
+
+  * New Release
+
+ -- Robert Woodcock <rcw@debian.org>  Sun, 23 May 1999 22:24:43 -0700
+
+cdgrab (0.7.2-1) unstable; urgency=low
+
+  * New Release
+
+ -- Robert Woodcock <rcw@debian.org>  Sun, 16 May 1999 17:41:55 -0700
+
+cdgrab (0.7.1-1) unstable; urgency=low
+
+  * New release
+
+ -- Robert Woodcock <rcw@debian.org>  Fri, 14 May 1999 23:37:00 -0700
+
+cdgrab (0.7-1) unstable; urgency=low
+
+  * New release
+  * cd-discid spun off into its own package, cdgrab is now
+    Architecture: all
+
+ -- Robert Woodcock <rcw@debian.org>  Fri,  7 May 1999 20:44:06 -0700
+
+cdgrab (0.6.2-1) unstable; urgency=low
+
+  * New release, closes: bug #35379, bug #36272
+
+ -- Robert Woodcock <rcw@debian.org>  Sun, 18 Apr 1999 15:09:43 -0700
+
+cdgrab (0.6.1-1) unstable; urgency=low
+
+  * New release, quick bashism bugfix - closes: bug #35245
+
+ -- Robert Woodcock <rcw@debian.org>  Mon, 29 Mar 1999 19:19:04 -0800
+
+cdgrab (0.6-1) unstable; urgency=low
+
+  * New release - closes: bug #34454, #34736, #34823, #34824
+
+ -- Robert Woodcock <rcw@debian.org>  Sun, 28 Mar 1999 18:26:54 -0800
+
+cdgrab (0.5-1) unstable; urgency=low
+
+  * New release
+
+ -- Robert Woodcock <rcw@debian.org>  Thu, 18 Mar 1999 23:39:02 -0800
+
+cdgrab (0.4-1) unstable; urgency=low
+
+  * New release - closes: bug #34566, #34577
+
+ -- Robert Woodcock <rcw@debian.org>  Tue, 16 Mar 1999 00:10:20 -0800
+
+cdgrab (0.3-1) unstable; urgency=low
+
+  * New release - closes: bug #34101
+
+ -- Robert Woodcock <rcw@debian.org>  Fri,  5 Mar 1999 18:13:30 -0800
+
+cdgrab (0.2-1) unstable; urgency=low
+
+  * Initial Release.
+
+ -- Robert Woodcock <rcw@debian.org>  Sun, 21 Feb 1999 18:50:34 -0800
+
+Local variables:
+mode: debian-changelog
+add-log-mailing-address: "rcw@debian.org"
+End:
--- abcde-2.0.1.orig/debian/copyright
+++ abcde-2.0.1/debian/copyright
@@ -0,0 +1,19 @@
+This package was debianized by Robert Woodcock <rcw@debian.org> on
+Sun, 21 Feb 1999 18:50:34 -0800.
+
+It is available at: http://lly.org/~rcw/abcde/
+
+Upstream Author: me :)
+
+Copyright:
+
+Copyright (c) 1998-2001 Robert Woodcock <rcw@debian.org>
+This code is hereby licensed for public consumption under either the
+GNU GPL v2 or greater, or Larry Wall's Artistic license - your choice.
+
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+Copyright for this work is to expire January 1, 2010, after which it
+shall be public domain.
--- abcde-2.0.1.orig/debian/dirs
+++ abcde-2.0.1/debian/dirs
@@ -0,0 +1,2 @@
+etc
+usr/bin
--- abcde-2.0.1.orig/debian/docs
+++ abcde-2.0.1/debian/docs
@@ -0,0 +1,4 @@
+README
+changelog
+TODO
+
--- abcde-2.0.1.orig/debian/preinst
+++ abcde-2.0.1/debian/preinst
@@ -0,0 +1,26 @@
+#!/bin/sh
+# If:
+# * this isn't an upgrade (a fresh install)
+# * and /etc/cdgrab.conf exists
+# * and /etc/abcde.conf doesn't
+# copy /etc/cdgrab.conf to /etc/abcde.conf
+
+if [ "$1" != "install" ]
+then
+	exit 0
+fi
+if [ "$2" != "" ]
+then
+	exit 0
+fi
+if [ -f /etc/abcde.conf ]
+then
+	exit 0
+fi
+if [ -r /etc/cdgrab.conf ]
+then
+	echo Copying old /etc/cdgrab.conf to /etc/abcde.conf...
+	cp -a /etc/cdgrab.conf /etc/abcde.conf
+	exit 0
+fi
+#DEBHELPER#
--- abcde-2.0.1.orig/debian/control
+++ abcde-2.0.1/debian/control
@@ -0,0 +1,19 @@
+Source: abcde
+Section: sound
+Priority: optional
+Maintainer: Robert Woodcock <abcde@whimsica.lly.org>
+Standards-Version: 3.5.5
+Build-Depends: debhelper
+
+Package: abcde
+Architecture: all
+Depends: cd-discid, wget, cdparanoia | cdda2wav, vorbis-tools (>= 1.0beta4-1)
+Conflicts: cdgrab
+Replaces: cdgrab
+Provides: cdgrab
+Suggests: eject, distmp3, id3 (>= 0.12), id3v2
+Description: A Better CD Encoder
+ A frontend program to cdparanoia, wget, cd-discid, id3, and your favorite
+ Ogg or MP3 encoder (defaults to oggenc). Grabs an entire CD and converts
+ each track to Ogg or MP3, then comments or ID3-tags each file, with one
+ command.
--- abcde-2.0.1.orig/debian/rules
+++ abcde-2.0.1/debian/rules
@@ -0,0 +1,74 @@
+#!/usr/bin/make -f
+# Made with the aid of dh_make, by Craig Small
+# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
+# Some lines taken from debmake, by Cristoph Lameter.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+build: build-stamp
+build-stamp:
+	dh_testdir
+
+	
+	# Add here commands to compile the package.
+	$(MAKE) 
+
+	touch build-stamp
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp install-stamp
+
+	# Add here commands to clean up after the build process.
+	-$(MAKE) clean
+
+	dh_clean
+
+install: install-stamp
+install-stamp: build-stamp
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs
+
+	# Add here commands to install the package into debian/tmp.
+	$(MAKE) install DESTDIR=`pwd`/debian/tmp
+
+	touch install-stamp
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+#	dh_testversion
+	dh_testdir
+	dh_testroot
+	dh_installdocs
+	dh_installexamples
+	dh_installmenu
+#	dh_installemacsen
+#	dh_installinit
+	dh_installcron
+	dh_installmanpages
+#	dh_undocumented
+	dh_installchangelogs 
+	dh_link
+	dh_strip
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+#	dh_makeshlibs
+	dh_md5sums
+	dh_builddeb
+
+source diff:                                                                  
+	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary
--- abcde-2.0.1.orig/abcde.smpfixes
+++ abcde-2.0.1/abcde.smpfixes
@@ -0,0 +1,1332 @@
+#!/bin/sh
+# Copyright (c) 1998-2001 Robert Woodcock <rcw@debian.org>
+# This code is hereby licensed for public consumption under either the
+# GNU GPL v2 or greater, or Larry Wall's Artistic license - your choice.
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# 
+# Copyright for this work is to expire January 1, 2010, after which it
+# shall be public domain.
+
+VERSION=2.0.1
+
+usage ()
+{
+echo "This is abcde v$VERSION."
+echo "Usage: abcde [options] [tracks]"
+echo "Options:"
+echo "-a    Specify actions to perform (cddb,read,encode,tag,move,playlist,clean)"
+echo "-c    Specify a configuration file (overrides system and user config files)"
+echo "-C    Specify discid to resume from (only needed if you no longer have the cd)"
+echo "-d    Specify CDROM device to grab"
+echo "-D    Debugging mode (equivalent to sh -x abcde)"
+echo "-h    This help information"
+echo "-j    Number of encoder processes to run at once"
+echo "-l    Use low disk space algorithm"
+echo "-n    No lookup. Don't query CDDB, just create and use template"
+echo "-N    Noninteractive. Never prompt for anything"
+echo "-o    Output file type - either \"ogg\" or \"mp3\""
+echo "-r    [host1,host2...] Also encode on these remote hosts"
+echo "-x    Eject CD after all tracks are read"
+echo "Tracks is a space-delimited list of tracks to grab."
+echo "Ranges specified with hyphens are allowed."
+}
+
+# checkstatus [blurb]
+# Returns "0" if the blurb was found, returns 1 if it wasn't
+# Puts the blurb content, if available, on stdout.
+# Otherwise, returns "".
+checkstatus ()
+{
+	# Take the last line in the status file if there's multiple matches
+	PATTERN="^$1(=.*)?$"
+	BLURB=$(egrep $PATTERN "$ABCDETEMPDIR/status" | tail -1)
+
+	if [ -z "$BLURB" ]; then
+		# No matches found
+		return 1
+	else
+		# Matches found
+		# See if there's a = in it
+		if [ "$(echo $BLURB | grep -c =)" != "0" ]; then
+			echo "$(echo $BLURB | cut -f2- -d=)"
+		fi
+		return 0
+	fi
+}
+
+# checkerrors [blurb]
+# Returns "0" if the blurb was found (meaning there was an error),
+# returns 1 if it wasn't (yes this is a little backwards).
+# Does not print the blurb on stdout.
+# Otherwise, returns "".
+checkerrors ()
+{
+	if [ \! -e "$ABCDETEMPDIR/errors" ]; then
+		return 1
+	fi
+	# Take the last line in the status file if there's multiple matches
+	PATTERN="^$1(:.*)?$"
+	BLURB="$(egrep $PATTERN $ABCDETEMPDIR/errors | tail -1)"
+
+	if [ -z "$BLURB" ]; then
+		# negative, we did not have a negative...
+		return 1
+	else
+		# affirmative, we had a negative...
+		return 0
+	fi
+}
+
+# run_command [blurb] [command...]
+# Runs a command, silently if necessary, and updates the status file
+run_command ()
+{
+	BLURB="$1"
+	shift
+	# See if this is supposed to be silent
+	if [ "$(checkstatus encode-output)" = "loud" ]; then
+		"$@" >&2
+		RETURN=$?
+	else
+		"$@" >/dev/null 2>&1
+		RETURN=$?
+	fi
+	if [ "$RETURN" != "0" ]; then
+		# Put an error in the errors file. For various reasons we
+		# can't capture a copy of the program's output but we can
+		# log what we attempted to execute and the error code
+		# returned by the program.
+		if [ "$BLURB" ]; then
+			TWEAK="$BLURB: "
+		fi
+		echo "${TWEAK}returned code $RETURN: $@" >> "$ABCDETEMPDIR/errors"
+		return $RETURN # Do not pass go, do not update the status file
+	fi
+	if [ "$BLURB" ]; then
+		echo $BLURB >> "$ABCDETEMPDIR/status"
+	fi
+}
+
+# relpath() and slash() are Copyright (c) 1999 Stuart Ballard and
+# distributed under the terms of the GNU GPL v2 or later, at your option
+
+# Function to determine if a word contains a slash.
+slash ()
+{
+	case "$1" in
+	*/*) return 0;;
+	*) return 1;;
+	esac
+}
+
+# Function to give the relative path from one file to another.
+# Usage: relpath fromfile tofile
+# eg relpath music/Artist/Album.m3u music/Artist/Album/Song.mp3
+# (the result would be Album/Song.mp3)
+# Output is relative path to $2 from $1 on stdout
+
+# This code has the following restrictions:
+# Multiple ////s are not collapsed into single /s, with strange effects.
+# Absolute paths and ../s are handled wrong in FR (but they work in TO)
+# If FR is a directory it must have a trailing /
+
+relpath ()
+{
+	FR="$1"
+	TO="$2"
+	
+	case "$TO" in
+	/*) ;; # No processing is needed for absolute paths
+	*)
+		# Loop through common prefixes, ignoring them.
+		while slash "$FR" && [ "$(echo "$FR" | cut -d/ -f1)" = "$(echo "$TO" | cut -d/ -f1)" ]
+		do
+			FR="$(echo "$FR" | cut -d/ -f2-)"
+			TO="$(echo "$TO" | cut -d/ -f2-)"
+		done
+		# Loop through directory portions left in FR, adding appropriate ../s.
+		while slash "$FR"
+		do
+			FR="$(echo "$FR" | cut -d/ -f2-)"
+			TO="../$TO"
+		done
+	esac
+	
+	echo $TO
+}
+
+# This code splits the a Various Artist track name from one of the following
+# forms:
+#
+#  forward:      Artist / Track
+#  forward-dash: Artist - Track
+#  reverse:      Track / Artist
+#  reverse-dash: Track - Artist
+#  colon:        Artist: Track
+#
+# variables used:
+# VARIOUSARTISTS, VARIOUSARTISTSTYLE, TRACKNAME, TRACKARTIST
+splitvarious ()
+{
+#	set +e
+	if [ "$VARIOUSARTISTS" = "y" ]; then
+		case "$VARIOUSARTISTSTYLE" in
+		forward)
+			DTITLEARTIST="$(echo $TRACKNAME | sed 's- / -~-g')"
+			TRACKARTIST="$(echo $DTITLEARTIST | cut -f1 -d~)"
+			TRACKNAME="$(echo $DTITLEARTIST | cut -f2 -d~)"
+			;;
+		forward-dash)
+			DTITLEARTIST="$(echo $TRACKNAME | sed 's, - ,~,g')"
+			TRACKARTIST="$(echo $DTITLEARTIST | cut -f1 -d~)"
+			TRACKNAME="$(echo $DTITLEARTIST | cut -f2 -d~)"
+			;;
+		reverse)
+			DTITLEARTIST="$(echo $TRACKNAME | sed 's- / -~-g')"
+			TRACKARTIST="$(echo $DTITLEARTIST | cut -f2 -d~)"
+			TRACKNAME="$(echo $DTITLEARTIST | cut -f1 -d~)"
+			;;
+		reverse-dash)
+			DTITLEARTIST="$(echo $TRACKNAME | sed 's, - ,~,g')"
+			TRACKARTIST="$(echo $DTITLEARTIST | cut -f2 -d~)"
+			TRACKNAME="$(echo $DTITLEARTIST | cut -f1 -d~)"
+			;;
+		colon)
+			DTITLEARTIST="$(echo $TRACKNAME | sed 's-: -~-g')"
+			TRACKARTIST="$(echo $DTITLEARTIST | cut -f1 -d~)"
+			TRACKNAME="$(echo $DTITLEARTIST | cut -f2 -d~)"
+			;;
+		esac
+	else
+		TRACKARTIST=$DARTIST
+	fi
+}
+
+# do_tag [tracknumber]
+# id3 tags a filename
+# variables used:
+# TRACKS, TRACKNAME, TRACKARTIST, TAGGER, TAGGEROPTS, COMMENT, DALBUM, DARTIST
+# (and temporarily) ID3TAGV
+do_tag ()
+{
+	COMMENTOUTPUT="$(eval echo ${COMMENT})"
+	run_command '' echo "Tagging track $1 of $TRACKS: $TRACKNAME..."
+	if [ "$OUTPUTTYPE" = "mp3" ]; then
+		# Amazingly, id3 and id3v2 have identical -a, -A, -c, -t, and -T switches
+		# ...except id3v2's -c is completely broken (there's a bug in id3lib
+		# v3.7.x keeping -c from being properly implemented)
+		if [ "$ID3TAGV" = "2" ]; then
+			run_command tagtrack-$1 $TAGGER $TAGGEROPTS -A "$DALBUM" -a "$TRACKARTIST" \
+				-t "$TRACKNAME" -T "$1" "$ABCDETEMPDIR/track$1.$OUTPUTTYPE"
+		else
+			run_command tagtrack-$1 $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \
+				-A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -T "$1" "$ABCDETEMPDIR/track$1.$OUTPUTTYPE"
+		fi
+	else
+		# vorbiscomment can't do in-place modification, mv the file first
+		if [ -f "$ABCDETEMPDIR/track$1.$OUTPUTTYPE" -a \! -f "$ABCDETEMPDIR/track$1.uncommented.$OUTPUTTYPE" ]; then
+			mv "$ABCDETEMPDIR/track$1.$OUTPUTTYPE" "$ABCDETEMPDIR/track$1.uncommented.$OUTPUTTYPE"
+		fi
+		(
+		# These are from http://www.xiph.org/ogg/vorbis/doc/v-comment.html
+		echo ARTIST=$TRACKARTIST
+		echo ALBUM=$DALBUM
+		echo TITLE=$TRACKNAME
+		echo TRACKNUMBER=$1
+		if [ "$(eval echo ${COMMENT})" != "" ]; then
+			echo $DESCRIPTION=$COMMENTOUTPUT;
+		fi
+		) | run_command tagtrack-$1 $VORBISCOMMENT -w \
+			"$ABCDETEMPDIR/track$1.uncommented.$OUTPUTTYPE" "$ABCDETEMPDIR/track$1.$OUTPUTTYPE"
+		# Doublecheck that the commented file was created successfully before wiping the original
+		if [ -f "$ABCDETEMPDIR/track$1.$OUTPUTTYPE" ]; then
+			rm -f "$ABCDETEMPDIR/track$1.uncommented.$OUTPUTTYPE"
+		else
+			mv "$ABCDETEMPDIR/track$1.uncommented.$OUTPUTTYPE" "$ABCDETEMPDIR/track$1.$OUTPUTTYPE"
+		fi
+	fi
+}
+
+# do_encode [tracknumber] [hostname]
+# If no hostname is specified, encode locally
+# variables used:
+# TRACKS, TRACKNAME, TRACKARTIST, DISTMP3, DISTMP3OPTS, ENCODERSYNTAX, OUTPUTTYPE, ENCODEROPTS, DALBUM, DARTIST, ENCNICE
+do_encode ()
+{
+	IN="$ABCDETEMPDIR/track$1.wav"
+	OUT="$ABCDETEMPDIR/track$1.$OUTPUTTYPE"
+	run_command '' echo "Encoding track $1 of $TRACKS: $TRACKNAME..."
+	case "$OUTPUTTYPE" in
+	mp3)
+		if [ "$2" = "%local%" ]; then
+			case "$ENCODERSYNTAX" in
+			lame|gogo) run_command encodetrack-$1 nice $ENCNICE $ENCODER $ENCODEROPTS "$IN" "$OUT" ;;
+			bladeenc) run_command encodetrack-$1 nice $ENCNICE $ENCODER $ENCODEROPTS "$IN" -quit ;;
+			l3enc|xingmp3enc) run_command encodetrack-$1 nice $ENCNICE $ENCODER "$IN" "$OUT" $ENCODEROPTS ;;
+			mp3enc) run_command encodetrack-$1 nice $ENCNICE $ENCODER -if "$IN" -of "$OUT" $ENCODEROPTS ;;
+			esac
+		else
+			run_command encodetrack-$1 $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" >/dev/null 2>&1
+		fi
+		;;
+	ogg)
+		if [ "$2" = "%local%" ]; then
+			case "$ENCODERSYNTAX" in
+			vorbize) run_command encodetrack-$1 nice $ENCNICE $ENCODER $ENCODEROPTS -w "$OUT" "$IN" ;;
+			oggenc) run_command encodetrack-$1 nice $ENCNICE $ENCODER $ENCODEROPTS -o "$OUT" "$IN" ;;
+			esac
+		else
+			run_command encodetrack-$1 $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" >/dev/null 2>&1
+		fi
+		;;
+	esac
+	# Only remove .wav if the encoding succeeded
+	if checkerrors encodetrack-$1; then :; else
+		rm -f "$IN"
+	fi
+}
+
+# do_move [tracknumber]
+# Deduces the outfile from environment variables
+# Creates directory if necessary
+# variables used:
+# TRACKNUM, TRACKNAME, TRACKARTIST, DALBUM, OUTPUTFORMAT
+do_move ()
+{
+	# Create ALBUMFILE, ARTISTFILE, TRACKFILE
+	# Munge filenames as follows: 
+	# ' ' -> '_'
+	# '/' -> '_'
+	# ''' -> ''
+	# '?' -> ''
+	# Eat control characters
+	ALBUMFILE=$(mungefilename "$DALBUM")
+	ARTISTFILE=$(mungefilename "$TRACKARTIST")
+	TRACKFILE=$(mungefilename "$TRACKNAME")
+	# Supported variables for OUTPUTFORMAT are ALBUMFILE, ARTISTFILE, TRACKFILE, and TRACKNUM.
+	if [ "$VARIOUSARTISTS" = "y" ]; then
+		OUTPUTFILE=$(eval echo $VAOUTPUTFORMAT)
+	else
+		OUTPUTFILE=$(eval echo $OUTPUTFORMAT)
+	fi
+
+	# Check that the directory for OUTPUTFILE exists, if it doesn't, create it
+	OUTPUTFILEDIR=$(dirname "$OUTPUTDIR/$OUTPUTFILE")
+	if [ \! -d "$OUTPUTFILEDIR" ]; then
+		mkdir -p "$OUTPUTFILEDIR"
+	fi
+	run_command movetrack-$1 mv "$ABCDETEMPDIR/track$1.$OUTPUTTYPE" "$OUTPUTDIR/$OUTPUTFILE"
+}
+
+# do_playlist
+# Create the playlist if wanted
+# Variables used:
+# PLAYLISTFORMAT, PLAYLISTDATAPREFIX, OUTPUTDIR, 
+do_playlist ()
+{
+	# Create a playlist file for the playlist data to go into, wiping it out if
+	# it exists already
+	for LASTTRACK in $TRACKQUEUE; do :; done
+	# get the number of digits to pad TRACKNUM with - we'll use this later
+	TRACKNUMPADDING=$(echo -n $LASTTRACK | wc -c | tr -d ' ')
+	ALBUMFILE=$(mungefilename "$DALBUM")
+	ARTISTFILE=$(mungefilename "$DARTIST")
+	PLAYLISTFILE=$(eval echo $PLAYLISTFORMAT)
+	FINALPLAYLISTDIR=$(dirname "$OUTPUTDIR/$PLAYLISTFILE")
+	if [ \! -e "$FINALPLAYLISTDIR" ]; then
+		mkdir -p "$FINALPLAYLISTDIR"
+	fi
+	rm -f "$OUTPUTDIR/$PLAYLISTFILE"
+	touch "$OUTPUTDIR/$PLAYLISTFILE"
+	for UTRACKNUM in $TRACKQUEUE
+	do
+		# Shares some code with do_move since the filenames have to match
+		CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
+		TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -1 | cut -f2 -d= | tr -d \[:cntrl:\])
+		splitvarious
+		TRACKFILE=$(mungefilename "$TRACKNAME")
+		ARTISTFILE=$(mungefilename "$TRACKARTIST")
+		TRACKNUM=$(printf %0.${TRACKNUMPADDING}d ${UTRACKNUM})
+		OUTPUTFILE=$(eval echo $OUTPUTFORMAT)
+		if [ "$PLAYLISTDATAPREFIX" ]; then
+			echo -n $PLAYLISTDATAPREFIX >> "$OUTPUTDIR/$PLAYLISTFILE"
+		fi
+		relpath "$PLAYLISTFILE", "$OUTPUTFILE" >> "$OUTPUTDIR/$PLAYLISTFILE"
+	done
+	echo "playlistcomplete" >> "$ABCDETEMPDIR/status"
+}
+
+# do_discid
+# This essentially the start of things
+do_discid ()
+{
+	# Query the CD to get the track info, unless the user specified -C
+	if [ -z "$DISCID" ]; then
+		echo -n "Getting CD track info... "
+		TRACKINFO=$($CDDISCID $CDROM)
+		# Make sure there's a CD in there by checking cd-discid's return code
+		if [ "$?" = "1" ]; then
+			echo "abcde error: CD could not be read. Perhaps there's no CD in the drive?" >&2
+			exit 1
+		fi
+	else
+		TRACKINFO=$(cat abcde.$DISCID/discid)
+	fi
+	
+	# Get a full enumeration of tracks, sort it, and put it in the TRACKQUEUE.
+	# This needs to be done now because a section of the resuming code will need
+	# it later.
+	
+	TRACKS=$(echo $TRACKINFO | cut -f2 -d' ')
+	
+	if [ -z "$TRACKQUEUE" ]; then
+		echo -n "Grabbing entire CD - tracks: "
+		X=0
+		while [ "$X" != "$TRACKS" ]
+		do
+			X=$(expr $X + 1)
+			TRACKQUEUE=$(echo "$TRACKQUEUE" $X)
+		done
+		echo $TRACKQUEUE
+	else
+		# User-supplied track queue.
+		# Weed out non-numbers, whitespace, then sort and weed out duplicates
+		TRACKQUEUE=$(echo $TRACKQUEUE | sed 's-[^0-9 ]--g' | tr ' ' '\n' | grep -v ^$ | sort -n | uniq | tr '\n' ' ' | sed 's- $--g')
+		echo Grabbing tracks: "$TRACKQUEUE"
+	fi
+	
+	for LASTTRACK in $TRACKQUEUE; do :; done
+	# get the number of digits to pad TRACKNUM with - we'll use this later
+	TRACKNUMPADDING=$(echo -n $LASTTRACK | wc -c | tr -d ' ')
+
+	QUEUEDTRACKS=$(echo $TRACKQUEUE | wc -w | tr -d ' ')
+
+	# We have the discid, create a temp directory after it to store all the temp
+	# info
+	
+	ABCDETEMPDIR="$WAVOUTPUTDIR/abcde.$(echo $TRACKINFO | cut -f1 -d' ')"
+	if [ -e "$ABCDETEMPDIR" ]; then
+		echo -n "abcde: attempting to resume from $ABCDETEMPDIR"
+		# It already exists, see if it's a directory
+		if [ \! -d "$ABCDETEMPDIR" ]; then
+			# This is a file/socket/fifo/device/etc, not a directory
+			# Complain and exit
+			echo >&2
+			echo "abcde: file $ABCDETEMPDIR already exists and does not belong to abcde." >&2
+			echo "Please investigate, remove it, and rerun abcde." >&2
+			exit 1
+		fi
+		echo -n .
+		# It's a directory, let's see if it's owned by us
+		if [ \! -O "$ABCDETEMPDIR" ]; then
+			# Nope, complain and exit
+			echo >&2
+			echo "abcde: directory $ABCDETEMPDIR already exists and is not owned by you." >&2
+			echo "Please investigate, remove it, and rerun abcde." >&2
+			exit 1
+		fi
+		echo .
+		# See if it's populated
+		if [ \! -f "$ABCDETEMPDIR/discid" ]; then
+			# Wipe and start fresh
+			echo "abcde: $ABCDETEMPDIR/discid not found. Abcde must remove and recreate" >&2
+			echo -n "this directory to continue. Continue? [y/n] " >&2
+			if [ "$INTERACTIVE" = "y" ]; then
+				read ANSWER
+			else
+				echo y >&2
+				ANSWER=y
+			fi
+			if [ "$ANSWER" != "y" ]; then
+				exit 1
+			fi
+			rm -rf "$ABCDETEMPDIR" || exit 1
+			mkdir "$ABCDETEMPDIR"
+			if [ "$?" -gt "0" ]; then
+				# Directory already exists or could not be created
+				echo "abcde: Temp directory $ABCDETEMPDIR could not be created." >&2
+				exit 1
+			fi
+		else
+			# Everything is fine. Check for ^encodetracklocation-
+			# and encode-output entries in the status file and
+			# remove them. These are not relevant across sessions.
+			if [ -f "$ABCDETEMPDIR/status" ]; then
+				mv "$ABCDETEMPDIR/status" "$ABCDETEMPDIR/status.old"
+				grep -v ^encodetracklocation- < "$ABCDETEMPDIR/status.old" \
+					| grep -v ^encode-output > "$ABCDETEMPDIR/status"
+			fi
+			# Remove old error messages
+			if [ -f "$ABCDETEMPDIR/errors" ]; then
+				rm -f "$ABCDETEMPDIR/errors"
+			fi
+		fi
+	else
+		# We are starting from scratch
+		mkdir "$ABCDETEMPDIR"
+		if [ "$?" -gt "0" ]; then
+			# Directory already exists or could not be created
+			echo "abcde: Temp directory $ABCDETEMPDIR could not be created." >&2
+			exit 1
+		fi
+		cat /dev/null > "$ABCDETEMPDIR/status"
+	fi
+	
+	# Create the discid file
+	echo "$TRACKINFO" > "$ABCDETEMPDIR/discid"
+
+	# Determine what actions are to be done from $ACTIONS and set the
+	# following environment variables for them:
+	DOCDDB=n
+	DOREAD=n
+	DOENCODE=n
+	DOTAG=n
+	DOMOVE=n
+	DOPLAYLIST=n
+	DOCLEAN=n
+
+	for ACTION in $(echo $ACTIONS | tr , \ )
+	do
+		case $ACTION in
+		cddb) DOCDDB=y;;
+		read) DOREAD=y;;
+		encode) DOENCODE=y; DOREAD=y;;
+		tag) DOTAG=y; DOREAD=y; DOENCODE=y; DOCDDB=y;;
+		move) DOMOVE=y; DOTAG=y; DOREAD=y; DOENCODE=y; DOCDDB=y;;
+		playlist) DOCDDB=y; DOPLAYLIST=y;;
+		clean) DOCLEAN=y;;
+		esac
+	done
+}
+
+# do_cddbquery
+do_cddbquery ()
+{
+	# Perform CDDB query if it hasn't already been done
+	if checkstatus cddb-querycomplete; then :; else
+		if [ "$CDDBAVAIL" = "n" ]; then
+			ERRORCODE=no_query
+			echo 503 > "$ABCDETEMPDIR/cddbquery"
+		else
+			CDDBUSER=$(echo $HELLOINFO | cut -f1 -d'@')
+			CDDBHOST=$(echo $HELLOINFO | cut -f2- -d'@')
+			$CDDBTOOL query $CDDBURL $CDDBUSER $CDDBHOST $TRACKINFO > "$ABCDETEMPDIR/cddbquery"
+			ERRORCODE=$?
+			case $ERRORCODE in
+				0)  # success
+				;;
+				12|13|14)
+					# no match found in database,
+					# wget error, or user requested not to use CDDB
+					# Make up an error code (503) that abcde
+					# will recognize in do_cddbread
+					# and compensate by making a template
+					echo 503 > "$ABCDETEMPDIR/cddbquery"
+				;;
+				*) # strange and unknown error
+					echo ERRORCODE=$ERRORCODE
+					echo "abcde: $CDDBTOOL returned unknown error code"
+				;;
+			esac
+		fi
+		echo cddb-querycomplete >> "$ABCDETEMPDIR/status"
+	fi
+}
+
+# do_cddbread
+do_cddbread ()
+{
+	# If it's not to be used, generate a template.
+	# Then, display it (or them) and let the user choose/edit it
+	if checkstatus cddb-readcomplete; then :; else
+		# If CDDB is to be used, interpret the query results and read all
+		# the available entries.
+		rm -f "$ABCDETEMPDIR/cddbchoices"
+		CDDBCHOICES=1 # Overridden by multiple matches
+		RESPONSECODE=$(head -1 "$ABCDETEMPDIR/cddbquery" | cut -f1 -d' ')
+		case "$RESPONSECODE" in
+		200)
+			# One exact match, retrieve it
+			# 200 [section] [discid] [artist] / [title]
+			if checkstatus cddb-read-1-complete; then :; else
+				echo -n "Retrieving 1 CDDB match..." >> "$ABCDETEMPDIR/cddbchoices"
+				$CDDBTOOL read $CDDBURL $CDDBUSER $CDDBHOST $(cut -f2,3 -d' ' "$ABCDETEMPDIR/cddbquery") > "$ABCDETEMPDIR/cddbread.1"
+				echo "done." >> "$ABCDETEMPDIR/cddbchoices"
+				echo cddb-read-1-complete >> "$ABCDETEMPDIR/status"
+				echo cddb-choice=1 >> "$ABCDETEMPDIR/status"
+			fi
+			# List out disc title/author and contents
+			echo ---- $(cut '-d ' -f4- "$ABCDETEMPDIR/cddbquery") ---- >> "$ABCDETEMPDIR/cddbchoices"
+			for TRACK in $(seq 1 $TRACKS)
+			do
+				echo $TRACK: $(grep ^TTITLE$(expr $TRACK - 1)= "$ABCDETEMPDIR/cddbread.1" | cut -f2- -d= | tr -d \\r\\n) >> "$ABCDETEMPDIR/cddbchoices"
+			done
+			echo >> "$ABCDETEMPDIR/cddbchoices"
+			;;
+		202|403|409|503)
+			# No match
+			case "$RESPONSECODE" in
+			202) echo "No CDDB match." >> "$ABCDETEMPDIR/cddbchoices" ;;
+			403|409) echo "CDDB entry is corrupt, or the handshake failed." >> "$ABCDETEMPDIR/cddbchoices" ;;
+			503) echo "CDDB unavailable." >> "$ABCDETEMPDIR/cddbchoices" ;;
+			esac
+			$CDDBTOOL template $(cat "$ABCDETEMPDIR/discid") > "$ABCDETEMPDIR/cddbread.1"
+			# List out disc title/author and contents of template
+			echo ---- Unknown Artist / Unknown Album ---- >> "$ABCDETEMPDIR/cddbchoices"
+			for TRACK in $(seq 1 $TRACKS)
+			do
+				echo $TRACK: $(grep ^TTITLE$(expr $TRACK - 1)= "$ABCDETEMPDIR/cddbread.1" | cut -f2- -d= | tr -d \\r\\n) >> "$ABCDETEMPDIR/cddbchoices"
+			done
+			echo >> "$ABCDETEMPDIR/cddbchoices"
+			echo cddb-read-1-complete >> "$ABCDETEMPDIR/status"
+			echo cddb-choice=1 >> "$ABCDETEMPDIR/status"
+			;;
+		210|211)
+			# Multiple exact, (possibly multiple) inexact matches
+			IN=
+			if [ "$RESPONSECODE" = "211" ]; then IN=in; fi
+			if [ "$(wc -l < $ABCDETEMPDIR/cddbquery | tr -d ' ')" -eq 3 ]; then
+				echo "One ${IN}exact match:" >> "$ABCDETEMPDIR/cddbchoices"
+				tail +2 "$ABCDETEMPDIR/cddbquery" | head -1 >> "$ABCDETEMPDIR/cddbchoices"
+	                        echo cddb-choice=1 >> "$ABCDETEMPDIR/status"
+			else
+				echo "Multiple ${IN}exact matches:" >> "$ABCDETEMPDIR/cddbchoices"
+			fi
+			grep -v ^[.]$ "$ABCDETEMPDIR/cddbquery" | ( X=0
+			read DISCINFO # eat top line
+			while read DISCINFO
+			do
+				X=$(expr $X + 1)
+				if checkstatus cddb-read-$X-complete; then :; else
+					$CDDBTOOL read $CDDBURL $CDDBUSER $CDDBHOST $(echo $DISCINFO | cut -f1,2 -d' ') > "$ABCDETEMPDIR/cddbread.$X"
+					echo cddb-read-$X-complete >> "$ABCDETEMPDIR/status"
+				fi
+				# List out disc title/author and contents
+				echo \#$X: ---- "$DISCINFO" ---- >> "$ABCDETEMPDIR/cddbchoices"
+				for TRACK in $(seq 1 $TRACKS)
+				do
+					echo $TRACK: $(grep ^TTITLE$(expr $TRACK - 1)= $ABCDETEMPDIR/cddbread.$X | cut -f2- -d= | tr -d \\r\\n) >> "$ABCDETEMPDIR/cddbchoices"
+				done
+				echo >> "$ABCDETEMPDIR/cddbchoices"
+			done )
+			CDDBCHOICES=$(expr $(cat "$ABCDETEMPDIR/cddbquery" | wc -l) - 2)
+			;;
+		esac	
+		echo "cddb-readcomplete" >> "$ABCDETEMPDIR/status"
+	fi
+}
+
+# do_cddbedit
+do_cddbedit ()
+{
+	if checkstatus cddb-edit; then
+		CDDBDATA="$ABCDETEMPDIR/cddbread.$(checkstatus cddb-choice)"
+		return 0
+	fi
+	if [ "$INTERACTIVE" = "y" ]; then
+		# Display the $ABCDETEMPDIR/cddbchoices file created above
+		# Pick a pager so that if the tracks overflow the screen the user can still view everything
+		if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
+			if checkstatus cddb-choice >/dev/null; then
+				# Make sure user sees this so they can edit it if they want to
+				cat "$ABCDETEMPDIR/cddbchoices"
+			else
+				# The user has a choice to make, display the info in a pager if necessary
+				if [ $(cat "$ABCDETEMPDIR/cddbchoices" | wc -l) -ge 24 ]; then
+					# Use the debian sensible-pager wrapper to pick the pager
+					# user has requested via their $PAGER environment variable
+					if [ -x "/usr/bin/sensible-pager" ]; then
+						/usr/bin/sensible-pager "$ABCDETEMPDIR/cddbchoices"
+					elif [ -x "$PAGER" ]; then
+						# That failed, try to load the preferred editor, starting
+						# with their PAGER variable
+						$PAGER "$ABCDETEMPDIR/cddbchoices"
+						# If that fails, check for less
+					elif [ -x /usr/bin/less ]; then
+						/usr/bin/less "$ABCDETEMPDIR/cddbchoices"
+						# more should be on all UNIX systems
+					elif [ -x /bin/more ]; then
+						/bin/more "$ABCDETEMPDIR/cddbchoices"
+					else
+						# No bananas, just cat the thing
+						cat "$ABCDETEMPDIR/cddbchoices" >&2
+					fi
+				else
+					# It's all going to fit in one page, cat it
+					cat "$ABCDETEMPDIR/cddbchoices" >&2
+				fi
+		
+				# I'll take CDDB read #3 for $400, Alex
+				echo -n "Which entry would you like abcde to use? [1-$CDDBCHOICES]: " >&2
+				read CDDBCHOICE
+				# Make sure we get a valid choice
+				CDCHOICENUM=$(echo $CDDBCHOICE | xargs printf %d 2>/dev/null)
+			        while [ $CDCHOICENUM -lt 1 ] || [ $CDCHOICENUM -gt $CDDBCHOICES ]; do
+					echo "Invalid selection. Please choose a number between 1 and $CDDBCHOICES." >&2
+					echo -n "Selection [1-$CDDBCHOICES]: " >&2
+					read CDDBCHOICE
+					CDCHOICENUM=$(echo $CDDBCHOICE | xargs printf %d 2>/dev/null)
+				done
+				echo "Selected: #$CDCHOICENUM ($(grep ^DTITLE= $ABCDETEMPDIR/cddbread.$CDCHOICENUM | cut -f2- -d= | tr -d \\r\\n))" >&2
+				echo "cddb-choice=$CDCHOICENUM" >> "$ABCDETEMPDIR/status"
+			fi
+		fi
+	else
+		# We're noninteractive - pick the first choice.
+		if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
+			if checkstatus cddb-choice >/dev/null; then
+				cat "$ABCDETEMPDIR/cddbchoices"
+			fi
+			CDCHOICENUM=1
+			echo "Selected: #$CDCHOICENUM ($(grep ^DTITLE= $ABCDETEMPDIR/cddbread.$CDCHOICENUM | cut -f2- -d= | tr -d \\r\\n))" >&2
+			echo "cddb-choice=1" >> "$ABCDETEMPDIR/status"
+		fi
+	fi
+	
+	# sanity check
+	if checkstatus cddb-choice >/dev/null; then :; else
+		echo "abcde: internal error: cddb-choice not recorded." >&2
+		exit 1
+	fi
+	CDDBDATA="$ABCDETEMPDIR/cddbread.$(checkstatus cddb-choice)"
+	
+	echo -n "Edit selected CDDB data? [y/n] (n): " >&2
+	if [ "$INTERACTIVE" = "y" ]; then
+		read EDITCDDB
+	else
+		echo n >&2
+		EDITCDDB=n
+	fi
+	if [ "$EDITCDDB" = "y" ]; then
+		# Use the debian sensible-editor wrapper to pick the editor that the
+		# user has requested via their $EDITOR environment variable
+		if [ -x "/usr/bin/sensible-editor" ]; then
+			/usr/bin/sensible-editor "$CDDBDATA"
+		elif [ -x "$EDITOR" ]; then
+			# That failed, try to load the preferred editor, starting
+			# with their EDITOR variable
+			$EDITOR "$CDDBDATA"
+		# If that fails, check for a vi
+		elif [ -x /usr/bin/vi ]; then
+			/usr/bin/vi "$CDDBDATA"
+		# ae should be on all debian systems
+		elif [ -x /bin/ae ]; then
+			/bin/ae "$CDDBDATA"
+		# bomb out
+		else
+			echo "No editor available. Check your EDITOR environment variable." >&2
+		fi
+		# delete editor backup file if it exists
+		if [ -w "$CDDBDATA~" ]; then
+			rm -f "$CDDBDATA~"
+		fi
+	fi	
+	
+	# Some heuristics first. Look at Disc Title, and if it starts with
+	# "Various", then we'll assume Various Artists
+	if [ "$(grep ^DTITLE= "$CDDBDATA" | cut -f2 -d= | egrep -ci '^(various|soundtrack)')" != "0" ]; then
+		echo "Looks like a Multi-Artist CD" >&2
+		VARIOUSARTISTS=y
+	else
+		echo -n "Is the CD multi-artist? [y/n] (n): " >&2
+		if [ "$INTERACTIVE" = "y" ]; then
+			read VARIOUSARTISTS
+		else
+			echo n >&2
+			VARIOUSARTISTS=n
+		fi
+	fi
+	if [ "$VARIOUSARTISTS" = "y" ]; then
+		# Set a default
+		DEFAULTSTYLE=1
+		# Need NUMTRACKS before cddb-tool will return it:
+		NUMTRACKS=$(grep -E '^TTITLE[0-9]+=' "$CDDBDATA" | wc -l)
+		if [ "$(grep -c "^TTITLE.*\/" "$CDDBDATA")" -gt "$(expr $NUMTRACKS / 2 )" ]; then
+			# More than 1/2 tracks contain a "/", so guess forward
+			DEFAULTSTYLE=1
+		elif [ "$(grep -c "^TTITLE.*\-" "$CDDBDATA")" -gt "$(expr $NUMTRACKS / 2 )" ]; then
+			# More than 1/2 contain a "-", so guess forward-dash
+			DEFAULTSTYLE=2
+		fi
+
+		echo "1) Artist / Title" >&2
+		echo "2) Artist - Title" >&2
+		echo "3) Title / Artist" >&2
+		echo "4) Title - Artist" >&2
+		echo "5) Artist: Title" >&2
+		echo "6) This is a single-artist CD" >&2
+		echo -n "Which style of multiple artist entries is it? [1-6] ($DEFAULTSTYLE): " >&2
+		if [ "$INTERACTIVE" = "y" ]; then
+			read VARIOUSARTISTSTYLE
+		else
+			echo $DEFAULTSTYLE >&2
+			VARIOUSARTISTSTYLE=$DEFAULTSTYLE
+		fi
+		VARIOUSARTISTSTYLE=$(echo $VARIOUSARTISTSTYLE | xargs printf %d)
+		# If they press Enter, then the default style (0) was chosen
+		while [ $VARIOUSARTISTSTYLE -lt 0 ] || [ $VARIOUSARTISTSTYLE -gt 6 ]; do
+			echo "Invalid selection. Please choose a number between 1 and 6."
+			echo -n "Selection [1-6]: "
+
+
+			read VARIOUSARTISTSTYLE
+			VARIOUSARTISTSTYLE=$(echo $VARIOUSARTISTSTYLE | xargs printf %d)
+		done
+		if [ "$VARIOUSARTISTSTYLE" = "0" ]; then
+			VARIOUSARTISTSTYLE=$DEFAULTSTYLE
+		fi
+		echo "Selected: $VARIOUSARTISTSTYLE"
+		case "$VARIOUSARTISTSTYLE" in
+		1) # Artist / Title
+			VARIOUSARTISTSTYLE=forward
+			;;
+		2) # Artist - Title
+			VARIOUSARTISTSTYLE=forward-dash
+			;;
+		3) # Title / Artist
+			VARIOUSARTISTSTYLE=reverse
+			;;
+		4) # Title - Artist
+			VARIOUSARTISTSTYLE=reverse-dash
+			;;
+		5) # Artist: Title
+			VARIOUSARTISTSTYLE=colon
+			;;
+		6) # Single Artist
+			VARIOUSARTISTS=n
+			;;
+		esac
+	fi
+	
+	if [ "$UNINTENTIONALLY_ANGER_THE_FREEDB_PEOPLE" = "y" ]; then
+		# This works but does not have the necessary error checking
+		# yet. If you are familiar with the CDDB spec
+		# (see http://www.freedb.org/src/latest/DBFORMAT) 
+		# and can create an error-free entry on your own, then put
+		# UNINTENTIONALLY_ANGER_THE_FREEDB_PEOPLE=y in your
+		# abcde.conf to enable it. Put CDDBSUBMIT=email@address in
+		# your abcde.conf to change the email address submissions are
+		# sent to.
+
+		# submit the modified file, if they want
+		if [ "$NOSUBMIT" != "y" ]; then
+			echo -n "Do you want to submit this entry to $CDDBSUBMIT? [y|N] "
+			read YESNO
+			while [ "$YESNO" != "y" ] && [ "$YESNO" != "n" ] && [ "$YESNO" != "Y" ] && [ "$YESNO" != "N" ]
+			do
+				echo -n 'Invalid selection. Please answer "y" or "n": '
+				read YESNO
+			done
+			if [ "$YESNO" = "y" ] || [ "$YESNO" = "Y" ]; then
+				echo -n "Sending..."
+				$CDDBTOOL send "$CDDBDATA" $CDDBSUBMIT
+				echo "done."
+			fi
+		fi
+	fi
+
+	echo "cddb-edit" >> "$ABCDETEMPDIR/status"
+}
+
+# do_cdread [tracknumber]
+# 
+do_cdread ()
+{
+	# The commands here don't go through run_command because they're never supposed to be silenced
+	# return codes need to be doublechecked anyway, however
+	UTRACKNUM=$1
+	CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
+	WAVDATA="$ABCDETEMPDIR/track$UTRACKNUM.wav"
+	OUTDATA="$ABCDETEMPDIR/track$UTRACKNUM.$OUTPUTTYPE"
+	if [ -r "$CDDBDATA" ]; then
+		TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -1 | cut -f2 -d= | tr -d \[:cntrl:\])
+		echo "Grabbing track $UTRACKNUM: $TRACKNAME..." >&2
+	else
+		echo "Grabbing track $UTRACKNUM..." >&2
+	fi
+	case "$CDROMREADERSYNTAX" in
+		cdparanoia) nice $READNICE $CDROMREADER -d $CDROM $UTRACKNUM "$WAVDATA" >&2 ;;
+		cdda2wav) nice $READNICE $CDROMREADER -H -D $CDROM -t $UTRACKNUM "$WAVDATA" >&2 ;;
+		debug) nice $READNICE $CDROMREADER -d $CDROM -w $UTRACKNUM-[:1] "$WAVDATA" >&2 ;;
+	esac
+	RETURN=$?
+	if [ "$RETURN" != "0" ]; then
+		# Thank goodness errors is only machine-parseable up to the
+		# first colon, otherwise this woulda sucked
+                echo "readtrack-$UTRACKNUM: $CDROMREADER returned code $RETURN" >> "$ABCDETEMPDIR/errors"
+		return $RETURN
+	else
+		echo readtrack-$UTRACKNUM >> "$ABCDETEMPDIR/status"
+	fi
+}
+
+# Start of execution
+
+# Builtin defaults
+CDDBURL="http://freedb.freedb.org/~cddb/cddb.cgi"
+HELLOINFO="$(whoami)@$(hostname)"
+INTERACTIVE=y
+CDROMREADERSYNTAX=cdparanoia
+OUTPUTTYPE=ogg
+ENCODERSYNTAX=default
+OUTPUTFORMAT='${ARTISTFILE}/${TRACKFILE}.$OUTPUTTYPE'
+VAOUTPUTFORMAT=${OUTPUTFORMAT}
+PLAYLISTFORMAT='${ARTISTFILE}_-_${ALBUMFILE}.m3u'
+PLAYLISTDATAPREFIX=''
+COMMENT=''
+ID3TAGV=2
+ENCNICE=10
+READNICE=10
+VARIOUSARTISTS=n
+VARIOUSARTISTSTYLE=forward
+
+# program paths - defaults to checking your $PATH
+LAME=lame
+GOGO=gogo
+BLADEENC=bladeenc
+L3ENC=l3enc
+XINGMP3ENC=xingmp3enc
+MP3ENC=mp3enc
+VORBIZE=vorbize
+OGGENC=oggenc
+ID3=id3
+ID3V2=id3v2
+CDPARANOIA=cdparanoia
+CDDA2WAV=cdda2wav
+WGET=wget
+CDDISCID=cd-discid
+CDDBTOOL=cddb-tool
+EJECT=eject
+DISTMP3=distmp3
+VORBISCOMMENT=vorbiscomment
+
+# Options for programs called from abcde
+LAMEOPTS=
+GOGOOPTS=
+BLADEENCOPTS=
+L3ENCOPTS=
+XINGMP3ENCOPTS=
+MP3ENCOPTS=
+VORBIZEOPTS=
+OGGENCOPTS=
+ID3OPTS=
+ID3V2OPTS=
+CDPARANOIAOPTS=
+CDDA2WAVOPTS=
+WGETOPTS=
+CDDBTOOLOPTS=
+EJECTOPTS=
+DISTMP3OPTS=
+
+# Default to one process if -j isn't specified
+MAXPROCS=1
+
+# List of actions to perform - by default, run to completion
+ACTIONS=cddb,read,encode,tag,move,clean
+
+# User-redefinable functions
+# Custom filename munging:
+mungefilename ()
+{
+	echo "$@" | sed s,:,\ -,g | tr \ / __ | tr -d \'\?\[:cntrl:\]
+}
+
+# If CDDBAVAIL is set to n, no CDDB read is done
+# If USEID3 is set to n, no ID3 tagging is done
+CDDBAVAIL=y
+USEID3=y
+
+if [ -z "$OUTPUTDIR" ]; then
+	OUTPUTDIR=$(pwd)
+fi
+
+if [ -z "$WAVOUTPUTDIR" ]; then
+	WAVOUTPUTDIR="$OUTPUTDIR"
+fi
+
+# If this is a devfs system, default to /dev/cdroms/cdrom0
+# instead of /dev/cdrom
+if [ -e /dev/cdroms/cdrom0 ]; then
+	CDROM=/dev/cdroms/cdrom0
+else
+	CDROM=/dev/cdrom
+fi
+
+# Load system defaults
+if [ -r /etc/abcde.conf ]; then
+	. /etc/abcde.conf
+fi
+# Load user preference defaults
+if [ -r $HOME/.abcde.conf ]; then
+	. $HOME/.abcde.conf
+fi
+
+# Parse command line options
+while getopts a:c:C:d:Dhj:lnNo:r:x opt ; do
+	case "$opt" in
+		a) ACTIONS="$OPTARG" ;;
+		c) . "$OPTARG" ;;
+		C) DISCID="$OPTARG" ;;
+		d) CDROM="$OPTARG" ;;
+		D) set -x ;;
+		j) MAXPROCS="$OPTARG" ;;
+		h) usage; exit ;;
+		l) LOWDISK=y ;;
+		n) CDDBAVAIL="n" ;;
+		N) INTERACTIVE="n" ;;
+		o) OUTPUTTYPE="$OPTARG" ;;
+		r) REMOTEHOSTS="$OPTARG" ;;
+		x) EJECTCD="y" ;;
+		?) usage; exit ;;
+	esac
+done
+
+shift $(($OPTIND - 1))
+
+while [ $# -gt 0 ]; do
+	# Range parsing code courtesy of Vincent Ho
+	RSTART=$(echo $1 | cut -f1 -d-)
+	REND=$(echo $1 | cut -f2 -d-)
+	if [ "$RSTART" = "$REND" ]; then 
+		NEWTRACKS="$RSTART"
+	else
+		NEWTRACKS=$(seq -s ' ' $RSTART $REND)
+	fi
+	TRACKQUEUE=$(echo "$TRACKQUEUE" "$NEWTRACKS")
+
+	shift
+done
+
+# Decide which CDROM reader we're gonna use
+case "$CDROMREADERSYNTAX" in
+	cdparanoia|debug)
+		CDROMREADER="$CDPARANOIA"
+		CDROMREADEROPTS="$CDPARANOIAOPTS"
+		;;
+	cdda2wav)
+		CDROMREADER="$CDDA2WAV"
+		CDROMREADEROPTS="$CDDA2WAVOPTS"
+		;;
+esac
+
+# If nothing has been specified, use oggenc for oggs and lame for mp3s
+if [ "$ENCODERSYNTAX" = "default" ]; then
+	if [ "$OUTPUTTYPE" = "ogg" ]; then
+		ENCODERSYNTAX=oggenc
+	else
+		ENCODERSYNTAX=lame
+	fi
+fi
+
+# decide which encoder
+case "$ENCODERSYNTAX" in
+	lame)
+		ENCODEROPTS="$LAMEOPTS"
+		ENCODER="$LAME"
+		;;
+	gogo)
+		ENCODEROPTS="$GOGOOPTS"
+		ENCODER="$GOGO"
+		;;
+	bladeenc)
+		ENCODEROPTS="$BLADEENCOPTS"
+		ENCODER="$BLADEENC"
+		;;
+	l3enc)
+		ENCODEROPTS="$L3ENCOPTS"
+		ENCODER="$L3ENC"
+		;;
+	xingmp3enc)
+		ENCODEROPTS="$XINGMP3ENCOPTS"
+		ENCODER="$XINGMP3ENC"
+		;;
+	mp3enc)
+		ENCODEROPTS="$MP3ENCOPTS"
+		ENCODER="$MP3ENC"
+		;;
+	vorbize)
+		ENCODEROPTS="$VORBIZEOPTS"
+		ENCODER="$VORBIZE"
+		;;
+	oggenc)
+		ENCODEROPTS="$OGGENCOPTS"
+		ENCODER="$OGGENC"
+		;;
+esac
+
+# and which tagger
+
+if [ "$ID3TAGV" = "1" ]; then
+	TAGGER="$ID3"
+	TAGGEROPTS="$ID3OPTS"
+else
+	TAGGER="$ID3V2"
+	TAGGEROPTS="$ID3V2OPTS"
+fi
+
+# Clean up nice options (either use '-n NICELEVEL or -NICELEVEL')
+
+if [ "$ENCNICE" ]; then
+	ENCNICE=-$ENCNICE
+fi
+if [ "$READNICE" ]; then
+	READNICE=-$READNICE
+fi
+
+
+# Don't check for stuff if it's not needed
+if [ "$REMOTEHOSTS" ]; then NEEDDISTMP3=y; fi	
+if [ "$OUTPUTTYPE" = "mp3" ]; then NEEDTAGGER=y; fi
+if [ "$OUTPUTTYPE" = "ogg" ]; then NEEDCOMMENTER=y; fi
+
+# Make sure a buncha things exist
+for X in $CDROMREADER $CDDISCID ${NEEDTAGGER+$TAGGER} $ENCODER $WGET \
+	${NEEDDISTMP3+$DISTMP3} ${NEEDCOMMENTER+$VORBISCOMMENT} seq
+do
+	# Cut off the command-line options we just added in
+	X=$(echo $X | cut -d' ' -f2)
+	if [ "$(which $X)" = "" ]; then
+		echo "abcde error: $X is not in your path." >&2
+		exit 1
+	elif [ \! -x $(which $X) ]; then
+		echo "abcde error: $X is not executable." >&2
+		exit 1
+	fi 
+done
+
+CDROMREADER="$CDROMREADER $CDROMREADEROPTS"
+CDDBTOOL="$CDDBTOOL $CDDBTOOLOPTS"
+
+# One thousand lines in, we can start doing stuff with things
+
+# List of valid actions: cddb,playlist,read,encode,tag,move
+
+do_discid # Get ABCDETEMPDIR created and status file initialized
+
+if [ "$DOCDDB" = "y" ]; then
+	do_cddbquery
+	do_cddbread
+	do_cddbedit
+
+	eval $($CDDBTOOL parse "$CDDBDATA")
+fi
+
+# Export needed things so they can be read in this subshell
+export CDDBTOOL ABCDETEMPDIR TRACKQUEUE LOWDISK EJECTCD EJECT EJECTOPTS
+export CDROM CDDBDATA REMOTEHOSTS MAXPROCS
+
+# Create playlist if needed (backgroundable) and start reading in tracks
+(
+if [ "$DOPLAYLIST" = "y" ]; then
+	echo Creating playlist... >&2
+	do_playlist
+fi
+
+# For the lowdisk option, only one program is running at once so the encoder
+# can be unsilenced right away.
+if [ "$LOWDISK" = "y" ]; then
+	echo "encode-output=loud" >> "$ABCDETEMPDIR/status"
+fi
+
+for UTRACKNUM in $TRACKQUEUE
+do
+	if [ "$DOREAD" = "y" ]; then
+		if checkstatus readtrack-$UTRACKNUM; then :; else
+			do_cdread $UTRACKNUM
+			if [ "$?" != "0" ]; then
+				# CD read failed - don't give the goahead to
+				# the encoder
+				echo NO
+				exit
+			fi
+		fi
+	fi
+	echo NEXTTRACK # Get the encoder machine churning again
+	if [ "$DOREAD" = "y" ]; then
+		if [ "$LOWDISK" = "y" ] && [ "$DOENCODE" = "y" ]; then
+			until checkstatus encodetrack-$UTRACKNUM
+			do
+				if checkerrors encodetrack-$UTRACKNUM; then
+					break
+				fi
+				sleep 2
+			done
+		fi
+	fi
+done
+
+# Now that we're done the encoding can be loud again.
+echo "encode-output=loud" >> "$ABCDETEMPDIR/status"
+
+# We are now finished with the cdrom - it can be safely ejected. Note that
+# abcde will not have completed yet.
+if [ "$EJECTCD" = "y" ]; then
+	$EJECT $EJECTOPTS $CDROM
+fi
+) | (
+# Do the encoding, including parallelization of remote encoding
+LOCALCOUNTER=0
+# Figure out where each track is going to be encoded
+ENCODELOCATIONS=""
+for REMOTEHOST in $(echo $REMOTEHOSTS | tr , ' ')
+do
+	ENCODELOCATIONS="$ENCODELOCATIONS $REMOTEHOST"
+done
+if [ "$MAXPROCS" != "0" ]; then
+	for NUM in $(seq 1 "$MAXPROCS")
+	do
+		ENCODELOCATIONS="$ENCODELOCATIONS %local%"
+	done
+fi
+# Strip whitespace
+ENCODELOCATIONS=$(echo $ENCODELOCATIONS)
+for UTRACKNUM in $TRACKQUEUE
+do
+	# Wait for our cue
+	read GOAHEAD # For blocking - will contain either "NO" or "NEXTTRACK"
+	if [ "$GOAHEAD" = "NO" ]; then break; fi
+	# find out where this track is to be encoded
+	if [ "$DOENCODE" = "y" ]; then
+		# Make sure we have a place to encode this, if not, exit stage right
+		if [ -z "$ENCODELOCATIONS" ]; then
+			continue
+		fi
+		PROCEED=
+		until [ $PROCEED ]
+		do
+			for LOCATION in $ENCODELOCATIONS
+			do
+				PREVIOUSTRACK="$(checkstatus encodetracklocation-$LOCATION)"
+				if [ "$LOCATION" = "%local%" ]; then
+					PROCEED=y
+				else
+					# check first if a track has ever been assigned to this location
+					if [ -z "$PREVIOUSTRACK" ]; then PROCEED=y; break; fi
+				fi
+				# If it errored out, rebuild $ENCODELOCATIONS without this location in it
+				if checkerrors encodetrack-$PREVIOUSTRACK; then
+					for TEMPLOCATION in $ENCODELOCATIONS
+					do
+						if [ "$TEMPLOCATION" != "$LOCATION" ]; then
+							TEMPENCODELOCATIONS="$TEMPENCODELOCATIONS $TEMPLOCATION"
+						fi
+					done
+					ENCODELOCATIONS=$(echo $TEMPENCODELOCATIONS)
+					ABORT=y
+					PROCEED=y
+					break
+				fi
+				# We're still here, this location must have been previously assigned,
+				# and last completed without error - check if it's done with the
+				# previous track yet
+				if checkstatus encodetrack-$PREVIOUSTRACK; then PROCEED=y; break; fi
+			done
+			# all locations are working, wait and try again later
+			if [ \! $PROCEED ]; then sleep 3; fi
+		done
+		# We need to know if this is the last local encode location
+		# so we can avoid backgrounding it - LOCALCOUNTER cycles
+		# from 0 to MAXPROCS-1
+		if [ "$LOCATION" = "%local%" ]; then
+			LOCALCOUNTER=$(expr $LOCALCOUNTER + 1)
+			if [ "$LOCALCOUNTER" -gt "$MAXPROCS" ]; then
+				LOCALCOUNTER=1
+			fi
+		fi
+		# Record the location we're about to encode the next track at
+		echo "encodetracklocation-$LOCATION=$UTRACKNUM" >> "$ABCDETEMPDIR/status"
+	fi
+	# Don't proceed with the rest of the loop if we can't encode
+	if [ "$ABORT" ]; then continue; fi
+	# Set TRACKNUM, TRACKNAME
+	if [ -e "$CDDBDATA" ]; then
+		TRACKNUM=$(printf %0.${TRACKNUMPADDING}d ${UTRACKNUM})
+	        CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
+		TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -1 | cut -f2 -d= | tr -d \[:cntrl:\])
+		splitvarious
+	fi
+	echo "\$LOCALCOUNTER = $LOCALCOUNTER" >&2
+	echo "\$MAXPROCS = $MAXPROCS" >&2
+	if [ "$LOCATION" = "%local%" -a "$LOCALCOUNTER" -lt "$MAXPROCS" ]; then
+		if [ "$DOENCODE" = "y" ]; then
+			if checkstatus readtrack-$UTRACKNUM; then
+				if checkstatus encodetrack-$UTRACKNUM; then :; else do_encode $UTRACKNUM $LOCATION; fi
+			fi
+		fi
+		if [ "$DOTAG" = "y" ]; then
+			if checkstatus encodetrack-$UTRACKNUM; then
+				if checkstatus tagtrack-$UTRACKNUM; then :; else do_tag $UTRACKNUM; fi
+			fi
+		fi
+		if [ "$DOMOVE" = "y" ]; then
+			if checkstatus tagtrack-$UTRACKNUM; then
+				if checkstatus movetrack-$UTRACKNUM; then :; else do_move $UTRACKNUM; fi
+			fi
+		fi
+	else
+		# You can't tag a file before it's finished encoding -
+		# thus all of this is backgrounded together
+		# (This is a copy of the above with a "( ) &" wrapped around it)
+		(
+		if [ "$DOENCODE" = "y" ]; then
+			if checkstatus readtrack-$UTRACKNUM; then
+				if checkstatus encodetrack-$UTRACKNUM; then :; else do_encode $UTRACKNUM $LOCATION; fi
+			fi
+		fi
+		if [ "$DOTAG" = "y" ]; then
+			if checkstatus encodetrack-$UTRACKNUM; then
+				if checkstatus tagtrack-$UTRACKNUM; then :; else do_tag $UTRACKNUM; fi
+			fi
+		fi
+		if [ "$DOMOVE" = "y" ]; then
+			if checkstatus tagtrack-$UTRACKNUM; then
+				if checkstatus movetrack-$UTRACKNUM; then :; else do_move $UTRACKNUM; fi
+			fi
+		fi
+		) &
+	fi
+done
+# Go through it again and make sure there's no distmp3 stragglers, otherwise
+# we'll delete the files they're working on
+if [ "$DOENCODE" = "y" ]; then
+	PROCEED=
+	until [ $PROCEED ]
+	do
+		PROCEED=y
+		for LOCATION in $ENCODELOCATIONS
+		do
+			CHECKTRACK="$(checkstatus encodetracklocation-$LOCATION)"
+			# "How can he give us a status update, if he's DEAD?"
+			if checkstatus encodetrack-$CHECKTRACK; then
+				continue
+			fi
+			# Nothing to see here please go quietly back to your homes
+			if [ -z "$CHECKTRACK" ]; then continue; fi
+			# You're still here? Maybe there is something...
+			if checkstatus encodetrack-$CHECKTRACK; then :;	else PROCEED= ; break; fi
+		done
+		# hold up
+		if [ \! $PROCEED ]; then sleep 5; fi
+	done
+fi
+# If the above didn't catch the stragglers, this will
+wait
+# Check to see if run_command logged any errors
+if [ -f "$ABCDETEMPDIR/errors" ]; then
+	echo "The following commands failed to run:"
+	cat "$ABCDETEMPDIR/errors"
+	# Don't clean up
+	DOCLEAN=n
+fi
+if [ "$DOCLEAN" = "y" ]; then
+	# Wipe all the evidence
+	rm -rf "$ABCDETEMPDIR"
+	echo "Finished."
+else
+	echo "Finished. Not cleaning $ABCDETEMPDIR."
+fi
+)
+exit 0

