| 1 | #!/bin/bash |
| 2 | |
| 3 | MH_VERSION=$(ls /usr/share/maven-repo/org/debian/maven/maven-packager-utils/ | sed 's|/||') |
| 4 | . /usr/share/maven-repo-helper/mh_lib.sh |
| 5 | |
| 6 | CLASSPATH="/usr/share/java/maven-repo-helper.jar:/usr/share/java/maven-packager-utils.jar" |
| 7 | |
| 8 | syntax() |
| 9 | { |
| 10 | echo -e "Usage: mh_resolve_dependencies [option]... <package>" |
| 11 | echo -e "Resolve the dependencies and generates the substvars" |
| 12 | echo -e "file containing the list of dependent packages." |
| 13 | echo -e "" |
| 14 | echo -e "Where" |
| 15 | echo -e "\t<package> is the name of the binary package," |
| 16 | echo -e "\t e.g. libcommons-lang-java. Default to the first binary" |
| 17 | echo -e "\t found in the debian/control file" |
| 18 | echo -e "Options:" |
| 19 | echo -e "\t-h --help: show this text" |
| 20 | echo -e "\t-V --version: show the version" |
| 21 | echo -e "\t-p<package> --package=<package>: name of the package" |
| 22 | echo -e "\t-j --javadoc: resolve the Javadoc dependencies" |
| 23 | echo -e "\t-n --non-interactive: non interactive mode, don't ask questions" |
| 24 | echo -e "\t-o --offline: don't ever connect to the internet, for Debian build" |
| 25 | echo -e "\t compatibility." |
| 26 | echo -e "\t-v --verbose: show more information while running" |
| 27 | echo -e "\t-b --base-directory: path to root directory of package" |
| 28 | echo -e "\t --non-explore: doesn't explore directories for pom.xml" |
| 29 | echo -e "\t --build: build mode (don't write the .poms and rules files)" |
| 30 | echo -e "" |
| 31 | echo -e "Description:" |
| 32 | echo -e "This tool reads the POM files defined in debian/$package.poms" |
| 33 | echo -e "and scans the Maven repository in /usr/share/maven-repo." |
| 34 | echo -e "It then extracts the dependencies required for the current" |
| 35 | echo -e "package and store them in the file debian/$package.substvars" |
| 36 | echo -e "where they can be read by debhelper." |
| 37 | echo -e "The variables defined are:" |
| 38 | echo -e " maven:Depends - the list of runtime dependencies" |
| 39 | echo -e " maven:OptionalDepends - the list of optional runtime dependencies" |
| 40 | echo -e " maven:CompileDepends - the list of compile-time dependencies" |
| 41 | echo -e " maven:TestDepends - the list of test dependencies" |
| 42 | exit 1 |
| 43 | } |
| 44 | |
| 45 | ARGS="p package d javadoc v verbose n non-interactive o offline b base-directory non-explore build" parseargs "$@" |
| 46 | |
| 47 | PACKAGE=$(getarg p package) |
| 48 | GEN_JAVADOC=$(getarg j javadoc) |
| 49 | NON_INTERACTIVE=$(getarg n non-interactive) |
| 50 | OFFLINE=$(getarg o offline) |
| 51 | VERBOSE=$(getarg v verbose) |
| 52 | BASE_DIR=$(getarg b base-directory) |
| 53 | NON_EXPLORE=$(getarg non-explore) |
| 54 | BUILD=$(getarg build) |
| 55 | |
| 56 | if [ -z "$PACKAGE" ]; then |
| 57 | if [ "$ARGC" -gt "0" ]; then |
| 58 | PACKAGE="${ARGV[0]}" |
| 59 | else |
| 60 | PACKAGE=$(dh_listpackages | head -1) |
| 61 | fi |
| 62 | fi |
| 63 | |
| 64 | if [ ! -e .debianVersion -a ! -e debian/stamp-poms-patched ]; then |
| 65 | touch .debianVersion |
| 66 | CREATED_POMS=false |
| 67 | if [ ! -e debian/${PACKAGE}.poms ]; then |
| 68 | CREATED_POMS=true |
| 69 | mh_lspoms $PACKAGE |
| 70 | fi |
| 71 | mh_patchpoms -p$PACKAGE --keep-pom-version |
| 72 | if [ $CREATED_POMS ]; then |
| 73 | rm debian/${PACKAGE}.poms |
| 74 | fi |
| 75 | fi |
| 76 | |
| 77 | java $JAVA_OPTS -cp $CLASSPATH org.debian.maven.packager.DependenciesSolver ${NON_INTERACTIVE:+--non-interactive} ${NON_EXPLORE:+--non-explore} ${OFFLINE:+--offline} ${BUILD:+--build} ${GEN_JAVADOC:+--generate-javadoc} ${BASE_DIR:+--base-directory=$BASE_DIR} ${VERBOSE:+--verbose} --package=$PACKAGE --maven-repo=/usr/share/maven-repo |
| 78 | |
| 79 | perl -p -i -e 's/maven\./maven:/' debian/${PACKAGE}.substvars |