From owner-svn-ports-head@freebsd.org  Mon Jan 22 16:35:24 2018
Return-Path: <owner-svn-ports-head@freebsd.org>
Delivered-To: svn-ports-head@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8118AEC9582;
 Mon, 22 Jan 2018 16:35:24 +0000 (UTC) (envelope-from tz@FreeBSD.org)
Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org
 [IPv6:2610:1c1:1:606c::19:3])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client CN "mxrelay.nyi.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 5B60A8389D;
 Mon, 22 Jan 2018 16:35:24 +0000 (UTC) (envelope-from tz@FreeBSD.org)
Received: from repo.freebsd.org (repo.freebsd.org
 [IPv6:2610:1c1:1:6068::e6a:0])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 949D51CAF1;
 Mon, 22 Jan 2018 16:35:23 +0000 (UTC) (envelope-from tz@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0MGZNV4031829;
 Mon, 22 Jan 2018 16:35:23 GMT (envelope-from tz@FreeBSD.org)
Received: (from tz@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0MGZNYs031827;
 Mon, 22 Jan 2018 16:35:23 GMT (envelope-from tz@FreeBSD.org)
Message-Id: <201801221635.w0MGZNYs031827@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: tz set sender to tz@FreeBSD.org
 using -f
From: Torsten Zuehlsdorff <tz@FreeBSD.org>
Date: Mon, 22 Jan 2018 16:35:23 +0000 (UTC)
To: ports-committers@freebsd.org, svn-ports-all@freebsd.org,
 svn-ports-head@freebsd.org
Subject: svn commit: r459673 - in head/Mk: . Scripts
X-SVN-Group: ports-head
X-SVN-Commit-Author: tz
X-SVN-Commit-Paths: in head/Mk: . Scripts
X-SVN-Commit-Revision: 459673
X-SVN-Commit-Repository: ports
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-ports-head@freebsd.org
X-Mailman-Version: 2.1.25
Precedence: list
List-Id: SVN commit messages for the ports tree for head
 <svn-ports-head.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-ports-head>, 
 <mailto:svn-ports-head-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-ports-head/>
List-Post: <mailto:svn-ports-head@freebsd.org>
List-Help: <mailto:svn-ports-head-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-ports-head>,
 <mailto:svn-ports-head-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 22 Jan 2018 16:35:24 -0000

Author: tz
Date: Mon Jan 22 16:35:23 2018
New Revision: 459673
URL: https://svnweb.freebsd.org/changeset/ports/459673

Log:
  add new stage-qa target: gemfiledeps
  
  This checks whether rubygem based ports have all of their dependencies
  in Gemfile(s) satisfied by what's currently installed. Sample output:
  
  ====> Running Q/A tests (stage-qa)
  Warning: Dependencies defined in /usr/ports/www/gitlab/work/stage/usr/local/www/gitlab/Gemfile are not satisfied
  
  These ports could (!) be broken at runtime. Be aware: some projects
  defines multiple Gemfiles and not all are used at runtime. For example
  www/gitlab has two Gemfiles, but only one is used for testing and warnings
  about it can be ignored.
  
  Approved by: portmgr (mat), lifanov
  Differential Revision: https://reviews.freebsd.org/D11865

Modified:
  head/Mk/Scripts/qa.sh
  head/Mk/bsd.port.mk

Modified: head/Mk/Scripts/qa.sh
==============================================================================
--- head/Mk/Scripts/qa.sh	Mon Jan 22 16:17:23 2018	(r459672)
+++ head/Mk/Scripts/qa.sh	Mon Jan 22 16:35:23 2018	(r459673)
@@ -841,6 +841,51 @@ gemdeps()
 	return $rc
 }
 
+# If an non rubygem-port has a 'Gemfile' file
+# it is checked with bundle to be sure
+# all dependencies are satisfied.
+# Without the check missing/wrong dependencies
+# are just found when executing the application
+gemfiledeps()
+{
+	# skip check if port does not use ruby at all
+	if [ -z "$USE_RUBY" ]; then
+		return 0
+	fi
+	
+	# skip check if port is a rubygem-* one; they have no Gemfiles
+	if [ "${PKGBASE%%-*}" = "rubygem" ]; then
+		return 0
+	fi
+	
+	# advise install of bundler if its not present for check
+	if ! type bundle > /dev/null 2>&1; then
+		notice "Please install sysutils/rubygem-bundler for additional Gemfile-checks"
+		return 0
+	fi
+ 
+	# locate the Gemfile(s)
+	while read -r f; do
+	
+		# no results presents a blank line from heredoc
+		[ -z "$f" ] && continue
+	
+		# if there is no Gemfile everything is fine - stop here
+		[ ! -f "$f" ] && return 0;
+
+		# use bundle to check if Gemfile is satisfied
+		# if bundle returns 1 the Gemfile is not satisfied
+		# and so stage-qa isn't also
+		if ! bundle check --dry-run --gemfile $f > /dev/null 2>&1; then
+			warn "Dependencies defined in ${f} are not satisfied"
+		fi
+      
+	done <<-EOF
+		$(find ${STAGEDIR} -name Gemfile)
+		EOF
+	return 0
+}
+
 flavors()
 {
 	local rc pkgnames uniques
@@ -860,7 +905,7 @@ flavors()
 
 checks="shebang symlinks paths stripped desktopfileutils sharedmimeinfo"
 checks="$checks suidfiles libtool libperl prefixvar baselibs terminfo"
-checks="$checks proxydeps sonames perlcore no_arch gemdeps flavors"
+checks="$checks proxydeps sonames perlcore no_arch gemdeps gemfiledeps flavors"
 
 ret=0
 cd ${STAGEDIR}

Modified: head/Mk/bsd.port.mk
==============================================================================
--- head/Mk/bsd.port.mk	Mon Jan 22 16:17:23 2018	(r459672)
+++ head/Mk/bsd.port.mk	Mon Jan 22 16:35:23 2018	(r459673)
@@ -1616,7 +1616,8 @@ QA_ENV+=		STAGEDIR=${STAGEDIR} \
 				PKGBASE=${PKGBASE} \
 				PORTNAME=${PORTNAME} \
 				NO_ARCH=${NO_ARCH} \
-				"NO_ARCH_IGNORE=${NO_ARCH_IGNORE}"
+				"NO_ARCH_IGNORE=${NO_ARCH_IGNORE}" \
+				USE_RUBY=${USE_RUBY}
 .if !empty(USES:Mssl)
 QA_ENV+=		USESSSL=yes
 .endif