| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. -e |
| 2 | |
| 3 | MH_VERSION=$(lsscip-shell system . . ls. /usr/share/maven-repo/org/debian/maven/maven-packager-utils/scip-shell filesystem . . `/usr/share/maven-repo/org/debian/maven/maven-packager-utils/`. | sedscip-shell system . . sed. 's|/||') |
| 4 | . /usr/share/maven-repo-helper/mh_lib.shscip-shell source . . `/usr/share/maven-repo-helper/mh_lib.sh`. |
| 5 | |
| 6 | syntaxscip-shell shell shell-project 0.0.0 syntax().() |
| 7 | { |
| 8 | echoscip-shell system . . echo. -e "Usage: mh_make [option]..." |
| 9 | echoscip-shell system . . echo. -e "Generate the Debian packaging by reading the information" |
| 10 | echoscip-shell system . . echo. -e "from the Maven POM." |
| 11 | echoscip-shell system . . echo. -e "" |
| 12 | echoscip-shell system . . echo. -e "Options:" |
| 13 | echoscip-shell system . . echo. -e "\t-h --help: show this text" |
| 14 | echoscip-shell system . . echo. -e "\t-V --version: show the version" |
| 15 | echoscip-shell system . . echo. -e "\t-s<svn url> --from-svn=<svn url>: download the source code from" |
| 16 | echoscip-shell system . . echo. -e "\t the SVN repository before building the Debian packaging. Use a tagged" |
| 17 | echoscip-shell system . . echo. -e "\t branch of the source code, for example" |
| 18 | echoscip-shell system . . echo. -e "\t http://svn.apache.org/repos/asf/felix/releases/org.osgi.core-1.2.0/" |
| 19 | echoscip-shell system . . echo. -e "\t-p<package> --package=<package>: name of the source package" |
| 20 | echoscip-shell system . . echo. -e "\t-b<package> --bin-package=<package>: name of the binary package" |
| 21 | echoscip-shell system . . echo. -e "\t-t<true|false> --run-tests=<true|false>: include or not the tests" |
| 22 | echoscip-shell system . . echo. -e "\t-d<true|false> --javadoc=<true|false>: include or not the javadoc" |
| 23 | echoscip-shell system . . echo. -e "\t during the build" |
| 24 | echoscip-shell system . . echo. -e "\t-n --non-interactive: non interactive mode, don't ask questions" |
| 25 | echoscip-shell system . . echo. -e "\t-v --verbose: show more information while running" |
| 26 | echoscip-shell system . . echo. -e "" |
| 27 | echoscip-shell system . . echo. -e "To have mh_make working properly, you need first to install on your system" |
| 28 | echoscip-shell system . . echo. -e "as many dependencies for your project as possible. Those dependencies should" |
| 29 | echoscip-shell system . . echo. -e "also contain the required Maven metadata (POM files and jars in the" |
| 30 | echoscip-shell system . . echo. -e "/usr/share/maven-repo repository)scip-shell filesystem . . `/usr/share/maven-repo repository)`." |
| 31 | echoscip-shell system . . echo. -e "" |
| 32 | echoscip-shell system . . echo. -e "Environment variables:" |
| 33 | echoscip-shell system . . echo. -e "\tDEBFULLNAME - your full name, e.g. John Doe" |
| 34 | echoscip-shell system . . echo. -e "\tDEBEMAIL - your packager email address" |
| 35 | echoscip-shell system . . echo. -e "\tDEBLICENSE - the license for the files under the debian/ directory" |
| 36 | echoscip-shell system . . echo. -e "\t must be one of GPL2, GPL3, LGPL2.1, Apache-2.0, BSD or any license" |
| 37 | echoscip-shell system . . echo. -e "\t short name defined in http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/" |
| 38 | exit 1 |
| 39 | } |
| 40 | |
| 41 | ARGS="p package b bin-package t run-tests d javadoc v verbose n non-interactive s from-svn" parseargs "$@" |
| 42 | |
| 43 | if [scip-shell system . . `[`. -z "$DEBFULLNAME" ]; then |
| 44 | echoscip-shell system . . echo. "Please define the environment variable DEBFULLNAME, e.g." |
| 45 | echoscip-shell system . . echo. "export DEBFULLNAME=\"John Doe\"" |
| 46 | exit 1 |
| 47 | fi |
| 48 | |
| 49 | if [scip-shell system . . `[`. -z "$DEBEMAIL" ]; then |
| 50 | # Fall back on EMAIL when DEBEMAIL is not defined |
| 51 | DEBEMAIL=$EMAIL |
| 52 | fi |
| 53 | |
| 54 | if [scip-shell system . . `[`. -z "$DEBEMAIL" ]; then |
| 55 | echoscip-shell system . . echo. "Please define the environment variable DEBEMAIL, e.g." |
| 56 | echoscip-shell system . . echo. "export DEBEMAIL=\"[email protected]\"" |
| 57 | exit 1 |
| 58 | fi |
| 59 | |
| 60 | if [scip-shell system . . `[`. -z "$DEBLICENSE" ]; then |
| 61 | echoscip-shell system . . echo. "Environment variable DEBLICENSE not set, using Apache-2.0 by default" |
| 62 | DEBLICENSE="Apache-2.0" |
| 63 | fi |
| 64 | |
| 65 | PACKAGE=$(getarg p package) |
| 66 | BIN_PACKAGE=$(getarg b bin-package) |
| 67 | RUN_TESTS=$(getarg t run-tests) |
| 68 | GEN_JAVADOC=$(getarg d javadoc) |
| 69 | FROM_SVN=$(getarg s from-svn) |
| 70 | VERBOSE=$(getarg v verbose) |
| 71 | NON_INTERACTIVE=$(getarg n non-interactive) |
| 72 | |
| 73 | if [scip-shell system . . `[`. "$FROM_SVN" == "true" ]; then |
| 74 | echoscip-shell system . . echo. "The syntax for the --from-svn option is --from-svn=<url>, please try again" |
| 75 | exit 1 |
| 76 | fi |
| 77 | |
| 78 | if [scip-shell system . . `[`. -z "$PACKAGE" ]; then |
| 79 | PACKAGE="$(basenamescip-shell system . . basename. $(pwdscip-shell system . . pwd.) | sedscip-shell system . . sed. 's/-[0-9\.].*//')" |
| 80 | if [scip-shell system . . `[`. -n "$FROM_SVN" ]; then |
| 81 | PACKAGE=$(echoscip-shell system . . echo. "$FROM_SVN" | sedscip-shell system . . sed. 's/-[0-9].*//') |
| 82 | PACKAGE=$(echoscip-shell system . . echo. "$PACKAGE" | sedscip-shell system . . sed. 's|.*/||' ) |
| 83 | fi |
| 84 | if [scip-shell system . . `[`. "$NON_INTERACTIVE" != true ]; then |
| 85 | echoscip-shell system . . echo. |
| 86 | echoscip-shell system . . echo. "Enter the name of the new Debian source package:" |
| 87 | read -p "[$PACKAGE] > " USER_PACKAGE |
| 88 | if [scip-shell system . . `[`. -n "$USER_PACKAGE" ]; then |
| 89 | PACKAGE=$USER_PACKAGE |
| 90 | fi |
| 91 | else |
| 92 | echoscip-shell system . . echo. "Using source package name $PACKAGE, override with option --package=<package>." |
| 93 | fi |
| 94 | fi |
| 95 | |
| 96 | if [scip-shell system . . `[`. -z "$BIN_PACKAGE" ]; then |
| 97 | PKG=$PACKAGE |
| 98 | if [scip-shell system . . `[`. -z "${PKG##lib*-java}" ]; then |
| 99 | BIN_PACKAGE="${PACKAGE}" |
| 100 | else |
| 101 | BIN_PACKAGE="lib${PACKAGE}-java" |
| 102 | fi |
| 103 | if [scip-shell system . . `[`. "$NON_INTERACTIVE" != true ]; then |
| 104 | echoscip-shell system . . echo. |
| 105 | echoscip-shell system . . echo. "Enter the name of the binary package:" |
| 106 | read -p "[$BIN_PACKAGE] > " USER_PACKAGE |
| 107 | if [scip-shell system . . `[`. -n "$USER_PACKAGE" ]; then |
| 108 | BIN_PACKAGE=$USER_PACKAGE |
| 109 | fi |
| 110 | else |
| 111 | echoscip-shell system . . echo. "Using binary package name $PACKAGE, override with option --bin-package=<package>." |
| 112 | fi |
| 113 | fi |
| 114 | |
| 115 | if [scip-shell system . . `[`. -z "$RUN_TESTS" ]; then |
| 116 | RUN_TESTS="true" |
| 117 | if [scip-shell system . . `[`. "$NON_INTERACTIVE" != true ]; then |
| 118 | echoscip-shell system . . echo. |
| 119 | echoscip-shell system . . echo. "Run tests while building the package?" |
| 120 | read -p "[Y/n] > " RUN |
| 121 | if [scip-shell system . . `[`. "$RUN" == "n" ]; then |
| 122 | RUN_TESTS= |
| 123 | fi |
| 124 | else |
| 125 | echoscip-shell system . . echo. "Tests will be run whilst building the package, override with option --run-tests=false." |
| 126 | fi |
| 127 | elif [scip-shell system . . `[`. "$RUN_TESTS"="false" ]; then |
| 128 | RUN_TESTS= |
| 129 | fi |
| 130 | |
| 131 | |
| 132 | if [scip-shell system . . `[`. -z "$GEN_JAVADOC" ]; then |
| 133 | GEN_JAVADOC="false" |
| 134 | if [scip-shell system . . `[`. "$NON_INTERACTIVE" != true ]; then |
| 135 | echoscip-shell system . . echo. |
| 136 | echoscip-shell system . . echo. "Generate the Javadoc while building the package?" |
| 137 | read -p "[y/N] > " GEN |
| 138 | if [scip-shell system . . `[`. "$GEN" == "y" ]; then |
| 139 | GEN_JAVADOC="true" |
| 140 | fi |
| 141 | else |
| 142 | echoscip-shell system . . echo. "Javadoc will not be generated whilst building the package, override with option --javadoc=true." |
| 143 | fi |
| 144 | elif [scip-shell system . . `[`. "$GEN_JAVADOC"="false" ]; then |
| 145 | GEN_JAVADOC= |
| 146 | fi |
| 147 | |
| 148 | echoscip-shell system . . echo. |
| 149 | echoscip-shell system . . echo. "Checking that apt-file is installed and has been configured..." |
| 150 | if [scip-shell system . . `[`. ! -x /usr/bin/apt-filescip-shell filesystem . . `/usr/bin/apt-file`. ]; then |
| 151 | echoscip-shell system . . echo. "Error: apt-file is not available." >&2 |
| 152 | echoscip-shell system . . echo. "Please install the 'apt-file' package and try again." >&2 |
| 153 | exit 1 |
| 154 | else |
| 155 | res="ok" |
| 156 | apt-file search /usr/share/maven/bin/mvnDebugscip-shell filesystem . . `/usr/share/maven/bin/mvnDebug`. | grepscip-shell system . . grep. maven > /dev/nullscip-shell filesystem . . `/dev/null`. || res="failed" |
| 157 | if [scip-shell system . . `[`. $? != 0 ] || [scip-shell system . . `[`. "$res" == "failed" ]; then |
| 158 | echoscip-shell system . . echo. "Warning: apt-file doesn't seem to be configured" |
| 159 | apt-file update |
| 160 | else |
| 161 | echoscip-shell system . . echo. '[ok]' |
| 162 | fi |
| 163 | fi |
| 164 | |
| 165 | echoscip-shell system . . echo. |
| 166 | echoscip-shell system . . echo. "Checking that licensecheck is installed..." |
| 167 | if [scip-shell system . . `[`. ! -x /usr/bin/licensecheckscip-shell filesystem . . `/usr/bin/licensecheck`. ]; then |
| 168 | echoscip-shell system . . echo. "Error: licensecheck is not available." >&2 |
| 169 | echoscip-shell system . . echo. "Please install the 'licensecheck' package and try again." >&2 |
| 170 | exit 1 |
| 171 | else |
| 172 | echoscip-shell system . . echo. '[ok]' |
| 173 | fi |
| 174 | |
| 175 | if [scip-shell system . . `[`. -n "$FROM_SVN" ]; then |
| 176 | echoscip-shell system . . echo. |
| 177 | echoscip-shell system . . echo. "Downloading the upstream sources..." |
| 178 | SVN_OPTIONS= |
| 179 | if [[ "$FROM_SVN" =~ https://.*\.dev\.java\.net/.* ]]; then |
| 180 | echoscip-shell system . . echo. "Press enter if a password is asked" |
| 181 | SVN_OPTIONS="--username guest" |
| 182 | fi |
| 183 | svn export $FROM_SVN $PACKAGE $SVN_OPTIONS |
| 184 | cd $PACKAGE |
| 185 | fi |
| 186 | |
| 187 | if [scip-shell system . . `[`. -e pom.xml.save ]; then |
| 188 | mh_unpatchpoms -p$BIN_PACKAGE |
| 189 | fi |
| 190 | |
| 191 | # Restore state after a brutal stop |
| 192 | if [scip-shell system . . `[`. -f debian/$BIN_PACKAGE.poms ]; then |
| 193 | mh_unpatchpoms -p$BIN_PACKAGE || truescip-shell system . . true. |
| 194 | fi |
| 195 | if [scip-shell system . . `[`. -f debian/patches/series ]; then |
| 196 | quiltscip-shell system . . quilt. pop -a || truescip-shell system . . true. |
| 197 | fi |
| 198 | |
| 199 | # Apply existing quilt patchs as source 3(quilt) is used in the package |
| 200 | if [scip-shell system . . `[`. -f debian/patches/series ]; then |
| 201 | quiltscip-shell system . . quilt. push -a |
| 202 | fi |
| 203 | |
| 204 | echoscip-shell system . . echo. |
| 205 | javascip-shell system . . java. -cp /usr/share/java/maven-project.jar:/usr/share/java/maven-repo-helper.jar:/usr/share/java/maven-packager-utils.jar:/usr/share/maven2/lib/maven-debian-uber.jarscip-shell filesystem . . `/usr/share/java/maven-project.jar:/usr/share/java/maven-repo-helper.jar:/usr/share/java/maven-packager-utils.jar:/usr/share/maven2/lib/maven-debian-uber.jar`. org.debian.maven.packager.DependenciesSolver --package="$BIN_PACKAGE" ${GEN_JAVADOC:+--generate-javadoc} ${RUN_TESTS:+--run-tests} ${VERBOSE:+--verbose} ${NON_INTERACTIVE:+--non-interactive} --maven-repo=/usr/share/maven-repo |
| 206 | |
| 207 | if [scip-shell system . . `[`. $? != 0 ]; then |
| 208 | if [scip-shell system . . `[`. -f debian/patches/series ]; then |
| 209 | quiltscip-shell system . . quilt. pop -a |
| 210 | fi |
| 211 | exit 1 |
| 212 | fi |
| 213 | |
| 214 | eval $(catscip-shell system . . cat. debian/$BIN_PACKAGE.substvars | sedscip-shell system . . sed. -e 's/maven\./maven_/' | grepscip-shell system . . grep. maven_UpstreamPackageVersion) |
| 215 | |
| 216 | mh_patchpoms ${VERBOSE:+--verbose} -p$BIN_PACKAGE -rdebian/maven.rules -idebian/maven.ignoreRules --keep-pom-version |
| 217 | |
| 218 | mvn org.debian.maven:maven-packager-utils:$MH_VERSION:generate -Demail="$DEBEMAIL" -Dpackager="$DEBFULLNAME" -DpackagerLicense="$DEBLICENSE" -Dpackage="$PACKAGE" -Dbin.package="$BIN_PACKAGE" -DrunTests="$RUN_TESTS" -DgenerateJavadoc="$GEN_JAVADOC" -Dmaven.repo.local=/usr/share/maven-repo ${FROM_SVN:+-DdownloadUrl=scm:svn:$FROM_SVN} --offline |
| 219 | |
| 220 | if [scip-shell system . . `[`. $? != 0 ]; then |
| 221 | if [scip-shell system . . `[`. -f debian/$BIN_PACKAGE.poms ]; then |
| 222 | mh_unpatchpoms -p$BIN_PACKAGE |
| 223 | fi |
| 224 | if [scip-shell system . . `[`. -f debian/patches/series ]; then |
| 225 | quiltscip-shell system . . quilt. pop -a |
| 226 | fi |
| 227 | exit 1 |
| 228 | fi |
| 229 | |
| 230 | if [scip-shell system . . `[`. ! -f debian/changelog ]; then |
| 231 | debianVersion=$(echoscip-shell system . . echo. ${maven_UpstreamPackageVersion} | sedscip-shell system . . sed. -re's/-(alpha|beta|rc)-?/~\1/') |
| 232 | dchscip-shell system . . dch. --create --newversion=${debianVersion}-1 --package=$PACKAGE "Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP>" |
| 233 | fi |
| 234 | |
| 235 | if [scip-shell system . . `[`. -f debian/$BIN_PACKAGE.poms ]; then |
| 236 | mh_unpatchpoms -p$BIN_PACKAGE |
| 237 | fi |
| 238 | if [scip-shell system . . `[`. -f debian/patches/series ]; then |
| 239 | quiltscip-shell system . . quilt. pop -a |
| 240 | fi |
| 241 | |
| 242 | rmscip-shell system . . rm. -f debian/*.substvars |
| 243 | rmscip-shell system . . rm. -f .debianVersion |
| 244 | rmscip-shell system . . rm. -f velocity.log |