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