Add --source option to build a source package instead of a binary deb package
authorBenjamin Drung <benjamin.drung@profitbricks.com>
Thu, 8 May 2014 12:53:53 +0000 (14:53 +0200)
committerBenjamin Drung <benjamin.drung@profitbricks.com>
Thu, 8 May 2014 12:53:53 +0000 (14:53 +0200)
Closes: #745762

lib/javase.sh
make-jpkg
make-jpkg.1

index 93215da..91187fc 100644 (file)
@@ -197,21 +197,36 @@ jinfos() {
 }
 
 j2se_build() {
-    cd "$package_dir"
-    echo "Create debian package:"
+    if [ -n "$build_source" ]; then
+        local source_dir=${j2se_package}-${j2se_version}
+        echo "    copy ${source_dir} into directory $working_dir/"
+        rm -rf "$working_dir/${source_dir}"
+        cp -r "$package_dir" "$working_dir/${source_dir}"
+        cat << EOF
+
+The Debian source package has been created in the current directory.
+You can build the package with:
 
+    cd ${source_dir}
     dpkg-buildpackage -b -uc -us
-    cd "$tmp"
-    local deb_filename="$( echo "${j2se_package}_"*.deb )"
-    echo "    copy $deb_filename into directory $working_dir/"
-    cp "$deb_filename" "$working_dir/"
-    if [ -n "$genchanges" ]; then
-        echo "    dpkg-genchanges"
-        local changes_filename="${deb_filename%.deb}.changes"
-        echo "    copy $changes_filename into directory $working_dir/"
-        cp "$changes_filename" "$working_dir/"
-    fi
-    cat << EOF
+
+EOF
+    else
+        cd "$package_dir"
+        echo "Create debian package:"
+
+        dpkg-buildpackage -b -uc -us
+        cd "$tmp"
+        local deb_filename="$( echo "${j2se_package}_"*.deb )"
+        echo "    copy $deb_filename into directory $working_dir/"
+        cp "$deb_filename" "$working_dir/"
+        if [ -n "$genchanges" ]; then
+            echo "    dpkg-genchanges"
+            local changes_filename="${deb_filename%.deb}.changes"
+            echo "    copy $changes_filename into directory $working_dir/"
+            cp "$changes_filename" "$working_dir/"
+        fi
+        cat << EOF
 
 The Debian package has been created in the current directory.
 You can install the package as root with:
@@ -219,4 +234,5 @@ You can install the package as root with:
     dpkg -i $deb_filename
 
 EOF
+    fi
 }
index 9eb0fab..826b2da 100755 (executable)
--- a/make-jpkg
+++ b/make-jpkg
@@ -31,6 +31,7 @@ else
 fi
 
 genchanges=""
+build_source=""
 
 ### check for run in fakeroot
 
@@ -82,6 +83,7 @@ The following options are recognized:
   --email EMAIL      email address used in the maintainer field of the package
   --changes          create a .changes file
   --revision         add debian revision
+  --source           build a source package instead of a binary deb package
 
   --help             display this help and exit
   --version          output version information and exit
@@ -127,6 +129,8 @@ while [[ $# -gt 0 && "x$1" == x--* ]]; do
     revision="-${1}"
     elif [[ "x$1" == x--changes ]]; then
     genchanges="true"
+    elif [[ "x$1" == x--source ]]; then
+    build_source="true"
     else
     unrecognized_option "$1"
     fi
index 2b6baad..bceec92 100644 (file)
@@ -49,6 +49,9 @@ create a .changes file
 .B --revision
 add debian revision
 .TP
+.B --source
+build a source package instead of a binary deb package
+.TP
 .B --help
 display help text and exit
 .TP