1 # Makefile.usr - installed as /usr/Makefile
3 # Provides simple targets to download and maintain /usr/src, /usr/dports etc.
5 # DragonFly BSD source repository
6 GITURL_SRC?=git://git.dragonflybsd.org/dragonfly.git
7 # DragonFly BSD projects repository
8 GITURL_PROJECTS?=git://git.dragonflybsd.org/projects.git
9 # Branch to be fetched & checked out
10 # * master - latest development branch
11 # * DragonFly_RELEASE_x_y - stable release branch x.y
13 BRANCH_PROJECTS?=master
15 # DPorts source repository
16 GITURL_DPORTS?=git://mirror-master.dragonflybsd.org/dports.git
18 # Mirror from which to fetch the pkg bootstrap
19 MIRROR?=https://mirror-master.dragonflybsd.org
21 DPDLURL=https://api.github.com/repos/DragonFlyBSD/DPorts/tarball/
23 PKGBOOT_x86_64=bootstrap_pkg_${PKGBOOT_VERSION}_x86-64.tar.xz
24 PKGBOOT=${MIRROR}/dports/bootstraps/${PKGBOOT_${MACHINE_ARCH}}
25 WSTARS="***************************************************************"
26 WARNPS=" Warning: Delete or move ${.CURDIR}/pkg before building any dport!"
27 LPATT=" make %-23s- %s\n"
32 .if exists(${.CURDIR}/dports/.git)
33 @printf ${LPATT} "dports-update" "update your dports repository from the net"
35 . if exists(${.CURDIR}/dports)
36 @printf ${LPATT} "dports-replace" "Replace dports with latest tarball (Github)"
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)"
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)"
48 .if exists(${.CURDIR}/src/.git)
49 @printf ${LPATT} "src-update" "update your src repository from the net"
51 @printf ${LPATT} "src-create" "fetch initial src repository from the net"
52 @printf ${LPATT} "src-create-shallow" "fetch initial history-free src repository"
54 .if exists(${.CURDIR}/projects/.git)
55 @printf ${LPATT} "projects-update" "update your projects repository from the net"
57 @printf ${LPATT} "projects-create" "fetch initial projects repository from the net"
58 @printf ${LPATT} "projects-create-shallow" "fetch initial history-free projects repository"
61 .if exists(${.CURDIR}/src-sys.tar.bz2)
62 @printf ${LPATT} "release-sys-extract" "extract the pre-packaged sys-only sources"
65 @echo "src checkout branch: ${BRANCH}"
68 @/usr/bin/which -s git || \
69 (echo "git must be present on the system to use this option."; /usr/bin/false)
72 @/bin/test ! -d ${.CURDIR}/src/.git || \
73 (echo "Error: ${.CURDIR}/src already exists"; /usr/bin/false)
75 projects-check: git-check
76 @/bin/test ! -d ${.CURDIR}/projects/.git || \
77 (echo "Error: ${.CURDIR}/projects already exists"; /usr/bin/false)
79 src-check-hasdir: git-check
80 @/bin/test -d ${.CURDIR}/src/.git || \
81 (echo "Error: ${.CURDIR}/src does not exist"; /usr/bin/false)
84 @echo "If problems occur you may have to 'rm -rf src' and try again."
86 git clone --branch ${BRANCH} -- ${GITURL_SRC} ${.CURDIR}/src
88 src-create-shallow: src-check
89 @echo "If problems occur you may have to 'rm -rf src' and try again."
91 git clone --depth 1 --branch ${BRANCH} -- ${GITURL_SRC} ${.CURDIR}/src
93 projects-create: projects-check
94 @echo "If problems occur you may have to 'rm -rf projects' and try again."
96 git clone --branch ${BRANCH_PROJECTS} -- ${GITURL_PROJECTS} ${.CURDIR}/projects
98 projects-create-shallow: projects-check
99 @echo "If problems occur you may have to 'rm -rf projects' and try again."
101 git clone --depth 1 --branch ${BRANCH_PROJECTS} -- ${GITURL_PROJECTS} ${.CURDIR}/projects
103 src-update: src-check-hasdir
104 cd ${.CURDIR}/src && git pull --ff-only
106 @echo "To automate, feel free to run this task from cron(8)."
108 projects-update: projects-check-hasdir
109 cd ${.CURDIR}/projects && git pull --ff-only
111 @echo "To automate, feel free to run this task from cron(8)."
113 .if exists(${.CURDIR}/src-sys.tar.bz2)
115 cd ${.CURDIR} && tar xvpjf src-sys.tar.bz2
118 dports-check: git-check
119 @/bin/test ! -d ${.CURDIR}/dports/.git || \
120 (echo "Error: ${.CURDIR}/dports already exists"; /usr/bin/false)
122 dports-check-hasdir: git-check
123 @/bin/test -d ${.CURDIR}/dports/.git || \
124 (echo "Error: ${.CURDIR}/dports does not exist"; /usr/bin/false)
126 dports-create: dports-check
127 @echo "If problems occur you may have to 'rm -rf dports' and try again."
129 git clone ${GITURL_DPORTS} ${.CURDIR}/dports
130 .if exists(${.CURDIR}/pkg)
136 dports-create-shallow: dports-check
137 @echo "If problems occur you may have to 'rm -rf dports' and try again."
139 git clone --depth 1 ${GITURL_DPORTS} ${.CURDIR}/dports
140 .if exists(${.CURDIR}/pkg)
146 dports-update: dports-check-hasdir
147 cd ${.CURDIR}/dports && git pull --ff-only
149 @echo "To automate, feel free to run this task from cron(8)."
152 .if exists(${.CURDIR}/dports)
153 @echo "Error: ${.CURDIR}/dports already exists"
156 mkdir ${.CURDIR}/dports
157 fetch -o - ${DPDLURL} | \
158 tar -xf - -C ${.CURDIR}/dports --strip-components 1
159 .if exists(${.CURDIR}/pkg)
165 # NOTE: Ignore error from rm -rf because /usr/dports might be
166 # a null-mount. Be safe, do not wildcard /usr/dports/*.
169 .if exists(${.CURDIR}/dports/.git)
170 @echo "Error: ${.CURDIR}/dports is a git repository currently."
171 @echo "Remove ${.CURDIR}/dports and execute 'make dports-download' if you want"
172 @echo "to convert to a non-git version."
175 -rm -rf ${.CURDIR}/dports
176 [ -d "${.CURDIR}/dports" ] || mkdir ${.CURDIR}/dports
177 fetch -o - ${DPDLURL} | \
178 tar -xf - -C ${.CURDIR}/dports --strip-components 1
182 .if !exists(/etc/ssl/cert.pem) # from port 'security/ca_root_nss'
183 # Disable SSL verification for fetch(1) and pkg-static(8)
184 PKG_ENV+= SSL_NO_VERIFY_PEER=1
187 PKG_ENV+= ABI=${ABIVERS}
191 ${PKG_ENV} fetch -o - ${PKGBOOT} | \
192 tar -xf - -C ${.CURDIR}/local
194 # This is a bit problematic
196 pkg-bootstrap-install:
197 ${PKG_ENV} ${.CURDIR}/local/sbin/pkg-static \
198 install -y ${PKG_FLAGS} pkg ca_root_nss
199 [ -f ${.CURDIR}/local/etc/pkg/repos/df-latest.conf ] || \
200 cp -f ${.CURDIR}/local/etc/pkg/repos/df-latest.conf.sample \
201 ${.CURDIR}/local/etc/pkg/repos/df-latest.conf \
204 .if exists(${.CURDIR}/local/sbin/pkg)
205 @echo "Error: Bootstrap not necessary, ${.CURDIR}/local/sbin/pkg already exists"
207 .elif exists(${.CURDIR}/local/etc/pkg.conf)
208 @echo "Error: ${.CURDIR}/local/etc/pkg.conf will be overwritten"
209 @echo "Please move this file and rerun 'make pkg-bootstrap'"
212 @(cd ${.CURDIR} && make pkg-bootstrap-fetch)
213 @(cd ${.CURDIR} && make pkg-bootstrap-install)
216 # NOTE: In force mode we also have to remove any old pkg.conf
217 # which might interfere with the newer pkg bootstrap.
220 rm -f ${.CURDIR}/local/etc/pkg.conf
221 @(cd ${.CURDIR} && make pkg-bootstrap-fetch)
222 @(cd ${.CURDIR} && make pkg-bootstrap-install PKG_FLAGS="-f")