xref: /dragonfly/etc/Makefile.usr (revision 32efd857)
1# Makefile.usr - installed as /usr/Makefile
2#
3# Provides simple targets to download and maintain /usr/src, /usr/dports etc.
4
5# DragonFly BSD source repository
6GITURL_SRC?=git://git.dragonflybsd.org/dragonfly.git
7# DragonFly BSD projects repository
8GITURL_PROJECTS?=git://git.dragonflybsd.org/projects.git
9# Branch to be fetched & checked out
10# * master - latest development branch
11# * DragonFly_RELEASE_x_y - stable release branch x.y
12BRANCH?=master
13BRANCH_PROJECTS?=master
14
15# DPorts source repository
16GITURL_DPORTS?=git://mirror-master.dragonflybsd.org/dports.git
17
18# Mirror from which to fetch the pkg bootstrap
19MIRROR?=https://mirror-master.dragonflybsd.org
20
21DPTBALL=/tmp/dports.tar.gz
22PKGBALL=/tmp/pkgboot.tar.xz
23DPDLURL=https://api.github.com/repos/DragonFlyBSD/DPorts/tarball/
24PKGBOOT_VERSION=04
25PKGBOOT_x86_64=bootstrap_pkg_${PKGBOOT_VERSION}_x86-64.tar.xz
26PKGBOOT=${MIRROR}/dports/bootstraps/${PKGBOOT_${MACHINE_ARCH}}
27ERRPKG="Error: Bootstrap not necessary, ${.CURDIR}/local/sbin/pkg already exists"
28WSTARS="***************************************************************"
29WARNPS="  Warning: Delete or move ${.CURDIR}/pkg before building any dport!"
30LPATT="   make %-23s- %s\n"
31
32help all:
33	@echo "HELP:"
34	@echo
35.if exists(${.CURDIR}/dports/.git)
36	@printf ${LPATT} "dports-update"         "update your dports repository from the net"
37.else
38.  if exists(${.CURDIR}/dports)
39	@printf ${LPATT} "dports-replace"        "Replace dports with latest tarball (Github)"
40.  else
41	@printf ${LPATT} "dports-create"         "fetch initial dports repository from the net"
42	@printf ${LPATT} "dports-create-shallow" "fetch initial history-free dports repository"
43	@printf ${LPATT} "dports-download"       "download & install dports tarball (Github)"
44.  endif
45.endif
46	@echo
47	@printf ${LPATT} "pkg-bootstrap"	"Use pre-built pkg to install dports packages"
48	@printf ${LPATT} "pkg-bootstrap-force"	"Force it (pkg.conf will be overwritten)"
49	@echo
50
51.if exists(${.CURDIR}/src/.git)
52	@printf ${LPATT} "src-update"         "update your src repository from the net"
53.else
54	@printf ${LPATT} "src-create"         "fetch initial src repository from the net"
55	@printf ${LPATT} "src-create-shallow" "fetch initial history-free src repository"
56.endif
57.if exists(${.CURDIR}/projects/.git)
58	@printf ${LPATT} "projects-update"         "update your projects repository from the net"
59.else
60	@printf ${LPATT} "projects-create"         "fetch initial projects repository from the net"
61	@printf ${LPATT} "projects-create-shallow" "fetch initial history-free projects repository"
62.endif
63	@echo
64.if exists(${.CURDIR}/src-sys.tar.bz2)
65	@printf ${LPATT} "release-sys-extract" "extract the pre-packaged sys-only sources"
66	@echo
67.endif
68	@echo "src checkout branch: ${BRANCH}"
69
70git-check:
71	@/usr/bin/which -s git || \
72		(echo "git must be present on the system to use this option."; /usr/bin/false)
73
74src-check: git-check
75	@/bin/test ! -d ${.CURDIR}/src/.git || \
76		(echo "Error: ${.CURDIR}/src already exists"; /usr/bin/false)
77
78projects-check: git-check
79	@/bin/test ! -d ${.CURDIR}/projects/.git || \
80		(echo "Error: ${.CURDIR}/projects already exists"; /usr/bin/false)
81
82src-check-hasdir: git-check
83	@/bin/test -d ${.CURDIR}/src/.git || \
84		(echo "Error: ${.CURDIR}/src does not exist"; /usr/bin/false)
85
86src-create: src-check
87	@echo "If problems occur you may have to 'rm -rf src' and try again."
88	@echo
89	git clone --branch ${BRANCH} -- ${GITURL_SRC} ${.CURDIR}/src
90
91src-create-shallow: src-check
92	@echo "If problems occur you may have to 'rm -rf src' and try again."
93	@echo
94	git clone --depth 1 --branch ${BRANCH} -- ${GITURL_SRC} ${.CURDIR}/src
95
96projects-create: projects-check
97	@echo "If problems occur you may have to 'rm -rf projects' and try again."
98	@echo
99	git clone --branch ${BRANCH_PROJECTS} -- ${GITURL_PROJECTS} ${.CURDIR}/projects
100
101projects-create-shallow: projects-check
102	@echo "If problems occur you may have to 'rm -rf projects' and try again."
103	@echo
104	git clone --depth 1 --branch ${BRANCH_PROJECTS} -- ${GITURL_PROJECTS} ${.CURDIR}/projects
105
106src-update: src-check-hasdir
107	cd ${.CURDIR}/src && git pull --ff-only
108	@echo
109	@echo "To automate, feel free to run this task from cron(8)."
110
111projects-update: projects-check-hasdir
112	cd ${.CURDIR}/projects && git pull --ff-only
113	@echo
114	@echo "To automate, feel free to run this task from cron(8)."
115
116.if exists(${.CURDIR}/src-sys.tar.bz2)
117release-sys-extract:
118	cd ${.CURDIR} && tar xvpjf src-sys.tar.bz2
119.endif
120
121dports-check: git-check
122	@/bin/test ! -d ${.CURDIR}/dports/.git || \
123		   (echo "Error: ${.CURDIR}/dports already exists"; /usr/bin/false)
124
125dports-check-hasdir: git-check
126	@/bin/test -d ${.CURDIR}/dports/.git || \
127		   (echo "Error: ${.CURDIR}/dports does not exist"; /usr/bin/false)
128
129dports-download-check:
130	@/bin/test ! -d ${.CURDIR}/dports || \
131		   (echo "Error: ${.CURDIR}/dports already exists"; /usr/bin/false)
132	@/bin/test ! -d ${.CURDIR}/DragonFlyBSD-DPorts-* || \
133		   (echo "Error: ${.CURDIR}/DragonFlyBSD-DPorts-* already exists"; /usr/bin/false)
134
135dports-create: dports-check
136	@echo "If problems occur you may have to 'rm -rf dports' and try again."
137	@echo
138	git clone ${GITURL_DPORTS} ${.CURDIR}/dports
139.if exists(${.CURDIR}/pkg)
140	@echo ${WSTARS}
141	@echo ${WARNPS}
142	@echo ${WSTARS}
143.endif
144
145dports-create-shallow: dports-check
146	@echo "If problems occur you may have to 'rm -rf dports' and try again."
147	@echo
148	git clone --depth 1 ${GITURL_DPORTS} ${.CURDIR}/dports
149.if exists(${.CURDIR}/pkg)
150	@echo ${WSTARS}
151	@echo ${WARNPS}
152	@echo ${WSTARS}
153.endif
154
155dports-update: dports-check-hasdir
156	cd ${.CURDIR}/dports && git pull --ff-only
157	@echo
158	@echo "To automate, feel free to run this task from cron(8)."
159
160dports-download: dports-download-check
161	rm -f ${DPTBALL}
162	fetch -o ${DPTBALL} ${DPDLURL}
163	tar -xf ${DPTBALL} -C ${.CURDIR}
164	mv /usr/DragonFlyBSD-DPorts-* ${.CURDIR}/dports
165	rm -f ${DPTBALL}
166.if exists(${.CURDIR}/pkg)
167	@echo ${WSTARS}
168	@echo ${WARNPS}
169	@echo ${WSTARS}
170.endif
171
172# NOTE: Ignore error from rm -rf because /usr/dports might be
173#	a null-mount.  Be safe, do not wildcard /usr/dports/*.
174#
175dports-replace:
176.if exists(${.CURDIR}/dports/.git)
177	@echo "Error: ${.CURDIR}/dports is a git repository currently."
178	@echo "Remove ${.CURDIR}/dports and execute 'make dports-download' if you want"
179	@echo "to convert to a non-git version."
180	@/usr/bin/false
181.else
182	rm -f ${DPTBALL}
183	fetch -o ${DPTBALL} ${DPDLURL}
184	-rm -rf ${.CURDIR}/dports
185	tar -xf ${DPTBALL} -C ${.CURDIR}
186	mv /usr/DragonFlyBSD-DPorts-* ${.CURDIR}/dports
187	rm -f ${DPTBALL}
188.endif
189
190pkg-bootstrap-fetch:
191.if exists(/etc/ssl/cert.pem) || exists(/usr/local/etc/ssl/cert.pem)
192	fetch -o ${PKGBALL} ${PKGBOOT}
193.else
194	@echo "Warning: /etc/ssl/cert.pem and /usr/local/etc/ssl/cert.pem do not exist."
195	@echo "Disable certificate verification for fetch(1)."
196	fetch --no-verify-peer -o ${PKGBALL} ${PKGBOOT}
197.endif
198	tar -xJf ${PKGBALL} -C ${.CURDIR}/local
199	@rm -f ${PKGBALL}
200
201# This is a bit problematic
202#
203pkg-bootstrap-install:
204.if defined(ABIVERS)
205	ABI=${ABIVERS} ${.CURDIR}/local/sbin/pkg-static \
206	    install -y ${PKG_FLAGS} pkg
207.else
208	${.CURDIR}/local/sbin/pkg-static install -y ${PKG_FLAGS} pkg
209.endif
210	${.CURDIR}/local/sbin/pkg-static install -y ${PKG_FLAGS} ca_root_nss
211	cp -f ${.CURDIR}/local/etc/pkg/repos/df-latest.conf.sample \
212		${.CURDIR}/local/etc/pkg/repos/df-latest.conf \
213
214pkg-bootstrap:
215.if exists(${.CURDIR}/local/sbin/pkg)
216	@echo ${ERRPKG}
217	@/usr/bin/false
218.elif exists(${.CURDIR}/local/etc/pkg.conf)
219	@echo "Error: ${.CURDIR}/local/etc/pkg.conf will be overwritten"
220	@echo "Please move this file and rerun 'make pkg-bootstrap'"
221	@/usr/bin/false
222.else
223	@(cd ${.CURDIR} && make pkg-bootstrap-fetch)
224	@(cd ${.CURDIR} && make pkg-bootstrap-install)
225.endif
226
227# NOTE: In force mode we also have to remove any old pkg.conf
228#	which might interfere with the newer pkg bootstrap.
229#
230pkg-bootstrap-force:
231	rm -f ${.CURDIR}/local/etc/pkg.conf
232	@(cd ${.CURDIR} && make pkg-bootstrap-fetch)
233	@(cd ${.CURDIR} && make pkg-bootstrap-install PKG_FLAGS="-f")
234