Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / mk / pkgformat / pkg / views.mk
blob623a36fccf8e438924ff45f4819a6dcea7af130b
1 # $NetBSD: views.mk,v 1.6 2009/03/17 22:13:36 rillig Exp $
3 # By default, all packages attempt to link into the views.
4 .if ${PKG_INSTALLATION_TYPE} == "pkgviews"
5 BUILD_VIEWS?= yes
6 .endif
8 # DEFAULT_VIEW.${PKGBASE} default view for ${PKGBASE}
9 # VIEWBASE base location of files at run-time
11 DEFAULT_VIEW.${PKGBASE}?= ${DEFAULT_VIEW}
12 .if ${PKG_INSTALLATION_TYPE} == "pkgviews"
13 . if empty(DEFAULT_VIEW.${PKGBASE}:M"")
14 VIEWBASE= ${LOCALBASE}/${DEFAULT_VIEW.${PKGBASE}}
15 . else
16 VIEWBASE= ${LOCALBASE}
17 . endif
18 .elif ${PKG_INSTALLATION_TYPE} == "overwrite"
19 VIEWBASE= ${PREFIX}
20 .endif
21 MAKE_ENV+= VIEWBASE=${VIEWBASE}
23 PKGVIEWS+= ${DEFAULT_VIEW.${PKGBASE}}
25 .if ${PKG_INSTALLATION_TYPE} == "pkgviews"
26 privileged-install-hook: build-views
27 .endif
29 ######################################################################
30 ### build-views, su-build-views (PRIVATE)
31 ######################################################################
32 ### build-views adds the package to each view in PKGVIEWS.
33 ###
34 .PHONY: build-views su-build-views
35 build-views: su-target
36 @${STEP_MSG} "Building views for ${PKGNAME}"
38 su-build-views:
39 ${RUN} \
40 ${MKDIR} ${LOCALBASE}; \
41 for v in ${PKGVIEWS}; do \
42 case "$$v" in \
43 "") dbdir=${PKG_DBDIR}; viewname=standard ;; \
44 *) dbdir=${LOCALBASE}/$$v/.dbdir; viewname=$$v ;; \
45 esac; \
46 ${STEP_MSG} "Performing package view clash check for ${PKGNAME} in $$viewname view"; \
47 pkg=`${PKG_INFO_CMD} -K $$dbdir -e ${PKGBASE} || ${TRUE}`; \
48 case "$$pkg" in \
49 "") ;; \
50 *) ${WARNING_MSG} "${PKGBASE} exists in $$viewname view - package $$pkg ***"; \
51 ${WARNING_MSG} "Not hoisting ${PKGNAME} into $$viewname view"; \
52 continue; \
53 ;; \
54 esac; \
55 ${STEP_MSG} "Performing package view overwrite check for ${PKGNAME} in $$viewname view"; \
56 dups=`${PKGSRC_SETENV} PLIST_IGNORE_FILES=${_PLIST_IGNORE_FILES:Q} ${PKG_VIEW} --view=$$v check ${PKGNAME} || ${TRUE}`; \
57 case "$$dups" in \
58 "") ;; \
59 *) ${WARNING_MSG} "***********************************************************"; \
60 ${WARNING_MSG} "**** The following symbolic links will be overwritten *****"; \
61 for f in $$dups; do \
62 ${LS} -l ${LOCALBASE}/$$v/$$f | ${WARNING_CAT}; \
63 done; \
64 ${WARNING_MSG} "***********************************************************"; \
65 ;; \
66 esac; \
67 ${STEP_MSG} "Linking package into $$viewname view"; \
68 ${PKGSRC_SETENV} PLIST_IGNORE_FILES=${_PLIST_IGNORE_FILES:Q} ${PKG_VIEW} --view=$$v add ${PKGNAME}; \
69 done
71 ######################################################################
72 ### remove-views, su-remove-views (PRIVATE)
73 ######################################################################
74 ### remove-views removes the package from each view in PKGVIEWS.
75 ###
76 .PHONY: remove-views su-remove-views
77 remove-views: su-target
78 @${STEP_MSG} "Removing ${PKGNAME} from views"
80 su-remove-views:
81 ${RUN} \
82 for v in "" ${PKGVIEWS}; do \
83 ${TEST} -n "$$v" || continue; \
84 case "$$v" in \
85 "") dbdir=${PKG_DBDIR}; viewname=standard ;; \
86 *) dbdir=${LOCALBASE}/$$v/.dbdir; viewname=$$v ;; \
87 esac; \
88 ${STEP_MSG} "Removing package from $$viewname view"; \
89 ${PKGSRC_SETENV} PLIST_IGNORE_FILES=${_PLIST_IGNORE_FILES:Q} ${PKG_VIEW} --view=$$v delete ${PKGNAME}; \
90 done