xref: /dragonfly/etc/Makefile.usr (revision d4ef6694)
1# Makefile.usr - installed as /usr/Makefile
2#
3# Provides simple targets to download and maintain /usr/src, /usr/dports etc.
4
5GITHOST?=git.dragonflybsd.org
6
7THISGIT!= which git 2>/dev/null; echo
8DPTBALL=/tmp/dports.tar.gz
9PKGBALL=/tmp/pkgboot.tar.xz
10DPDLURL=https://api.github.com/repos/DragonFlyBSD/DPorts/tarball/
11PKGBOOT_VERSION=02
12PKGBOOT_i386=bootstrap_pkg_${PKGBOOT_VERSION}_x86-32.tar.xz
13PKGBOOT_x86_64=bootstrap_pkg_${PKGBOOT_VERSION}_x86-64.tar.xz
14PKGBOOT=http://mirror-master.dragonflybsd.org/dports/bootstraps/${PKGBOOT_${MACHINE_ARCH}}
15GITNFMSG="git must be present on the system to use this option."
16ERRDP="Error: ${.CURDIR}/dports already exists"
17ERRSR="Error: ${.CURDIR}/src already exists"
18ERRNDP="Error: ${.CURDIR}/dports does not exist"
19ERRNSR="Error: ${.CURDIR}/src does not exist"
20ERRPKG="Error: Bootstrap not neccessary, ${.CURDIR}/local/sbin/pkg already exists"
21WSTARS="***************************************************************"
22WARNPS="  Warning: Delete or move ${.CURDIR}/pkg before building any dport!"
23LPATT="   make %-23s- %s\n"
24
25help all:
26	@echo "HELP:"
27	@echo
28.if exists(${.CURDIR}/dports/.git)
29	@printf ${LPATT} "dports-update"         "update your dports repository from the net"
30.else
31.  if exists(${.CURDIR}/dports)
32	@printf ${LPATT} "dports-replace"        "Replace dports with latest tarball (Github)"
33.  else
34	@printf ${LPATT} "dports-create"         "fetch initial dports repository from the net"
35	@printf ${LPATT} "dports-create-shallow" "fetch initial history-free dports repository"
36	@printf ${LPATT} "dports-download"       "download & install dports tarball (Github)"
37.  endif
38.endif
39	@printf ${LPATT} "pkg-bootstrap"	"Use pre-built pkg to install dports packages"
40	@printf ${LPATT} "pkg-bootstrap-force"	"Force it (pkg.conf will be overwritten)"
41	@echo
42
43.if exists(${.CURDIR}/src/.git)
44.if exists(${.CURDIR}/src/Makefile)
45	@printf ${LPATT} "src-update"         "update your src repository from the net"
46.else
47	@printf ${LPATT} "src-checkout"       "Initial checkout of src repository"
48.endif
49.else
50	@printf ${LPATT} "src-create"         "fetch initial src repository from the net"
51	@printf ${LPATT} "src-create-shallow" "fetch initial history-free src repository"
52	@printf ${LPATT} "src-create-repo"    "fetch src repository only, no checkout"
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 "If automating please feel free to run git pull's from cron."
60	@echo "We prefer once a day but you can run them more often if you desire"
61
62src-create-repo:
63.if empty(THISGIT)
64	@echo ${GITNFMSG}
65.elif exists (${.CURDIR}/src)
66	@echo ${ERRSR}
67.else
68	@echo "If problems occur you may have to rm -rf src and try again."
69	@echo
70	mkdir -p ${.CURDIR}/src
71	cd ${.CURDIR}/src && git init
72	cd ${.CURDIR}/src && \
73		git remote add origin git://${GITHOST}/dragonfly.git
74	cd ${.CURDIR}/src && git fetch origin
75	cd ${.CURDIR}/src && git branch master origin/master
76.endif
77
78src-create: src-create-repo
79.if empty(THISGIT)
80	@echo ${GITNFMSG}
81.elif exists (${.CURDIR}/src)
82	@echo ${ERRSR}
83.else
84	cd ${.CURDIR}/src && git checkout master
85	cd ${.CURDIR}/src && git pull
86.endif
87
88src-create-shallow:
89.if empty(THISGIT)
90	@echo ${GITNFMSG}
91.elif exists (${.CURDIR}/src)
92	@echo ${ERRSR}
93.else
94	@echo "If problems occur you may have to rm -rf src and try again."
95	@echo
96	mkdir -p ${.CURDIR}/src
97	cd ${.CURDIR}/src && git init
98	cd ${.CURDIR}/src && \
99	    git remote add origin git://${GITHOST}/dragonfly.git
100	cd ${.CURDIR}/src && git fetch --depth=1 origin
101	cd ${.CURDIR}/src && git branch master origin/master
102	cd ${.CURDIR}/src && git checkout master
103	cd ${.CURDIR}/src && git pull
104.endif
105
106src-checkout:
107.if empty(THISGIT)
108	@echo ${GITNFMSG}
109.elif !exists (${.CURDIR}/src)
110	@echo ${ERRNSR}
111.else
112	cd ${.CURDIR}/src && git checkout master
113.endif
114
115src-update:
116.if empty(THISGIT)
117	@echo ${GITNFMSG}
118.elif !exists (${.CURDIR}/src)
119	@echo ${ERRNSR}
120.else
121	cd ${.CURDIR}/src && git pull
122.endif
123
124release-sys-extract:
125	cd ${.CURDIR} && tar xvpjf src-sys.tar.bz2
126
127dports-update:
128.if empty(THISGIT)
129	@echo ${GITNFMSG}
130.elif !exists (${.CURDIR}/dports)
131	@echo ${ERRNDP}
132.else
133	cd ${.CURDIR}/dports && git pull
134.endif
135
136dports-create:
137.if empty(THISGIT)
138	@echo ${GITNFMSG}
139.elif exists (${.CURDIR}/dports)
140	@echo ${ERRDP}
141.else
142	@echo "If problems occur you may have to rm -rf dports and try again."
143	@echo
144	git clone git://mirror-master.dragonflybsd.org/dports.git ${.CURDIR}/dports
145.if exists(${.CURDIR}/pkg)
146	@echo ${WSTARS}
147	@echo ${WARNPS}
148	@echo ${WSTARS}
149.endif
150.endif
151
152dports-create-shallow:
153.if empty(THISGIT)
154	@echo ${GITNFMSG}
155.elif exists (${.CURDIR}/dports)
156	@echo ${ERRDP}
157.else
158	@echo "If problems occur you may have to rm -rf dports and try again."
159	@echo
160	git clone --depth=1 git://mirror-master.dragonflybsd.org/dports.git \
161	   ${.CURDIR}/dports
162.if exists(${.CURDIR}/pkg)
163	@echo ${WSTARS}
164	@echo ${WARNPS}
165	@echo ${WSTARS}
166.endif
167.endif
168
169dports-download:
170.if exists (${.CURDIR}/dports)
171	@echo ${ERRDP}
172.else
173	rm -f ${DPTBALL}
174	fetch -o ${DPTBALL} ${DPDLURL}
175	tar -xf ${DPTBALL} -C ${.CURDIR}
176	mv /usr/DragonFlyBSD-DPorts-* ${.CURDIR}/dports
177	rm -f ${DPTBALL}
178.if exists(${.CURDIR}/pkg)
179	@echo ${WSTARS}
180	@echo ${WARNPS}
181	@echo ${WSTARS}
182.endif
183.endif
184
185dports-replace:
186.if !exists (${.CURDIR}/dports)
187	@echo ${ERRNDP}
188.elif exists(${.CURDIR}/dports/.git)
189	@echo "Error: this is git repository currently."
190	@echo "Remove ${.CURDIR}/dports and execute \"make dports-downloads\" if you want"
191	@echo "to convert to a non-git version."
192.else
193	rm -f ${DPTBALL}
194	fetch -o ${DPTBALL} ${DPDLURL}
195	rm -rf ${.CURDIR}/dports
196	tar -xf ${DPTBALL} -C ${.CURDIR}
197	mv /usr/DragonFlyBSD-DPorts-* ${.CURDIR}/dports
198	rm -f ${DPTBALL}
199.endif
200
201pkg-bootstrap-force:
202	@fetch -o ${PKGBALL} ${PKGBOOT}
203	@tar -xJf ${PKGBALL} -C ${.CURDIR}/local
204	@rm -f ${PKGBALL}
205.if defined(ABIVERS)
206	ABI=${ABIVERS} ${.CURDIR}/local/sbin/pkg-static install -y -f pkg
207.else
208	${.CURDIR}/local/sbin/pkg-static install -y -f pkg
209.endif
210
211pkg-bootstrap:
212.if exists(${.CURDIR}/local/sbin/pkg)
213	@echo ${ERRPKG}
214.elif exists(${.CURDIR}/local/etc/pkg.conf)
215	@echo "Error: ${.CURDIR}/local/etc/pkg.conf will be ovewritten"
216	@echo "Please move this file and rerun 'make pkg-bootstrap'"
217.else
218	@fetch -o ${PKGBALL} ${PKGBOOT}
219	@tar -xJf ${PKGBALL} -C ${.CURDIR}/local
220	@rm -f ${PKGBALL}
221.if defined(ABIVERS)
222	ABI=${ABIVERS} ${.CURDIR}/local/sbin/pkg-static install -y pkg
223.else
224	${.CURDIR}/local/sbin/pkg-static install -y pkg
225.endif
226.endif
227