--- scripts/uscan.pl.bak	2008-01-02 14:09:08.000000000 -0500
+++ scripts/uscan.pl	2008-01-02 14:09:56.000000000 -0500
@@ -713,6 +713,9 @@
 		elsif ($opt =~ /^filenamemangle\s*=\s*(.+)/) {
 		    @{$options{'filenamemangle'}} = split /;/, $1;
 		}
+		elsif ($opt =~ /^origversionmangle\s*=\s*(.+)/) {
+		    @{$options{'origversionmangle'}} = split /;/, $1;
+		}
 		elsif ($opt =~ /^downloadurlmangle\s*=\s*(.+)/) {
 		    @{$options{'downloadurlmangle'}} = split /;/, $1;
 		}
@@ -1145,18 +1148,25 @@
 	}
     }
 
+    # Mangle the orig version in case it's different from upstream version
+    # For example, convert 1-1-1 to 1.1.1
+    my $mangled_origversion = $newversion;
+    foreach my $pat (@{$options{'origversionmangle'}}) {
+	eval "\$mangled_origversion =~ $pat;";
+    }
+
     if ($newfile_base =~ /\.(tar\.gz|tgz)$/) {
 	if ($symlink eq 'symlink') {
-	    symlink $newfile_base, "$destdir/${pkg}_${newversion}.orig.tar.gz";
+	    symlink $newfile_base, "$destdir/${pkg}_${mangled_origversion}.orig.tar.gz";
 	} elsif ($symlink eq 'rename') {
-	    move "$destdir/$newfile_base", "$destdir/${pkg}_${newversion}.orig.tar.gz";
+	    move "$destdir/$newfile_base", "$destdir/${pkg}_${mangled_origversion}.orig.tar.gz";
 	}
     }
     elsif ($newfile_base =~ /\.(tar\.bz2|tbz2?)$/) {
 	if ($symlink eq 'symlink') {
-	    symlink $newfile_base, "$destdir/${pkg}_${newversion}.orig.tar.bz2";
+	    symlink $newfile_base, "$destdir/${pkg}_${mangled_origversion}.orig.tar.bz2";
 	} elsif ($symlink eq 'rename') {
-	    move "$destdir/$newfile_base", "$destdir/${pkg}_${newversion}.orig.tar.bz2";
+	    move "$destdir/$newfile_base", "$destdir/${pkg}_${mangled_origversion}.orig.tar.bz2";
 	}
     }
 
@@ -1164,32 +1174,32 @@
 	print "-- Successfully downloaded updated package $newfile_base\n";
 	if ($newfile_base =~ /\.(tar\.gz|tgz)$/) {
 	    if ($symlink eq 'symlink') {
-		print "    and symlinked ${pkg}_${newversion}.orig.tar.gz to it\n";
+		print "    and symlinked ${pkg}_${mangled_origversion}.orig.tar.gz to it\n";
 	    } elsif ($symlink eq 'rename') {
-		print "    and renamed it as ${pkg}_${newversion}.orig.tar.gz\n";
+		print "    and renamed it as ${pkg}_${mangled_origversion}.orig.tar.gz\n";
 	    }
 	}
 	elsif ($newfile_base =~ /\.(tar\.bz2|tbz2?)$/) {
 	    if ($symlink eq 'symlink') {
-		print "    and symlinked ${pkg}_${newversion}.orig.tar.bz2 to it\n";
+		print "    and symlinked ${pkg}_${mangled_origversion}.orig.tar.bz2 to it\n";
 	    } elsif ($symlink eq 'rename') {
-		print "    and renamed it as ${pkg}_${newversion}.orig.tar.bz2\n";
+		print "    and renamed it as ${pkg}_${mangled_origversion}.orig.tar.bz2\n";
 	    }
 	}
     } elsif ($dehs) {
 	my $msg = "Successfully downloaded updated package $newfile_base";
 	if ($newfile_base =~ /\.(tar\.gz|tgz)$/) {
 	    if ($symlink eq 'symlink') {
-		$msg .= " and symlinked ${pkg}_${newversion}.orig.tar.gz to it";
+		$msg .= " and symlinked ${pkg}_${mangled_origversion}.orig.tar.gz to it";
 	    } elsif ($symlink eq 'rename') {
-		$msg .= " and renamed it as ${pkg}_${newversion}.orig.tar.gz";
+		$msg .= " and renamed it as ${pkg}_${mangled_origversion}.orig.tar.gz";
 	    }
 	}
 	elsif ($newfile_base =~ /\.(tar\.bz2|tbz2?)$/) {
 	    if ($symlink eq 'symlink') {
-		$msg .= " and symlinked ${pkg}_${newversion}.orig.tar.bz2 to it";
+		$msg .= " and symlinked ${pkg}_${mangled_origversion}.orig.tar.bz2 to it";
 	    } elsif ($symlink eq 'rename') {
-		$msg .= " and renamed it as ${pkg}_${newversion}.orig.tar.bz2";
+		$msg .= " and renamed it as ${pkg}_${mangled_origversion}.orig.tar.bz2";
 	    }
 	}
 	dehs_msg($msg);
@@ -1197,16 +1207,16 @@
 	print "$pkg: Successfully downloaded updated package $newfile_base\n";
 	if ($newfile_base =~ /\.(tar\.gz|tgz)$/) {
 	    if ($symlink eq 'symlink') {
-		print "    and symlinked ${pkg}_${newversion}.orig.tar.gz to it\n";
+		print "    and symlinked ${pkg}_${mangled_origversion}.orig.tar.gz to it\n";
 	    } elsif ($symlink eq 'rename') {
-		print "    and renamed it as ${pkg}_${newversion}.orig.tar.gz\n";
+		print "    and renamed it as ${pkg}_${mangled_origversion}.orig.tar.gz\n";
 	    }
 	}
 	elsif ($newfile_base =~ /\.(tar\.bz2|tbz2?)$/) {
 	    if ($symlink eq 'symlink') {
-		print "    and symlinked ${pkg}_${newversion}.orig.tar.bz2 to it\n";
+		print "    and symlinked ${pkg}_${mangled_origversion}.orig.tar.bz2 to it\n";
 	    } elsif ($symlink eq 'rename') {
-		print "    and renamed it as ${pkg}_${newversion}.orig.tar.bz2\n";
+		print "    and renamed it as ${pkg}_${mangled_origversion}.orig.tar.bz2\n";
 	    }
 	}
     }
