From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-1125660-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id A43D2138334 for <garchives@archives.gentoo.org>; Wed, 27 Nov 2019 09:50:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4BABEE08C2; Wed, 27 Nov 2019 09:50:22 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 272B3E08C2 for <gentoo-commits@lists.gentoo.org>; Wed, 27 Nov 2019 09:50:22 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CE45834D47F for <gentoo-commits@lists.gentoo.org>; Wed, 27 Nov 2019 09:50:20 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 6760A8C3 for <gentoo-commits@lists.gentoo.org>; Wed, 27 Nov 2019 09:50:17 +0000 (UTC) From: "Miroslav Šulc" <fordfrog@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Miroslav Šulc" <fordfrog@gentoo.org> Message-ID: <1574848159.46bbaf55e2d6924a324fbff3dc0755e4ad8280eb.fordfrog@gentoo> Subject: [gentoo-commits] proj/java-ebuilder:master commit in: src/main/java/org/gentoo/java/ebuilder/maven/ X-VCS-Repository: proj/java-ebuilder X-VCS-Files: src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java X-VCS-Directories: src/main/java/org/gentoo/java/ebuilder/maven/ X-VCS-Committer: fordfrog X-VCS-Committer-Name: Miroslav Šulc X-VCS-Revision: 46bbaf55e2d6924a324fbff3dc0755e4ad8280eb X-VCS-Branch: master Date: Wed, 27 Nov 2019 09:50:17 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 49ae2299-c469-4aa8-8d3c-276fa27ab0e1 X-Archives-Hash: 1191ac5d00675e4c08bf2d8b503f0923 commit: 46bbaf55e2d6924a324fbff3dc0755e4ad8280eb Author: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org> AuthorDate: Wed Nov 27 09:44:05 2019 +0000 Commit: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org> CommitDate: Wed Nov 27 09:49:19 2019 +0000 URL: https://gitweb.gentoo.org/proj/java-ebuilder.git/commit/?id=46bbaf55 fixing download tarball name Signed-off-by: Miroslav Šulc <fordfrog <AT> gentoo.org> .../gentoo/java/ebuilder/maven/MavenEbuilder.java | 42 ++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java b/src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java index 5ddfd9b..c9ec5b9 100644 --- a/src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java +++ b/src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java @@ -7,6 +7,8 @@ import java.nio.file.Path; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.gentoo.java.ebuilder.Config; /** @@ -20,6 +22,16 @@ public class MavenEbuilder { * EAPI version. */ private static final String EAPI = "7"; + /** + * Pattern for retrieval of tarball extension. + */ + private static final Pattern PATTERN_TARBALL_EXTENSION = Pattern.compile( + "^.*((?:\\.tar)\\.\\S+)$"); + /** + * Pattern for checking whether download tarball name matches expected name. + */ + private static final Pattern PATTERN_TARBALL_NAME + = Pattern.compile("^.*/\\$\\{P\\}(?:\\.tar)\\.\\S+$"); /** * Generates ebuild from the collected information at the specified path. @@ -194,6 +206,32 @@ public class MavenEbuilder { return result; } + /** + * If the tarball name does not match pattern ${P}.ext then we will update + * it to store the tarball as ${P}.ext. + * + * @param srcUri source URI + * + * @return either original source URI or updated source URI + */ + private String improveSrcUri(final String srcUri) { + if (PATTERN_TARBALL_NAME.matcher(srcUri).matches()) { + return srcUri; + } + + final Matcher matcher = PATTERN_TARBALL_EXTENSION.matcher(srcUri); + + /** + * We do not know how to get the extension so we will leave the tarball + * name as it is. + */ + if (!matcher.matches()) { + return srcUri; + } + + return srcUri + " -> " + "${P}" + matcher.group(1); + } + /** * Merges maven project system dependencies of specified type and removed * duplicates. @@ -578,8 +616,8 @@ public class MavenEbuilder { writer.println('"'); writer.print("SRC_URI=\""); - writer.print( - replaceWithVars(config.getDownloadUri().toString(), config)); + writer.print(improveSrcUri( + replaceWithVars(config.getDownloadUri().toString(), config))); writer.println('"'); writer.print("LICENSE=\"");