Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK)) by mollari.NetBSD.org (Postfix) with ESMTPS id BFB437A1BE for ; Fri, 2 Jun 2017 16:12:27 +0000 (UTC) Received: by mail.netbsd.org (Postfix, from userid 605) id 5617184DAB; Fri, 2 Jun 2017 16:12:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id DB69F84DA0 for ; Fri, 2 Jun 2017 16:12:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([IPv6:::1]) by localhost (mail.netbsd.org [IPv6:::1]) (amavisd-new, port 10025) with ESMTP id DJeIxz4CCvO1 for ; Fri, 2 Jun 2017 16:12:26 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.NetBSD.org [IPv6:2001:470:a085:999:28c:faff:fe03:5984]) by mail.netbsd.org (Postfix) with ESMTP id 38F1684CD8 for ; Fri, 2 Jun 2017 16:12:26 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 36C55FBEE; Fri, 2 Jun 2017 16:12:26 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_149641994629970" MIME-Version: 1.0 Date: Fri, 2 Jun 2017 16:12:26 +0000 From: "Johnny C. Lam" Subject: CVS commit: pkgsrc/mk/pkgtasks To: pkgsrc-changes@NetBSD.org Reply-To: jlam@netbsd.org X-Mailer: log_accum Message-Id: <20170602161226.36C55FBEE@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: pkgsrc-changes.NetBSD.org Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_149641994629970 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: jlam Date: Fri Jun 2 16:12:26 UTC 2017 Modified Files: pkgsrc/mk/pkgtasks: files.mk pkgsrc/mk/pkgtasks/tests: files_test pkgtasks_test test.mk Log Message: Create ${PKG_SYSCONFDIR} automatically in "pkgtasks" framework. Add missing feature from "pkginstall" framework where the config directory ${PKG_SYSCONFDIR} was automatically created if one of the following conditions were true: * PKG_SYSCONFSUBDIR was defined and non-empty. * Any configuration files were copied into ${PKG_SYSCONFDIR}. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 pkgsrc/mk/pkgtasks/files.mk cvs rdiff -u -r1.1 -r1.2 pkgsrc/mk/pkgtasks/tests/files_test \ pkgsrc/mk/pkgtasks/tests/pkgtasks_test cvs rdiff -u -r1.2 -r1.3 pkgsrc/mk/pkgtasks/tests/test.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. --_----------=_149641994629970 Content-Disposition: inline Content-Length: 5578 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii Modified files: Index: pkgsrc/mk/pkgtasks/files.mk diff -u pkgsrc/mk/pkgtasks/files.mk:1.2 pkgsrc/mk/pkgtasks/files.mk:1.3 --- pkgsrc/mk/pkgtasks/files.mk:1.2 Fri Jun 2 16:11:47 2017 +++ pkgsrc/mk/pkgtasks/files.mk Fri Jun 2 16:12:25 2017 @@ -1,4 +1,4 @@ -# $NetBSD: files.mk,v 1.2 2017/06/02 16:11:47 jlam Exp $ +# $NetBSD: files.mk,v 1.3 2017/06/02 16:12:25 jlam Exp $ # # Copyright (c) 2017 The NetBSD Foundation, Inc. # All rights reserved. @@ -139,6 +139,23 @@ PKG_FAIL_REASON+= ${t:Q}" is liste . endif .endfor +# Hook into directories.mk to create ${PKG_SYSCONFDIR} in the package +# tasks. +# +# The following variables used are set within bsd.pkg.mk: +# +# PKG_SYSCONFDIR +# PKG_SYSCONFDIR_PERMS +# PKG_SYSCONFSUBDIR +# +.if defined(PKG_SYSCONFSUBDIR) && !empty(PKG_SYSCONFSUBDIR) +# Always create ${PKG_SYSCONFDIR} if ${PKG_SYSCONFSUBDIR} is non-empty. +MAKE_DIRS_PERMS+= ${PKG_SYSCONFDIR} ${PKG_SYSCONFDIR_PERMS} +.elif !empty(_ALL_FILES.files:M${PKG_SYSCONFDIR}/*) +# Create ${PKG_SYSCONFDIR} if any target files are in that directory. +MAKE_DIRS+= ${PKG_SYSCONFDIR} +.endif + _PKGTASKS_DATA.files= ${_PKGTASKS_DIR}/files _PKGTASKS_DATAFILES+= ${_PKGTASKS_DATA.files} Index: pkgsrc/mk/pkgtasks/tests/files_test diff -u pkgsrc/mk/pkgtasks/tests/files_test:1.1 pkgsrc/mk/pkgtasks/tests/files_test:1.2 --- pkgsrc/mk/pkgtasks/tests/files_test:1.1 Thu Jun 1 02:06:05 2017 +++ pkgsrc/mk/pkgtasks/tests/files_test Fri Jun 2 16:12:26 2017 @@ -1,6 +1,6 @@ #!/usr/bin/env atf-sh # -# $NetBSD: files_test,v 1.1 2017/06/01 02:06:05 jlam Exp $ +# $NetBSD: files_test,v 1.2 2017/06/02 16:12:26 jlam Exp $ # # Copyright (c) 2017 The NetBSD Foundation, Inc. # All rights reserved. @@ -161,8 +161,98 @@ EOF atf_pass } +### +### test3 +### + +atf_test_case test3 + +test3_head() +{ + atf_set "descr" "PKG_SYSCONFSUBDIR triggers MAKE_DIRS_PERMS" +} + +test3_body() +{ + : ${MAKE:=make} + : ${PKGSRCDIR:=/usr/pkgsrc} + + # Setup + setup + + cat > mk.conf << 'EOF' +PKG_SYSCONFSUBDIR= pkgname +PKG_SYSCONFDIR_PERMS= root wheel 0755 +EOF + echo "/etc/pkgname root wheel 0755" > expected + ${MAKE} show-var VARNAME=MAKE_DIRS_PERMS \ + PKGSRCDIR="${PKGSRCDIR}" > value + cmp expected value || + atf_fail "PKG_SYSCONFSUBDIR not in MAKE_DIRS_PERMS" + atf_pass +} + +### +### test4 +### + +atf_test_case test4 + +test4_head() +{ + atf_set "descr" "CONF_FILES into PKG_SYSCONFDIR triggers MAKE_DIRS" +} + +test4_body() +{ + : ${MAKE:=make} + : ${PKGSRCDIR:=/usr/pkgsrc} + + # Setup + setup + + cat > mk.conf << 'EOF' +CONF_FILES+= source ${PKG_SYSCONFDIR}/target +EOF + echo "/etc" > expected + ${MAKE} show-var VARNAME=MAKE_DIRS PKGSRCDIR="${PKGSRCDIR}" > value + cmp expected value || atf_fail "PKG_SYSCONFDIR not in MAKE_DIRS" + atf_pass +} + +### +### test5 +### + +atf_test_case test5 + +test5_head() +{ + atf_set "descr" "CONF_FILES outside of PKG_SYSCONFDIR" +} + +test5_body() +{ + : ${MAKE:=make} + : ${PKGSRCDIR:=/usr/pkgsrc} + + # Setup + setup + + cat > mk.conf << 'EOF' +CONF_FILES+= source target +EOF + echo > expected + ${MAKE} show-var VARNAME=MAKE_DIRS PKGSRCDIR="${PKGSRCDIR}" > value + cmp expected value || atf_fail "MAKE_DIRS not empty" + atf_pass +} + atf_init_test_cases() { atf_add_test_case test1 atf_add_test_case test2 + atf_add_test_case test3 + atf_add_test_case test4 + atf_add_test_case test5 } Index: pkgsrc/mk/pkgtasks/tests/pkgtasks_test diff -u pkgsrc/mk/pkgtasks/tests/pkgtasks_test:1.1 pkgsrc/mk/pkgtasks/tests/pkgtasks_test:1.2 --- pkgsrc/mk/pkgtasks/tests/pkgtasks_test:1.1 Thu Jun 1 02:06:05 2017 +++ pkgsrc/mk/pkgtasks/tests/pkgtasks_test Fri Jun 2 16:12:26 2017 @@ -1,6 +1,6 @@ #!/usr/bin/env atf-sh # -# $NetBSD: pkgtasks_test,v 1.1 2017/06/01 02:06:05 jlam Exp $ +# $NetBSD: pkgtasks_test,v 1.2 2017/06/02 16:12:26 jlam Exp $ # # Copyright (c) 2017 The NetBSD Foundation, Inc. # All rights reserved. @@ -77,14 +77,15 @@ test1_body() cat > mk.conf << 'EOF' MAKE_DIRS+= dir -CONF_FILES+= source target +CONF_FILES+= source ${PKG_SYSCONFDIR}/target PKG_GROUPS+= g1 PKG_USERS+= u1:g1 EOF # Expected output. cat > expected << 'EOF' # DIR: dir m -# FILE: target c source 0644 +# DIR: /etc m +# FILE: /etc/target c source 0644 # GROUP: g1 # USER: u1:g1:::/nonexistent:/sbin/nologin EOF @@ -120,7 +121,7 @@ test2_body() cat > mk.conf << 'EOF' MAKE_DIRS+= dir -CONF_FILES+= source target +CONF_FILES+= source ${PKG_SYSCONFDIR}/target PKG_GROUPS+= g1 PKG_USERS+= u1:g1 EOF Index: pkgsrc/mk/pkgtasks/tests/test.mk diff -u pkgsrc/mk/pkgtasks/tests/test.mk:1.2 pkgsrc/mk/pkgtasks/tests/test.mk:1.3 --- pkgsrc/mk/pkgtasks/tests/test.mk:1.2 Fri Jun 2 16:11:24 2017 +++ pkgsrc/mk/pkgtasks/tests/test.mk Fri Jun 2 16:12:26 2017 @@ -1,4 +1,4 @@ -# $NetBSD: test.mk,v 1.2 2017/06/02 16:11:24 jlam Exp $ +# $NetBSD: test.mk,v 1.3 2017/06/02 16:12:26 jlam Exp $ # # Copyright (c) 2017 The NetBSD Foundation, Inc. # All rights reserved. @@ -39,7 +39,7 @@ LOCALBASE?= /usr/pkg MKDIR?= mkdir -p MV?= mv NOLOGIN?= /sbin/nologin -PKG_SYSCONFDIR?= /etc +PKG_SYSCONFBASE?= /etc PREFIX?= ${LOCALBASE} RM?= rm RUN?= @ @@ -48,6 +48,8 @@ STEP_MSG?= ${ECHO} ">>>" TEST?= test VARBASE?= /var +PKG_SYSCONFDIR= ${PKG_SYSCONFSUBDIR:D${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}:U${PKG_SYSCONFBASE}} + # Override any other default definitions so that generated files go into # the current directory. # @@ -59,3 +61,7 @@ all: _all .PHONY: _all _all: ${RUN}: "do nothing" + +# Target to write the value of a variable to standard output. +show-var: .PHONY + @echo ${${VARNAME}:Q} --_----------=_149641994629970--