diff --git a/bin/mkpackage.pike b/bin/mkpackage.pike
index 2ba217f6e710694188c06e003e6ed7fd6cbda9fb..e7b7e28eb2f3883d9c5cfbc0c04129eac8c6c3ca 100644
--- a/bin/mkpackage.pike
+++ b/bin/mkpackage.pike
@@ -71,7 +71,7 @@ class Package
     string setup = ("#!/bin/sh\n"
 		    "TARFILE=\"$1\"; shift; ARGS=''\n"
 		    "CONTENTS=`tar tf \"$TARFILE\" | sed -ne '/^"+
-		    replace(install_filename, ".", "\\.")+"/,$p'`\n"
+		    (replace(install_filename, ".", "\\.")/"/")[-1]+"/,$p'`\n"
 		    // Check all arguments for possible options.
 		    "while [ $# != 0 ]\n"
 		    "do\n"