xref: /dragonfly/etc/Makefile.usr (revision cecb9aae)
1# Makefile.usr - installed as /usr/Makefile
2#
3# Provides simple targets to download and maintain /usr/src, /usr/pkgsrc etc.
4
5GITHOST?=git.dragonflybsd.org
6
7THISGIT!= which git 2>/dev/null; echo
8DPTBALL=/tmp/dports.tar.gz
9DPDLURL=https://api.github.com/repos/jrmarino/DPorts/tarball/
10GITNFMSG="git must be present on the system to use this option."
11ERRPS="Error: ${.CURDIR}/pkgsrc already exists"
12ERRDP="Error: ${.CURDIR}/dports already exists"
13ERRSR="Error: ${.CURDIR}/src already exists"
14ERRNPS="Error: ${.CURDIR}/pkgsrc does not exist"
15ERRNDP="Error: ${.CURDIR}/dports does not exist"
16ERRNSR="Error: ${.CURDIR}/src does not exist"
17WSTARS="***************************************************************"
18WARNPS="  Warning: Delete or move ${.CURDIR}/pkg before building any dport!"
19LPATT="   make %-23s- %s\n"
20
21
22help all:
23	@echo "HELP:"
24.if exists(${.CURDIR}/pkgsrc/.git)
25.if exists(${.CURDIR}/pkgsrc/Makefile)
26	@printf ${LPATT} "pkgsrc-update"         "update your pkgsrc repo from the net"
27.else
28	@printf ${LPATT} "pkgsrc-checkout"       "Initial checkout of pkgsrc repository"
29.endif
30.else
31	@printf ${LPATT} "pkgsrc-create"         "fetch initial pkgsrc repository from the net"
32	@printf ${LPATT} "pkgsrc-create-shallow" "fetch initial history-free pkgsrc repository"
33	@printf ${LPATT} "pkgsrc-create-repo"    "fetch pkgsrc repository only, no checkout"
34.endif
35	@echo
36.if exists(${.CURDIR}/dports/.git)
37	@printf ${LPATT} "dports-update"         "update your dports repo from Github"
38.else
39.  if exists(${.CURDIR}/dports)
40	@printf ${LPATT} "dports-replace"        "Replace dports with latest tarball from Github"
41.  else
42	@printf ${LPATT} "dports-create"         "fetch initial dports repository from Github"
43	@printf ${LPATT} "dports-create-shallow" "fetch initial history-free dports repository"
44	@printf ${LPATT} "dports-download"       "download & install dports tarball from Github"
45.  endif
46.endif
47	@echo
48
49.if exists(${.CURDIR}/src/.git)
50.if exists(${.CURDIR}/src/Makefile)
51	@printf ${LPATT} "src-update"         "update your src repository from the net"
52.else
53	@printf ${LPATT} "src-checkout"       "Initial checkout of src repository"
54.endif
55.else
56	@printf ${LPATT} "src-create"         "fetch initial src repository from the net"
57	@printf ${LPATT} "src-create-shallow" "fetch initial history-free src repository"
58	@printf ${LPATT} "src-create-repo"    "fetch src repository only, no checkout"
59.endif
60	@echo
61.if exists(${.CURDIR}/src-sys.tar.bz2)
62	@printf ${LPATT} "release-sys-extract" "extract the pre-packaged sys-only sources"
63	@echo
64.endif
65	@echo "If automating please feel free to run git pull's from cron."
66	@echo "We prefer once a day but you can run them more often if you desire"
67
68pkgsrc-create-repo:
69.if empty(THISGIT)
70	@echo ${GITNFMSG}
71.elif exists (${.CURDIR}/pkgsrc)
72	@echo ${ERRPS}
73.else
74	@echo "If problems occur you may have to rm -rf pkgsrc and try again."
75	@echo
76	mkdir -p ${.CURDIR}/pkgsrc
77	cd ${.CURDIR}/pkgsrc && git init
78	cd ${.CURDIR}/pkgsrc && \
79		git remote add origin git://${GITHOST}/pkgsrcv2.git
80	cd ${.CURDIR}/pkgsrc && git fetch origin
81	cd ${.CURDIR}/pkgsrc && git branch master origin/master
82.endif
83
84pkgsrc-create: pkgsrc-create-repo
85.if empty(THISGIT)
86	@echo ${GITNFMSG}
87.elif exists (${.CURDIR}/pkgsrc)
88	@echo ${ERRPS}
89.else
90	cd ${.CURDIR}/pkgsrc && git checkout master
91	cd ${.CURDIR}/pkgsrc && git pull
92.endif
93
94pkgsrc-create-shallow:
95.if empty(THISGIT)
96	@echo ${GITNFMSG}
97.elif exists (${.CURDIR}/pkgsrc)
98	@echo ${ERRPS}
99.else
100	@echo "If problems occur you may have to rm -rf pkgsrc and try again."
101	@echo
102	mkdir -p ${.CURDIR}/pkgsrc
103	cd ${.CURDIR}/pkgsrc && git init
104	cd ${.CURDIR}/pkgsrc && \
105		git remote add origin git://${GITHOST}/pkgsrcv2.git
106	cd ${.CURDIR}/pkgsrc && git fetch --depth=1 origin
107	cd ${.CURDIR}/pkgsrc && git branch master origin/master
108	cd ${.CURDIR}/pkgsrc && git checkout master
109	cd ${.CURDIR}/pkgsrc && git pull
110.endif
111
112pkgsrc-checkout:
113.if empty(THISGIT)
114	@echo ${GITNFMSG}
115.elif !exists (${.CURDIR}/pkgsrc)
116	@echo ${ERRNPS}
117.else
118	cd ${.CURDIR}/pkgsrc && git checkout master
119.endif
120
121pkgsrc-update:
122.if empty(THISGIT)
123	@echo ${GITNFMSG}
124.elif !exists (${.CURDIR}/pkgsrc)
125	@echo ${ERRNPS}
126.else
127	cd ${.CURDIR}/pkgsrc && git pull
128.endif
129
130src-create-repo:
131.if empty(THISGIT)
132	@echo ${GITNFMSG}
133.elif exists (${.CURDIR}/src)
134	@echo ${ERRSR}
135.else
136	@echo "If problems occur you may have to rm -rf src and try again."
137	@echo
138	mkdir -p ${.CURDIR}/src
139	cd ${.CURDIR}/src && git init
140	cd ${.CURDIR}/src && \
141		git remote add origin git://${GITHOST}/dragonfly.git
142	cd ${.CURDIR}/src && git fetch origin
143	cd ${.CURDIR}/src && git branch master origin/master
144.endif
145
146src-create: src-create-repo
147.if empty(THISGIT)
148	@echo ${GITNFMSG}
149.elif exists (${.CURDIR}/src)
150	@echo ${ERRSR}
151.else
152	cd ${.CURDIR}/src && git checkout master
153	cd ${.CURDIR}/src && git pull
154.endif
155
156src-create-shallow:
157.if empty(THISGIT)
158	@echo ${GITNFMSG}
159.elif exists (${.CURDIR}/src)
160	@echo ${ERRSR}
161.else
162	@echo "If problems occur you may have to rm -rf src and try again."
163	@echo
164	mkdir -p ${.CURDIR}/src
165	cd ${.CURDIR}/src && git init
166	cd ${.CURDIR}/src && \
167	    git remote add origin git://${GITHOST}/dragonfly.git
168	cd ${.CURDIR}/src && git fetch --depth=1 origin
169	cd ${.CURDIR}/src && git branch master origin/master
170	cd ${.CURDIR}/src && git checkout master
171	cd ${.CURDIR}/src && git pull
172.endif
173
174src-checkout:
175.if empty(THISGIT)
176	@echo ${GITNFMSG}
177.elif !exists (${.CURDIR}/src)
178	@echo ${ERRNSR}
179.else
180	cd ${.CURDIR}/src && git checkout master
181.endif
182
183src-update:
184.if empty(THISGIT)
185	@echo ${GITNFMSG}
186.elif !exists (${.CURDIR}/src)
187	@echo ${ERRNSR}
188.else
189	cd ${.CURDIR}/src && git pull
190.endif
191
192release-sys-extract:
193	cd ${.CURDIR} && tar xvpjf src-sys.tar.bz2
194
195dports-update:
196.if empty(THISGIT)
197	@echo ${GITNFMSG}
198.elif !exists (${.CURDIR}/dports)
199	@echo ${ERRNDP}
200.else
201	cd ${.CURDIR}/dports && git pull
202.endif
203
204dports-create:
205.if empty(THISGIT)
206	@echo ${GITNFMSG}
207.elif exists (${.CURDIR}/dports)
208	@echo ${ERRDP}
209.else
210	@echo "If problems occur you may have to rm -rf dports and try again."
211	@echo
212	git clone git://github.com/jrmarino/DPorts.git ${.CURDIR}/dports
213.if exists(${.CURDIR}/pkg)
214	@echo ${WSTARS}
215	@echo ${WARNPS}
216	@echo ${WSTARS}
217.endif
218.endif
219
220dports-create-shallow:
221.if empty(THISGIT)
222	@echo ${GITNFMSG}
223.elif exists (${.CURDIR}/dports)
224	@echo ${ERRDP}
225.else
226	@echo "If problems occur you may have to rm -rf dports and try again."
227	@echo
228	git clone --depth=1 git://github.com/jrmarino/DPorts.git \
229	   ${.CURDIR}/dports
230.if exists(${.CURDIR}/pkg)
231	@echo ${WSTARS}
232	@echo ${WARNPS}
233	@echo ${WSTARS}
234.endif
235.endif
236
237dports-download:
238.if exists (${.CURDIR}/dports)
239	@echo ${ERRDP}
240.else
241	rm -f ${DPTBALL}
242	fetch -o ${DPTBALL} ${DPDLURL}
243	tar -xf ${DPTBALL} -C ${.CURDIR}
244	mv /usr/jrmarino-DPorts-* ${.CURDIR}/dports
245	rm -f ${DPTBALL}
246.if exists(${.CURDIR}/pkg)
247	@echo ${WSTARS}
248	@echo ${WARNPS}
249	@echo ${WSTARS}
250.endif
251.endif
252
253dports-replace:
254.if !exists (${.CURDIR}/dports)
255	@echo ${ERRNDP}
256.elif exists(${.CURDIR}/dports/.git)
257	@echo "Error: this is git repository currently."
258	@echo "Remove ${.CURDIR}/dports and execute \"make dports-downloads\" if you want"
259	@echo "to convert to a non-git version."
260.else
261	rm -f ${DPTBALL}
262	fetch -o ${DPTBALL} ${DPDLURL}
263	rm -rf ${.CURDIR}/dports
264	tar -xf ${DPTBALL} -C ${.CURDIR}
265	mv /usr/jrmarino-DPorts-* ${.CURDIR}/dports
266	rm -f ${DPTBALL}
267.endif
268