898f2d0aaca6d15a9345bc5fbcc2bdaced6f6ad5
[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 DPTBALL=/tmp/dports.tar.gz
9 PKGBALL=/tmp/pkgboot.tar.xz
10 DPDLURL=https://api.github.com/repos/DragonFlyBSD/DPorts/tarball/
11 PKGBOOT_VERSION=02
12 PKGBOOT_x86_64=bootstrap_pkg_${PKGBOOT_VERSION}_x86-64.tar.xz
13 PKGBOOT=http://mirror-master.dragonflybsd.org/dports/bootstraps/${PKGBOOT_${MACHINE_ARCH}}
14 ERRPKG="Error: Bootstrap not necessary, ${.CURDIR}/local/sbin/pkg already exists"
15 WSTARS="***************************************************************"
16 WARNPS="  Warning: Delete or move ${.CURDIR}/pkg before building any dport!"
17 LPATT="   make %-23s- %s\n"
18
19 help all:
20         @echo "HELP:"
21         @echo
22 .if exists(${.CURDIR}/dports/.git)
23         @printf ${LPATT} "dports-update"         "update your dports repository from the net"
24 .else
25 .  if exists(${.CURDIR}/dports)
26         @printf ${LPATT} "dports-replace"        "Replace dports with latest tarball (Github)"
27 .  else
28         @printf ${LPATT} "dports-create"         "fetch initial dports repository from the net"
29         @printf ${LPATT} "dports-create-shallow" "fetch initial history-free dports repository"
30         @printf ${LPATT} "dports-download"       "download & install dports tarball (Github)"
31 .  endif
32 .endif
33         @printf ${LPATT} "pkg-bootstrap"        "Use pre-built pkg to install dports packages"
34         @printf ${LPATT} "pkg-bootstrap-force"  "Force it (pkg.conf will be overwritten)"
35         @echo
36
37 .if exists(${.CURDIR}/src/.git)
38 .if exists(${.CURDIR}/src/Makefile)
39         @printf ${LPATT} "src-update"         "update your src repository from the net"
40 .else
41         @printf ${LPATT} "src-checkout"       "Initial checkout of src repository"
42 .endif
43 .else
44         @printf ${LPATT} "src-create"         "fetch initial src repository from the net"
45         @printf ${LPATT} "src-create-shallow" "fetch initial history-free src repository"
46         @printf ${LPATT} "src-create-repo"    "fetch src repository only, no checkout"
47 .endif
48         @echo
49 .if exists(${.CURDIR}/src-sys.tar.bz2)
50         @printf ${LPATT} "release-sys-extract" "extract the pre-packaged sys-only sources"
51         @echo
52 .endif
53         @echo "If automating please feel free to run git pull's from cron."
54         @echo "We prefer once a day but you can run them more often if you desire"
55
56 git-check:
57         @/usr/bin/which -s git || \
58                 (echo "git must be present on the system to use this option."; /usr/bin/false)
59
60 src-check: git-check
61         @/bin/test ! -d ${.CURDIR}/src/.git || \
62                 (echo "Error: ${.CURDIR}/src already exists"; /usr/bin/false)
63
64 src-check-hasdir: git-check
65         @/bin/test -d ${.CURDIR}/src/.git || \
66                 (echo "Error: ${.CURDIR}/src does not exist"; /usr/bin/false)
67
68 src-create-repo: src-check
69         @echo "If problems occur you may have to rm -rf src and try again."
70         @echo
71         @mkdir -p ${.CURDIR}/src
72         @cd ${.CURDIR}/src && git init
73         @cd ${.CURDIR}/src && \
74                 git remote add origin git://${GITHOST}/dragonfly.git
75         cd ${.CURDIR}/src && git fetch origin
76         cd ${.CURDIR}/src && git branch master origin/master
77
78 src-create: src-create-repo
79         cd ${.CURDIR}/src && git checkout master
80         cd ${.CURDIR}/src && git pull
81
82 src-create-shallow: src-check
83         @echo "If problems occur you may have to rm -rf src and try again."
84         @echo
85         @mkdir -p ${.CURDIR}/src
86         cd ${.CURDIR}/src && git init
87         cd ${.CURDIR}/src && \
88             git remote add origin git://${GITHOST}/dragonfly.git
89         cd ${.CURDIR}/src && git fetch --depth=1 origin
90         cd ${.CURDIR}/src && git branch master origin/master
91         cd ${.CURDIR}/src && git checkout master
92         cd ${.CURDIR}/src && git pull
93
94 src-checkout: src-check-hasdir
95         cd ${.CURDIR}/src && git checkout master
96
97 src-update: src-check-hasdir
98         cd ${.CURDIR}/src && git pull
99
100 release-sys-extract:
101         cd ${.CURDIR} && tar xvpjf src-sys.tar.bz2
102
103 dports-check: git-check
104         @/bin/test ! -d ${.CURDIR}/dports/.git || \
105                    (echo "Error: ${.CURDIR}/dports already exists"; /usr/bin/false)
106
107 dports-download-check:
108         @/bin/test ! -d ${.CURDIR}/dports || \
109                    (echo "Error: ${.CURDIR}/dports already exists"; /usr/bin/false)
110         @/bin/test ! -d ${.CURDIR}/DragonFlyBSD-DPorts-* || \
111                    (echo "Error: ${.CURDIR}/DragonFlyBSD-DPorts-* already exists"; /usr/bin/false)
112
113 dports-check-hasdir: git-check
114         @/bin/test -d ${.CURDIR}/dports || \
115                    (echo "Error: ${.CURDIR}/dports does not exist"; /usr/bin/false)
116
117 dports-update: dports-check-hasdir
118         cd ${.CURDIR}/dports && git pull
119
120 dports-create: dports-check
121         @echo "If problems occur you may have to rm -rf dports and try again."
122         @echo
123         git clone git://${GITHOST_DPORTS}/dports.git ${.CURDIR}/dports
124 .if exists(${.CURDIR}/pkg)
125         @echo ${WSTARS}
126         @echo ${WARNPS}
127         @echo ${WSTARS}
128 .endif
129
130 dports-create-shallow: dports-check
131         @echo "If problems occur you may have to rm -rf dports and try again."
132         @echo
133         git clone --depth=1 git://${GITHOST_DPORTS}/dports.git \
134            ${.CURDIR}/dports
135 .if exists(${.CURDIR}/pkg)
136         @echo ${WSTARS}
137         @echo ${WARNPS}
138         @echo ${WSTARS}
139 .endif
140
141 dports-download: dports-download-check
142         rm -f ${DPTBALL}
143         fetch -o ${DPTBALL} ${DPDLURL}
144         tar -xf ${DPTBALL} -C ${.CURDIR}
145         mv /usr/DragonFlyBSD-DPorts-* ${.CURDIR}/dports
146         rm -f ${DPTBALL}
147 .if exists(${.CURDIR}/pkg)
148         @echo ${WSTARS}
149         @echo ${WARNPS}
150         @echo ${WSTARS}
151 .endif
152
153 dports-replace: dports-check-hasdir
154 .if exists(${.CURDIR}/dports/.git)
155         @echo "Error: this is git repository currently."
156         @echo "Remove ${.CURDIR}/dports and execute \"make dports-download\" if you want"
157         @echo "to convert to a non-git version."
158         @/usr/bin/false
159 .else
160         rm -f ${DPTBALL}
161         fetch -o ${DPTBALL} ${DPDLURL}
162         rm -rf ${.CURDIR}/dports
163         tar -xf ${DPTBALL} -C ${.CURDIR}
164         mv /usr/DragonFlyBSD-DPorts-* ${.CURDIR}/dports
165         rm -f ${DPTBALL}
166 .endif
167
168 # NOTE: In force mode we also have to remove any old pkg.conf
169 #       which might interfere with the newer pkg bootstrap.
170 #
171 pkg-bootstrap-force:
172         @rm -f /usr/local/etc/pkg.conf
173         @fetch -o ${PKGBALL} ${PKGBOOT}
174         @tar -xJf ${PKGBALL} -C ${.CURDIR}/local
175         @rm -f ${PKGBALL}
176 .if defined(ABIVERS)
177         ABI=${ABIVERS} ${.CURDIR}/local/sbin/pkg-static install -y -f pkg
178 .else
179         ${.CURDIR}/local/sbin/pkg-static install -y -f pkg
180 .endif
181
182 pkg-bootstrap:
183 .if exists(${.CURDIR}/local/sbin/pkg)
184         @echo ${ERRPKG}
185         @/usr/bin/false
186 .elif exists(${.CURDIR}/local/etc/pkg.conf)
187         @echo "Error: ${.CURDIR}/local/etc/pkg.conf will be overwritten"
188         @echo "Please move this file and rerun 'make pkg-bootstrap'"
189         @/usr/bin/false
190 .else
191         @fetch -o ${PKGBALL} ${PKGBOOT}
192         @tar -xJf ${PKGBALL} -C ${.CURDIR}/local
193         @rm -f ${PKGBALL}
194 .if defined(ABIVERS)
195         ABI=${ABIVERS} ${.CURDIR}/local/sbin/pkg-static install -y pkg
196 .else
197         ${.CURDIR}/local/sbin/pkg-static install -y pkg
198 .endif
199 .endif