summaryrefslogtreecommitdiff
path: root/mk/pkgformat/pkg/utility.mk
blob: 31ef392318644050b9ba0e191d7072b94ef97b81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# $NetBSD: utility.mk,v 1.1 2011/10/15 00:23:09 reed Exp $

# The 'info' target can be used to display information about a package.
.PHONY: info
info:
	${RUN}${PKG_INFO} "${PKGWILDCARD}"

# The 'check' target can be used to check an installed package.
.PHONY: check
check:
	${RUN}${PKG_ADMIN} check "${PKGWILDCARD}"

# The 'list' target can be used to list the files installed by a package.
.PHONY: list
list:
	${RUN}${PKG_INFO} -L "${PKGWILDCARD}"

######################################################################
###
### The targets below should probably be removed from pkgsrc.
###
######################################################################

# show-downlevel:
#	Lists the packages whose installed version does not match the
#	current version in pkgsrc.
#
show-downlevel: .PHONY
.if defined(PKG_FAIL_REASON)
	${RUN}${DO_NADA}
.else
	${RUN}								\
	found="`${_PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`";	\
	if [ "X$$found" != "X" -a "X$$found" != "X${PKGNAME}" ]; then	\
		${ECHO} "${PKGBASE} package: $$found installed, pkgsrc version ${PKGNAME}"; \
		if [ "X$$STOP_DOWNLEVEL_AFTER_FIRST" != "X" ]; then	\
			${ECHO} "stopping after first downlevel pkg found"; \
			exit 1;						\
		fi;							\
	fi
.endif

.PHONY: show-installed-depends
show-installed-depends: # will not be removed
.if !empty(DEPENDS)
	${RUN}								\
	for i in ${DEPENDS:C/:.*$//:Q:S/\ / /g} ; do			\
		echo "$$i =>" `${_PKG_BEST_EXISTS} "$$i"`;		\
	done
.endif

.PHONY: show-needs-update
show-needs-update: _about-to-be-removed
.if !empty(DEPENDS)
	${RUN}								\
	${_DEPENDS_WALK_CMD} -r ${PKGPATH} |				\
	while read i; do						\
		cd ${PKGSRCDIR}/$$i;					\
		eval `${RECURSIVE_MAKE} ${MAKEFLAGS} show-vars-eval VARS='PKGNAME:want PKGWILDCARD:wild'`; \
		have=`${_PKG_BEST_EXISTS} "$$wild" || ${TRUE}`;		\
		if [ -z "$$have" ]; then				\
			${ECHO} "$$i => (none) => needs install of $$want"; \
		elif [ "$$have" != "$$want" ]; then			\
			${ECHO} "$$i => $$have => needs update to $$want"; \
		fi;							\
	done
.endif

.PHONY: show-pkgsrc-dir
show-pkgsrc-dir: _about-to-be-removed
.if defined(PKG_FAIL_REASON)
	${RUN}${DO_NADA}
.else
	${RUN}								\
	found="`${_PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`";	\
	if [ "X$$found" != "X" ]; then					\
		${ECHO} ${PKGPATH};					\
	fi
.endif

.PHONY: show-depends-options
show-depends-options:
	${RUN}                                                          \
	${_DEPENDS_WALK_CMD} ${PKGPATH} |                               \
	while read dir; do                                              \
		${ECHO} "===> Options for $${dir}" &&                   \
		cd ${.CURDIR}/../../$$dir &&                            \
		${RECURSIVE_MAKE} ${MAKEFLAGS} show-options;            \
	done

# Short aliases
.PHONY: sid
sid: show-installed-depends

_about-to-be-removed: .USE
	@${WARNING_MSG} "This make target (${.TARGET}) is about to be removed. Since you used"
	@${WARNING_MSG} "it, it may not be completele useless.  Please tell us on the"
	@${WARNING_MSG} "tech-pkg""@""NetBSD.org mailing list why you think this target should"
	@${WARNING_MSG} "not be removed."