195f63befSSascha Wildner# Makefile.usr - installed as /usr/Makefile 2809ae383SMatthew Dillon# 3df16f41aSMatthew Dillon# Provides simple targets to download and maintain /usr/src, /usr/dports etc. 4809ae383SMatthew Dillon 5ad8b70e0SAaron LI# DragonFly BSD source repository 6ad8b70e0SAaron LIGITURL_SRC?=git://git.dragonflybsd.org/dragonfly.git 7ad8b70e0SAaron LI# Branch to be fetched & checked out 8ad8b70e0SAaron LI# * master - latest development branch 9ad8b70e0SAaron LI# * DragonFly_RELEASE_x_y - stable release branch x.y 10ad8b70e0SAaron LIBRANCH?=master 11ad8b70e0SAaron LI 12ad8b70e0SAaron LI# DPorts source repository 13ad8b70e0SAaron LIGITURL_DPORTS?=git://mirror-master.dragonflybsd.org/dports.git 14ad8b70e0SAaron LI 15ad8b70e0SAaron LI# Mirror from which to fetch the pkg bootstrap 16ad8b70e0SAaron LIMIRROR?=https://mirror-master.dragonflybsd.org 17fe70af21SMatthew Dillon 184060abb3SJohn MarinoDPTBALL=/tmp/dports.tar.gz 193271cef5SJohn MarinoPKGBALL=/tmp/pkgboot.tar.xz 20898339daSJohn MarinoDPDLURL=https://api.github.com/repos/DragonFlyBSD/DPorts/tarball/ 21daa5ccc1SMatthew DillonPKGBOOT_VERSION=02 22937aaebfSJohn MarinoPKGBOOT_x86_64=bootstrap_pkg_${PKGBOOT_VERSION}_x86-64.tar.xz 23ad8b70e0SAaron LIPKGBOOT=${MIRROR}/dports/bootstraps/${PKGBOOT_${MACHINE_ARCH}} 249c71144eSSascha WildnerERRPKG="Error: Bootstrap not necessary, ${.CURDIR}/local/sbin/pkg already exists" 254060abb3SJohn MarinoWSTARS="***************************************************************" 264060abb3SJohn MarinoWARNPS=" Warning: Delete or move ${.CURDIR}/pkg before building any dport!" 274060abb3SJohn MarinoLPATT=" make %-23s- %s\n" 284060abb3SJohn Marino 29e2dbfa0bSThomas Nikolajsenhelp all: 304922fbd1SMatthew Dillon @echo "HELP:" 314060abb3SJohn Marino @echo 324060abb3SJohn Marino.if exists(${.CURDIR}/dports/.git) 330b576daeSJohn Marino @printf ${LPATT} "dports-update" "update your dports repository from the net" 344060abb3SJohn Marino.else 354060abb3SJohn Marino. if exists(${.CURDIR}/dports) 360b576daeSJohn Marino @printf ${LPATT} "dports-replace" "Replace dports with latest tarball (Github)" 374060abb3SJohn Marino. else 380b576daeSJohn Marino @printf ${LPATT} "dports-create" "fetch initial dports repository from the net" 394060abb3SJohn Marino @printf ${LPATT} "dports-create-shallow" "fetch initial history-free dports repository" 400b576daeSJohn Marino @printf ${LPATT} "dports-download" "download & install dports tarball (Github)" 414060abb3SJohn Marino. endif 424060abb3SJohn Marino.endif 43ad8b70e0SAaron LI @echo 443271cef5SJohn Marino @printf ${LPATT} "pkg-bootstrap" "Use pre-built pkg to install dports packages" 45f201b797SMatthew Dillon @printf ${LPATT} "pkg-bootstrap-force" "Force it (pkg.conf will be overwritten)" 464060abb3SJohn Marino @echo 474060abb3SJohn Marino 484922fbd1SMatthew Dillon.if exists(${.CURDIR}/src/.git) 494060abb3SJohn Marino @printf ${LPATT} "src-update" "update your src repository from the net" 504922fbd1SMatthew Dillon.else 514060abb3SJohn Marino @printf ${LPATT} "src-create" "fetch initial src repository from the net" 524060abb3SJohn Marino @printf ${LPATT} "src-create-shallow" "fetch initial history-free src repository" 534922fbd1SMatthew Dillon.endif 544060abb3SJohn Marino @echo 559effbeffSSascha Wildner.if exists(${.CURDIR}/src-sys.tar.bz2) 564060abb3SJohn Marino @printf ${LPATT} "release-sys-extract" "extract the pre-packaged sys-only sources" 574060abb3SJohn Marino @echo 584922fbd1SMatthew Dillon.endif 59ad8b70e0SAaron LI @echo "src checkout branch: ${BRANCH}" 60ad8b70e0SAaron LI @echo 61ad8b70e0SAaron LI @echo "If automating please feel free to run 'git pull' from cron." 62ad8b70e0SAaron LI @echo "We prefer once a day but you can run them more often if you desire." 634922fbd1SMatthew Dillon 64fff08b59SAntonio Huete Jimenezgit-check: 65fff08b59SAntonio Huete Jimenez @/usr/bin/which -s git || \ 66fff08b59SAntonio Huete Jimenez (echo "git must be present on the system to use this option."; /usr/bin/false) 67fff08b59SAntonio Huete Jimenez 68fff08b59SAntonio Huete Jimenezsrc-check: git-check 69fff08b59SAntonio Huete Jimenez @/bin/test ! -d ${.CURDIR}/src/.git || \ 70fff08b59SAntonio Huete Jimenez (echo "Error: ${.CURDIR}/src already exists"; /usr/bin/false) 71fff08b59SAntonio Huete Jimenez 72fff08b59SAntonio Huete Jimenezsrc-check-hasdir: git-check 73fff08b59SAntonio Huete Jimenez @/bin/test -d ${.CURDIR}/src/.git || \ 74fff08b59SAntonio Huete Jimenez (echo "Error: ${.CURDIR}/src does not exist"; /usr/bin/false) 75fff08b59SAntonio Huete Jimenez 76ad8b70e0SAaron LIsrc-create: src-check 77ad8b70e0SAaron LI @echo "If problems occur you may have to 'rm -rf src' and try again." 784060abb3SJohn Marino @echo 79ad8b70e0SAaron LI git clone --branch ${BRANCH} -- ${GITURL_SRC} ${.CURDIR}/src 80f03b7956SMatthias Schmidt 81fff08b59SAntonio Huete Jimenezsrc-create-shallow: src-check 82ad8b70e0SAaron LI @echo "If problems occur you may have to 'rm -rf src' and try again." 834060abb3SJohn Marino @echo 84ad8b70e0SAaron LI git clone --depth 1 --branch ${BRANCH} -- ${GITURL_SRC} ${.CURDIR}/src 85f03b7956SMatthias Schmidt 86fff08b59SAntonio Huete Jimenezsrc-update: src-check-hasdir 874922fbd1SMatthew Dillon cd ${.CURDIR}/src && git pull 88e2dbfa0bSThomas Nikolajsen 89ad8b70e0SAaron LI.if exists(${.CURDIR}/src-sys.tar.bz2) 90809ae383SMatthew Dillonrelease-sys-extract: 919effbeffSSascha Wildner cd ${.CURDIR} && tar xvpjf src-sys.tar.bz2 92ad8b70e0SAaron LI.endif 93809ae383SMatthew Dillon 94fff08b59SAntonio Huete Jimenezdports-check: git-check 95fff08b59SAntonio Huete Jimenez @/bin/test ! -d ${.CURDIR}/dports/.git || \ 96fff08b59SAntonio Huete Jimenez (echo "Error: ${.CURDIR}/dports already exists"; /usr/bin/false) 974060abb3SJohn Marino 98ad8b70e0SAaron LIdports-check-hasdir: git-check 99ad8b70e0SAaron LI @/bin/test -d ${.CURDIR}/dports/.git || \ 100ad8b70e0SAaron LI (echo "Error: ${.CURDIR}/dports does not exist"; /usr/bin/false) 101ad8b70e0SAaron LI 102f0ef1af5SPierre-Alain TORETdports-download-check: 103f0ef1af5SPierre-Alain TORET @/bin/test ! -d ${.CURDIR}/dports || \ 104f0ef1af5SPierre-Alain TORET (echo "Error: ${.CURDIR}/dports already exists"; /usr/bin/false) 1055c0c71f9SPierre-Alain TORET @/bin/test ! -d ${.CURDIR}/DragonFlyBSD-DPorts-* || \ 1065c0c71f9SPierre-Alain TORET (echo "Error: ${.CURDIR}/DragonFlyBSD-DPorts-* already exists"; /usr/bin/false) 107f0ef1af5SPierre-Alain TORET 108fff08b59SAntonio Huete Jimenezdports-create: dports-check 109ad8b70e0SAaron LI @echo "If problems occur you may have to 'rm -rf dports' and try again." 1104060abb3SJohn Marino @echo 111ad8b70e0SAaron LI git clone ${GITURL_DPORTS} ${.CURDIR}/dports 1124060abb3SJohn Marino.if exists(${.CURDIR}/pkg) 1134060abb3SJohn Marino @echo ${WSTARS} 1144060abb3SJohn Marino @echo ${WARNPS} 1154060abb3SJohn Marino @echo ${WSTARS} 1164060abb3SJohn Marino.endif 1174060abb3SJohn Marino 118fff08b59SAntonio Huete Jimenezdports-create-shallow: dports-check 119ad8b70e0SAaron LI @echo "If problems occur you may have to 'rm -rf dports' and try again." 1204060abb3SJohn Marino @echo 121ad8b70e0SAaron LI git clone --depth 1 ${GITURL_DPORTS} ${.CURDIR}/dports 1224060abb3SJohn Marino.if exists(${.CURDIR}/pkg) 1234060abb3SJohn Marino @echo ${WSTARS} 1244060abb3SJohn Marino @echo ${WARNPS} 1254060abb3SJohn Marino @echo ${WSTARS} 1264060abb3SJohn Marino.endif 1274060abb3SJohn Marino 128ad8b70e0SAaron LIdports-update: dports-check-hasdir 129ad8b70e0SAaron LI cd ${.CURDIR}/dports && git pull 130ad8b70e0SAaron LI 131f0ef1af5SPierre-Alain TORETdports-download: dports-download-check 1324060abb3SJohn Marino rm -f ${DPTBALL} 1334060abb3SJohn Marino fetch -o ${DPTBALL} ${DPDLURL} 1344060abb3SJohn Marino tar -xf ${DPTBALL} -C ${.CURDIR} 135898339daSJohn Marino mv /usr/DragonFlyBSD-DPorts-* ${.CURDIR}/dports 1364060abb3SJohn Marino rm -f ${DPTBALL} 1374060abb3SJohn Marino.if exists(${.CURDIR}/pkg) 1384060abb3SJohn Marino @echo ${WSTARS} 1394060abb3SJohn Marino @echo ${WARNPS} 1404060abb3SJohn Marino @echo ${WSTARS} 1414060abb3SJohn Marino.endif 1424060abb3SJohn Marino 1435a500d26SMatthew Dillon# NOTE: Ignore error from rm -rf because /usr/dports might be 1445a500d26SMatthew Dillon# a null-mount. Be safe, do not wildcard /usr/dports/*. 1455a500d26SMatthew Dillon# 146ad8b70e0SAaron LIdports-replace: 147fff08b59SAntonio Huete Jimenez.if exists(${.CURDIR}/dports/.git) 148ad8b70e0SAaron LI @echo "Error: ${.CURDIR}/dports is a git repository currently." 149ad8b70e0SAaron LI @echo "Remove ${.CURDIR}/dports and execute 'make dports-download' if you want" 1504060abb3SJohn Marino @echo "to convert to a non-git version." 151fff08b59SAntonio Huete Jimenez @/usr/bin/false 1524060abb3SJohn Marino.else 1534060abb3SJohn Marino rm -f ${DPTBALL} 1544060abb3SJohn Marino fetch -o ${DPTBALL} ${DPDLURL} 1555a500d26SMatthew Dillon -rm -rf ${.CURDIR}/dports 1564060abb3SJohn Marino tar -xf ${DPTBALL} -C ${.CURDIR} 157898339daSJohn Marino mv /usr/DragonFlyBSD-DPorts-* ${.CURDIR}/dports 1584060abb3SJohn Marino rm -f ${DPTBALL} 1594060abb3SJohn Marino.endif 1603271cef5SJohn Marino 161*eae13f14SAaron LIpkg-bootstrap-fetch: 162*eae13f14SAaron LI.if exists(/etc/ssl/cert.pem) || exists(/usr/local/etc/ssl/cert.pem) 163*eae13f14SAaron LI fetch -o ${PKGBALL} ${PKGBOOT} 164daa5ccc1SMatthew Dillon.else 165*eae13f14SAaron LI @echo "Warning: /etc/ssl/cert.pem and /usr/local/etc/ssl/cert.pem do not exist." 166*eae13f14SAaron LI @echo "Disable certificate verification for fetch(1)." 167*eae13f14SAaron LI fetch --no-verify-peer -o ${PKGBALL} ${PKGBOOT} 168*eae13f14SAaron LI.endif 169*eae13f14SAaron LI tar -xJf ${PKGBALL} -C ${.CURDIR}/local 170*eae13f14SAaron LI @rm -f ${PKGBALL} 171*eae13f14SAaron LI 172*eae13f14SAaron LIpkg-bootstrap-install: 173*eae13f14SAaron LI.if defined(ABIVERS) 174*eae13f14SAaron LI ABI=${ABIVERS} ${.CURDIR}/local/sbin/pkg-static \ 175*eae13f14SAaron LI install -y ${PKG_FLAGS} pkg 176*eae13f14SAaron LI.else 177*eae13f14SAaron LI ${.CURDIR}/local/sbin/pkg-static install -y ${PKG_FLAGS} pkg 178daa5ccc1SMatthew Dillon.endif 179f201b797SMatthew Dillon 1803271cef5SJohn Marinopkg-bootstrap: 1813271cef5SJohn Marino.if exists(${.CURDIR}/local/sbin/pkg) 1823271cef5SJohn Marino @echo ${ERRPKG} 183fff08b59SAntonio Huete Jimenez @/usr/bin/false 1843271cef5SJohn Marino.elif exists(${.CURDIR}/local/etc/pkg.conf) 1851b1c1a4fSSascha Wildner @echo "Error: ${.CURDIR}/local/etc/pkg.conf will be overwritten" 1863271cef5SJohn Marino @echo "Please move this file and rerun 'make pkg-bootstrap'" 187fff08b59SAntonio Huete Jimenez @/usr/bin/false 1883271cef5SJohn Marino.else 189*eae13f14SAaron LI @(cd ${.CURDIR} && make pkg-bootstrap-fetch) 190*eae13f14SAaron LI @(cd ${.CURDIR} && make pkg-bootstrap-install) 191daa5ccc1SMatthew Dillon.endif 192*eae13f14SAaron LI 193*eae13f14SAaron LI# NOTE: In force mode we also have to remove any old pkg.conf 194*eae13f14SAaron LI# which might interfere with the newer pkg bootstrap. 195*eae13f14SAaron LI# 196*eae13f14SAaron LIpkg-bootstrap-force: 197*eae13f14SAaron LI rm -f ${.CURDIR}/local/etc/pkg.conf 198*eae13f14SAaron LI @(cd ${.CURDIR} && make pkg-bootstrap-fetch) 199*eae13f14SAaron LI @(cd ${.CURDIR} && make pkg-bootstrap-install PKG_FLAGS="-f") 200