1# Makefile.usr - installed as /usr/Makefile 2# 3# Provides simple targets to download and maintain /usr/src, /usr/dports etc. 4 5# DragonFly BSD source repository 6GITURL_SRC?=git://git.dragonflybsd.org/dragonfly.git 7# Branch to be fetched & checked out 8# * master - latest development branch 9# * DragonFly_RELEASE_x_y - stable release branch x.y 10BRANCH?=master 11 12# DPorts source repository 13GITURL_DPORTS?=git://mirror-master.dragonflybsd.org/dports.git 14 15# Mirror from which to fetch the pkg bootstrap 16MIRROR?=https://mirror-master.dragonflybsd.org 17 18DPTBALL=/tmp/dports.tar.gz 19PKGBALL=/tmp/pkgboot.tar.xz 20DPDLURL=https://api.github.com/repos/DragonFlyBSD/DPorts/tarball/ 21PKGBOOT_VERSION=03 22PKGBOOT_x86_64=bootstrap_pkg_${PKGBOOT_VERSION}_x86-64.tar.xz 23PKGBOOT=${MIRROR}/dports/bootstraps/${PKGBOOT_${MACHINE_ARCH}} 24ERRPKG="Error: Bootstrap not necessary, ${.CURDIR}/local/sbin/pkg already exists" 25WSTARS="***************************************************************" 26WARNPS=" Warning: Delete or move ${.CURDIR}/pkg before building any dport!" 27LPATT=" make %-23s- %s\n" 28 29help all: 30 @echo "HELP:" 31 @echo 32.if exists(${.CURDIR}/dports/.git) 33 @printf ${LPATT} "dports-update" "update your dports repository from the net" 34.else 35. if exists(${.CURDIR}/dports) 36 @printf ${LPATT} "dports-replace" "Replace dports with latest tarball (Github)" 37. else 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)" 41. endif 42.endif 43 @echo 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)" 46 @echo 47 48.if exists(${.CURDIR}/src/.git) 49 @printf ${LPATT} "src-update" "update your src repository from the net" 50.else 51 @printf ${LPATT} "src-create" "fetch initial src repository from the net" 52 @printf ${LPATT} "src-create-shallow" "fetch initial history-free src repository" 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 "src checkout branch: ${BRANCH}" 60 61git-check: 62 @/usr/bin/which -s git || \ 63 (echo "git must be present on the system to use this option."; /usr/bin/false) 64 65src-check: git-check 66 @/bin/test ! -d ${.CURDIR}/src/.git || \ 67 (echo "Error: ${.CURDIR}/src already exists"; /usr/bin/false) 68 69src-check-hasdir: git-check 70 @/bin/test -d ${.CURDIR}/src/.git || \ 71 (echo "Error: ${.CURDIR}/src does not exist"; /usr/bin/false) 72 73src-create: src-check 74 @echo "If problems occur you may have to 'rm -rf src' and try again." 75 @echo 76 git clone --branch ${BRANCH} -- ${GITURL_SRC} ${.CURDIR}/src 77 78src-create-shallow: src-check 79 @echo "If problems occur you may have to 'rm -rf src' and try again." 80 @echo 81 git clone --depth 1 --branch ${BRANCH} -- ${GITURL_SRC} ${.CURDIR}/src 82 83src-update: src-check-hasdir 84 cd ${.CURDIR}/src && git pull --ff-only 85 @echo 86 @echo "To automate, feel free to run this task from cron(8)." 87 88.if exists(${.CURDIR}/src-sys.tar.bz2) 89release-sys-extract: 90 cd ${.CURDIR} && tar xvpjf src-sys.tar.bz2 91.endif 92 93dports-check: git-check 94 @/bin/test ! -d ${.CURDIR}/dports/.git || \ 95 (echo "Error: ${.CURDIR}/dports already exists"; /usr/bin/false) 96 97dports-check-hasdir: git-check 98 @/bin/test -d ${.CURDIR}/dports/.git || \ 99 (echo "Error: ${.CURDIR}/dports does not exist"; /usr/bin/false) 100 101dports-download-check: 102 @/bin/test ! -d ${.CURDIR}/dports || \ 103 (echo "Error: ${.CURDIR}/dports already exists"; /usr/bin/false) 104 @/bin/test ! -d ${.CURDIR}/DragonFlyBSD-DPorts-* || \ 105 (echo "Error: ${.CURDIR}/DragonFlyBSD-DPorts-* already exists"; /usr/bin/false) 106 107dports-create: dports-check 108 @echo "If problems occur you may have to 'rm -rf dports' and try again." 109 @echo 110 git clone ${GITURL_DPORTS} ${.CURDIR}/dports 111.if exists(${.CURDIR}/pkg) 112 @echo ${WSTARS} 113 @echo ${WARNPS} 114 @echo ${WSTARS} 115.endif 116 117dports-create-shallow: dports-check 118 @echo "If problems occur you may have to 'rm -rf dports' and try again." 119 @echo 120 git clone --depth 1 ${GITURL_DPORTS} ${.CURDIR}/dports 121.if exists(${.CURDIR}/pkg) 122 @echo ${WSTARS} 123 @echo ${WARNPS} 124 @echo ${WSTARS} 125.endif 126 127dports-update: dports-check-hasdir 128 cd ${.CURDIR}/dports && git pull --ff-only 129 @echo 130 @echo "To automate, feel free to run this task from cron(8)." 131 132dports-download: dports-download-check 133 rm -f ${DPTBALL} 134 fetch -o ${DPTBALL} ${DPDLURL} 135 tar -xf ${DPTBALL} -C ${.CURDIR} 136 mv /usr/DragonFlyBSD-DPorts-* ${.CURDIR}/dports 137 rm -f ${DPTBALL} 138.if exists(${.CURDIR}/pkg) 139 @echo ${WSTARS} 140 @echo ${WARNPS} 141 @echo ${WSTARS} 142.endif 143 144# NOTE: Ignore error from rm -rf because /usr/dports might be 145# a null-mount. Be safe, do not wildcard /usr/dports/*. 146# 147dports-replace: 148.if exists(${.CURDIR}/dports/.git) 149 @echo "Error: ${.CURDIR}/dports is a git repository currently." 150 @echo "Remove ${.CURDIR}/dports and execute 'make dports-download' if you want" 151 @echo "to convert to a non-git version." 152 @/usr/bin/false 153.else 154 rm -f ${DPTBALL} 155 fetch -o ${DPTBALL} ${DPDLURL} 156 -rm -rf ${.CURDIR}/dports 157 tar -xf ${DPTBALL} -C ${.CURDIR} 158 mv /usr/DragonFlyBSD-DPorts-* ${.CURDIR}/dports 159 rm -f ${DPTBALL} 160.endif 161 162pkg-bootstrap-fetch: 163.if exists(/etc/ssl/cert.pem) || exists(/usr/local/etc/ssl/cert.pem) 164 fetch -o ${PKGBALL} ${PKGBOOT} 165.else 166 @echo "Warning: /etc/ssl/cert.pem and /usr/local/etc/ssl/cert.pem do not exist." 167 @echo "Disable certificate verification for fetch(1)." 168 fetch --no-verify-peer -o ${PKGBALL} ${PKGBOOT} 169.endif 170 tar -xJf ${PKGBALL} -C ${.CURDIR}/local 171 @rm -f ${PKGBALL} 172 173# This is a bit problematic 174# 175pkg-bootstrap-install: 176.if defined(ABIVERS) 177 ABI=${ABIVERS} ${.CURDIR}/local/sbin/pkg-static \ 178 install -y ${PKG_FLAGS} pkg 179.else 180 ${.CURDIR}/local/sbin/pkg-static install -y ${PKG_FLAGS} pkg 181.endif 182 ${.CURDIR}/local/sbin/pkg install -y ${PKG_FLAGS} ca_root_nss 183 cp -f ${.CURDIR}/local/etc/pkg/repos/df-latest.conf.sample \ 184 ${.CURDIR}/local/etc/pkg/repos/df-latest.conf \ 185 186pkg-bootstrap: 187.if exists(${.CURDIR}/local/sbin/pkg) 188 @echo ${ERRPKG} 189 @/usr/bin/false 190.elif exists(${.CURDIR}/local/etc/pkg.conf) 191 @echo "Error: ${.CURDIR}/local/etc/pkg.conf will be overwritten" 192 @echo "Please move this file and rerun 'make pkg-bootstrap'" 193 @/usr/bin/false 194.else 195 @(cd ${.CURDIR} && make pkg-bootstrap-fetch) 196 @(cd ${.CURDIR} && make pkg-bootstrap-install) 197.endif 198 199# NOTE: In force mode we also have to remove any old pkg.conf 200# which might interfere with the newer pkg bootstrap. 201# 202pkg-bootstrap-force: 203 rm -f ${.CURDIR}/local/etc/pkg.conf 204 @(cd ${.CURDIR} && make pkg-bootstrap-fetch) 205 @(cd ${.CURDIR} && make pkg-bootstrap-install PKG_FLAGS="-f") 206