@@ -1216,11 +1226,11 @@
 	my $usefile = "$destdir/$newfile_base";
 	if ($symlink =~ /^(symlink|rename)$/
 	    and $newfile_base =~ /\.(tar\.gz|tgz)$/) {
-	    $usefile = "$destdir/${pkg}_${newversion}.orig.tar.gz";
+	    $usefile = "$destdir/${pkg}_${mangled_origversion}.orig.tar.gz";
 	}
 	elsif ($symlink =~ /^(symlink|rename)$/
 	    and $newfile_base =~ /\.(tar\.bz2|tbz2)$/) {
-	    $usefile = "$destdir/${pkg}_${newversion}.orig.tar.bz2";
+	    $usefile = "$destdir/${pkg}_${mangled_origversion}.orig.tar.bz2";
 	}
 
 	# Any symlink requests are already handled by uscan
@@ -1229,22 +1239,22 @@
 	}
 
 	if ($watch_version > 1) {
-	    print "-- Executing user specified script\n     $action --upstream-version $newversion $newfile_base" if $verbose;
+	    print "-- Executing user specified script\n     $action --upstream-version $mangled_origversion $newfile_base" if $verbose;
 	    if ($dehs) {
-		my $msg = "Executing user specified script: $action --upstream-version $newversion $newfile_base; output:\n";
-		$msg .= `$action --upstream-version $newversion $usefile 2>&1`;
+		my $msg = "Executing user specified script: $action --upstream-version $mangled_origversion $newfile_base; output:\n";
+		$msg .= `$action --upstream-version $mangled_origversion $usefile 2>&1`;
 		dehs_msg($msg);
 	    } else {
-		system("$action --upstream-version $newversion $usefile");
+		system("$action --upstream-version $mangled_origversion $usefile");
 	    }
 	} else {
-	    print "-- Executing user specified script $action $newfile_base $newversion" if $verbose;
+	    print "-- Executing user specified script $action $newfile_base $mangled_origversion" if $verbose;
 	    if ($dehs) {
-		my $msg = "Executing user specified script: $action $newfile_base $newversion; output:\n";
-		$msg .= `$action $usefile $newversion 2>&1`;
+		my $msg = "Executing user specified script: $action $newfile_base $mangled_origversion; output:\n";
+		$msg .= `$action $usefile $mangled_origversion 2>&1`;
 		dehs_msg($msg);
 	    } else {
-		system("$action $usefile $newversion");
+		system("$action $usefile $mangled_origversion");
 	    }
 	}
     }
--- scripts/uscan.1.bak	2008-01-02 14:09:01.000000000 -0500
+++ scripts/uscan.1	2008-01-02 14:51:29.000000000 -0500
@@ -114,6 +114,14 @@
 #   http://developer.berlios.de/project/showfiles.php?group_id=2051 \\
 #   http://prdownload.berlios.de/softdevice/vdr-softdevice-(.*).tgz
 
+# The option origversionmangle can be used to mangle the version used
+# for the orig tarball from the upstream version.
+# For example, when upstream uses the versioning n-n-n:
+# opts=uversionmangle=s/\\.\\?.*//,origversionmangle=s/\-/\\./g \\
+# http://downloads.sourceforge.net/ogre \\
+#    http://downloads.sourceforge.net/ogre/ogre-linux_osx-v(.*)\\.tar\\.bz2(.*) \\
+#    1-4-5
+
 .fi
 .PP
 Comment lines may be introduced with a `#' character.  Continuation
@@ -252,6 +260,11 @@
 \fBuversionmangle=\fIrules\fB,dversionmangle=\fIrules\fB, applying the
 same rules to both the upstream and Debian version numbers.
 .TP
+\fBorigversionmangle=\fIrules\fR
+This is used to mangle what's used for the version for the orig tarball.
+For example, it can be used to change the upstream version of 1-1-1 to
+1.1.1.
+.TP
 \fBfilenamemangle=\fIrules\fR
 This is used to mangle the filename with which the downloaded file
 will be saved, and is parsed in the same way as the
