Merge branch 'vendor/NCURSES'
[dragonfly.git] / etc / Makefile.usr
1 # Makefile.usr - installed as /usr/Makefile
2 #
3 # Provides simple targets to download and maintain /usr/src, /usr/dports etc.
4
5 GITHOST?=git.dragonflybsd.org
6 GITHOST_DPORTS?=mirror-master.dragonflybsd.org
7
8 THISGIT!= which git 2>/dev/null; echo
9 DPTBALL=/tmp/dports.tar.gz
10 PKGBALL=/tmp/pkgboot.tar.xz
11 DPDLURL=https://api.github.com/repos/DragonFlyBSD/DPorts/tarball/
12 PKGBOOT_VERSION=02
13 PKGBOOT_x86_64=bootstrap_pkg_${PKGBOOT_VERSION}_x86-64.tar.xz
14 PKGBOOT=http://mirror-master.dragonflybsd.org/dports/bootstraps/${PKGBOOT_${MACHINE_ARCH}}
15 GITNFMSG="git must be present on the system to use this option."
16 ERRDP="Error: ${.CURDIR}/dports already exists"
17 ERRSR="Error: ${.CURDIR}/src already exists"
18 ERRNDP="Error: ${.CURDIR}/dports does not exist"
19 ERRNSR="Error: ${.CURDIR}/src does not exist"
20 ERRPKG="Error: Bootstrap not necessary, ${.CURDIR}/local/sbin/pkg already exists"
21 WSTARS="***************************************************************"
22 WARNPS="  Warning: Delete or move ${.CURDIR}/pkg before building any dport!"
23 LPATT="   make %-23s- %s\n"
24
25 help 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
62 src-create-repo:
63 .if empty(THISGIT)
64         @echo ${GITNFMSG}
65 .elif exists (${.CURDIR}/src/.git)
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
78 src-create: src-create-repo
79 .if empty(THISGIT)
80         @echo ${GITNFMSG}
81 .elif exists (${.CURDIR}/src/.git)
82         @echo ${ERRSR}
83 .else
84         cd ${.CURDIR}/src && git checkout master
85         cd ${.CURDIR}/src && git pull
86 .endif
87
88 src-create-shallow:
89 .if empty(THISGIT)
90         @echo ${GITNFMSG}
91 .elif exists (${.CURDIR}/src/.git)
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
106 src-checkout:
107 .if empty(THISGIT)
108         @echo ${GITNFMSG}
109 .elif !exists (${.CURDIR}/src/.git)
110         @echo ${ERRNSR}
111 .else
112         cd ${.CURDIR}/src && git checkout master
113 .endif
114
115 src-update:
116 .if empty(THISGIT)
117         @echo ${GITNFMSG}
118 .elif !exists (${.CURDIR}/src/.git)
119         @echo ${ERRNSR}
120 .else
121         cd ${.CURDIR}/src && git pull
122 .endif
123
124 release-sys-extract:
125         cd ${.CURDIR} && tar xvpjf src-sys.tar.bz2
126
127 dports-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
136 dports-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://${GITHOST_DPORTS}/dports.git ${.CURDIR}/dports
145 .if exists(${.CURDIR}/pkg)
146         @echo ${WSTARS}
147         @echo ${WARNPS}
148         @echo ${WSTARS}
149 .endif
150 .endif
151
152 dports-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://${GITHOST_DPORTS}/dports.git \
161            ${.CURDIR}/dports
162 .if exists(${.CURDIR}/pkg)
163         @echo ${WSTARS}
164         @echo ${WARNPS}
165         @echo ${WSTARS}
166 .endif
167 .endif
168
169 dports-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
185 dports-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
201 # NOTE: In force mode we also have to remove any old pkg.conf
202 #       which might interfere with the newer pkg bootstrap.
203 #
204 pkg-bootstrap-force:
205         @rm -f /usr/local/etc/pkg.conf
206         @fetch -o ${PKGBALL} ${PKGBOOT}
207         @tar -xJf ${PKGBALL} -C ${.CURDIR}/local
208         @rm -f ${PKGBALL}
209 .if defined(ABIVERS)
210         ABI=${ABIVERS} ${.CURDIR}/local/sbin/pkg-static install -y -f pkg
211 .else
212         ${.CURDIR}/local/sbin/pkg-static install -y -f pkg
213 .endif
214
215 pkg-bootstrap:
216 .if exists(${.CURDIR}/local/sbin/pkg)
217         @echo ${ERRPKG}
218 .elif exists(${.CURDIR}/local/etc/pkg.conf)
219         @echo "Error: ${.CURDIR}/local/etc/pkg.conf will be ovewritten"
220         @echo "Please move this file and rerun 'make pkg-bootstrap'"
221 .else
222         @fetch -o ${PKGBALL} ${PKGBOOT}
223         @tar -xJf ${PKGBALL} -C ${.CURDIR}/local
224         @rm -f ${PKGBALL}
225 .if defined(ABIVERS)
226         ABI=${ABIVERS} ${.CURDIR}/local/sbin/pkg-static install -y pkg
227 .else
228         ${.CURDIR}/local/sbin/pkg-static install -y pkg
229 .endif
230 .endif