pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/mk/pkgtasks
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.
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}
Home |
Main Index |
Thread Index |
Old Index