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