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 DPTBALL=/tmp/dports.tar.gz
22 PKGBALL=/tmp/pkgboot.tar.xz
23 DPDLURL=https://api.github.com/repos/DragonFlyBSD/DPorts/tarball/
25 PKGBOOT_x86_64=bootstrap_pkg_${PKGBOOT_VERSION}_x86-64.tar.xz
26 PKGBOOT=${MIRROR}/dports/bootstraps/${PKGBOOT_${MACHINE_ARCH}}
27 ERRPKG="Error: Bootstrap not necessary, ${.CURDIR}/local/sbin/pkg already exists"
28 WSTARS="***************************************************************"
29 WARNPS=" Warning: Delete or move ${.CURDIR}/pkg before building any dport!"
30 LPATT=" make %-23s- %s\n"
35 .if exists(${.CURDIR}/dports/.git)
36 @printf ${LPATT} "dports-update" "update your dports repository from the net"
38 . if exists(${.CURDIR}/dports)
39 @printf ${LPATT} "dports-replace" "Replace dports with latest tarball (Github)"
41 @printf ${LPATT} "dports-create" "fetch initial dports repository from the net"
42 @printf ${LPATT} "dports-create-shallow" "fetch initial history-free dports repository"
43 @printf ${LPATT} "dports-download" "download & install dports tarball (Github)"
47 @printf ${LPATT} "pkg-bootstrap" "Use pre-built pkg to install dports packages"
48 @printf ${LPATT} "pkg-bootstrap-force" "Force it (pkg.conf will be overwritten)"
51 .if exists(${.CURDIR}/src/.git)
52 @printf ${LPATT} "src-update" "update your src repository from the net"
54 @printf ${LPATT} "src-create" "fetch initial src repository from the net"
55 @printf ${LPATT} "src-create-shallow" "fetch initial history-free src repository"
57 .if exists(${.CURDIR}/projects/.git)
58 @printf ${LPATT} "projects-update" "update your projects repository from the net"
60 @printf ${LPATT} "projects-create" "fetch initial projects repository from the net"
61 @printf ${LPATT} "projects-create-shallow" "fetch initial history-free projects repository"
64 .if exists(${.CURDIR}/src-sys.tar.bz2)
65 @printf ${LPATT} "release-sys-extract" "extract the pre-packaged sys-only sources"
68 @echo "src checkout branch: ${BRANCH}"
71 @/usr/bin/which -s git || \
72 (echo "git must be present on the system to use this option."; /usr/bin/false)
75 @/bin/test ! -d ${.CURDIR}/src/.git || \
76 (echo "Error: ${.CURDIR}/src already exists"; /usr/bin/false)
78 projects-check: git-check
79 @/bin/test ! -d ${.CURDIR}/projects/.git || \
80 (echo "Error: ${.CURDIR}/projects already exists"; /usr/bin/false)
82 src-check-hasdir: git-check
83 @/bin/test -d ${.CURDIR}/src/.git || \
84 (echo "Error: ${.CURDIR}/src does not exist"; /usr/bin/false)
87 @echo "If problems occur you may have to 'rm -rf src' and try again."
89 git clone --branch ${BRANCH} -- ${GITURL_SRC} ${.CURDIR}/src
91 src-create-shallow: src-check
92 @echo "If problems occur you may have to 'rm -rf src' and try again."
94 git clone --depth 1 --branch ${BRANCH} -- ${GITURL_SRC} ${.CURDIR}/src
96 projects-create: projects-check
97 @echo "If problems occur you may have to 'rm -rf projects' and try again."
99 git clone --branch ${BRANCH_PROJECTS} -- ${GITURL_PROJECTS} ${.CURDIR}/projects
101 projects-create-shallow: projects-check
102 @echo "If problems occur you may have to 'rm -rf projects' and try again."
104 git clone --depth 1 --branch ${BRANCH_PROJECTS} -- ${GITURL_PROJECTS} ${.CURDIR}/projects
106 src-update: src-check-hasdir
107 cd ${.CURDIR}/src && git pull --ff-only
109 @echo "To automate, feel free to run this task from cron(8)."
111 projects-update: projects-check-hasdir
112 cd ${.CURDIR}/projects && git pull --ff-only
114 @echo "To automate, feel free to run this task from cron(8)."
116 .if exists(${.CURDIR}/src-sys.tar.bz2)
118 cd ${.CURDIR} && tar xvpjf src-sys.tar.bz2
121 dports-check: git-check
122 @/bin/test ! -d ${.CURDIR}/dports/.git || \
123 (echo "Error: ${.CURDIR}/dports already exists"; /usr/bin/false)
125 dports-check-hasdir: git-check
126 @/bin/test -d ${.CURDIR}/dports/.git || \
127 (echo "Error: ${.CURDIR}/dports does not exist"; /usr/bin/false)
129 dports-download-check:
130 @/bin/test ! -d ${.CURDIR}/dports || \
131 (echo "Error: ${.CURDIR}/dports already exists"; /usr/bin/false)
132 @/bin/test ! -d ${.CURDIR}/DragonFlyBSD-DPorts-* || \
133 (echo "Error: ${.CURDIR}/DragonFlyBSD-DPorts-* already exists"; /usr/bin/false)
135 dports-create: dports-check
136 @echo "If problems occur you may have to 'rm -rf dports' and try again."
138 git clone ${GITURL_DPORTS} ${.CURDIR}/dports
139 .if exists(${.CURDIR}/pkg)
145 dports-create-shallow: dports-check
146 @echo "If problems occur you may have to 'rm -rf dports' and try again."
148 git clone --depth 1 ${GITURL_DPORTS} ${.CURDIR}/dports
149 .if exists(${.CURDIR}/pkg)
155 dports-update: dports-check-hasdir
156 cd ${.CURDIR}/dports && git pull --ff-only
158 @echo "To automate, feel free to run this task from cron(8)."
160 dports-download: dports-download-check
162 fetch -o ${DPTBALL} ${DPDLURL}
163 tar -xf ${DPTBALL} -C ${.CURDIR}
164 mv /usr/DragonFlyBSD-DPorts-* ${.CURDIR}/dports
166 .if exists(${.CURDIR}/pkg)
172 # NOTE: Ignore error from rm -rf because /usr/dports might be
173 # a null-mount. Be safe, do not wildcard /usr/dports/*.
176 .if exists(${.CURDIR}/dports/.git)
177 @echo "Error: ${.CURDIR}/dports is a git repository currently."
178 @echo "Remove ${.CURDIR}/dports and execute 'make dports-download' if you want"
179 @echo "to convert to a non-git version."
183 fetch -o ${DPTBALL} ${DPDLURL}
184 -rm -rf ${.CURDIR}/dports
185 tar -xf ${DPTBALL} -C ${.CURDIR}
186 mv /usr/DragonFlyBSD-DPorts-* ${.CURDIR}/dports
191 .if exists(/etc/ssl/cert.pem) || exists(/usr/local/etc/ssl/cert.pem)
192 fetch -o ${PKGBALL} ${PKGBOOT}
194 @echo "Warning: /etc/ssl/cert.pem and /usr/local/etc/ssl/cert.pem do not exist."
195 @echo "Disable certificate verification for fetch(1)."
196 fetch --no-verify-peer -o ${PKGBALL} ${PKGBOOT}
198 tar -xJf ${PKGBALL} -C ${.CURDIR}/local
201 # This is a bit problematic
203 pkg-bootstrap-install:
205 ABI=${ABIVERS} ${.CURDIR}/local/sbin/pkg-static \
206 install -y ${PKG_FLAGS} pkg
208 ${.CURDIR}/local/sbin/pkg-static install -y ${PKG_FLAGS} pkg
210 ${.CURDIR}/local/sbin/pkg-static install -y ${PKG_FLAGS} ca_root_nss
211 cp -f ${.CURDIR}/local/etc/pkg/repos/df-latest.conf.sample \
212 ${.CURDIR}/local/etc/pkg/repos/df-latest.conf \
215 .if exists(${.CURDIR}/local/sbin/pkg)
218 .elif exists(${.CURDIR}/local/etc/pkg.conf)
219 @echo "Error: ${.CURDIR}/local/etc/pkg.conf will be overwritten"
220 @echo "Please move this file and rerun 'make pkg-bootstrap'"
223 @(cd ${.CURDIR} && make pkg-bootstrap-fetch)
224 @(cd ${.CURDIR} && make pkg-bootstrap-install)
227 # NOTE: In force mode we also have to remove any old pkg.conf
228 # which might interfere with the newer pkg bootstrap.
231 rm -f ${.CURDIR}/local/etc/pkg.conf
232 @(cd ${.CURDIR} && make pkg-bootstrap-fetch)
233 @(cd ${.CURDIR} && make pkg-bootstrap-install PKG_FLAGS="-f")