1HOMEPAGE = "https://github.com/minio/mc"
2SUMMARY = "MinIO Client is a replacement for ls, cp, mkdir, diff and rsync commands for filesystems and object storage."
3DESCRIPTION = "MinIO Client (mc) provides a modern alternative to \
4               UNIX commands like ls, cat, cp, mirror, diff, find \
5               etc. It supports filesystems and Amazon S3 compatible \
6               cloud storage service (AWS Signature v2 and v4). \
7"
8
9SRC_URI = "git://github.com/minio/mc;nobranch=1;name=mc;protocol=https \
10           file://modules.txt \
11          "
12
13include src_uri.inc
14
15SRCREV_mc = "01b87ecc02ffad47dfe13c2154ac31db3e3115df"
16
17GO_IMPORT = "import"
18
19LICENSE = "AGPL-3.0-only"
20LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=eb1e647870add0502f8f010b19de32af"
21
22PV = "${SRCREV_mc}"
23
24inherit go
25inherit goarch
26
27# | ./github.com/minio/mc/main.go:27:(.text+0xd258b8): relocation R_MIPS_HI16 against `a local symbol' cannot be used when making a shared object; recompile with -fPIC
28COMPATIBLE_HOST:mips = "null"
29# ERROR: QA Issue: minio: ELF binary /usr/sbin/mc has relocations in .text [textrel]
30# Needs fixing with go >= 1.20.4"
31EXCLUDE_FROM_WORLD = "1"
32
33DEPENDS += "rsync-native"
34
35do_compile() {
36
37    cd ${S}/src/${GO_IMPORT}
38
39    export GOFLAGS="-mod=vendor"
40    export GOPATH="$GOPATH:${S}/src/import/.gopath:${S}/src/import/vendor"
41    sites="github.com/charmbracelet/bubbletea:github.com/charmbracelet/bubbletea \
42           github.com/cheggaaa/pb:github.com/cheggaaa/pb \
43           github.com/dustin/go-humanize:github.com/dustin/go-humanize \
44           github.com/fatih/color:github.com/fatih/color \
45           github.com/go-ole/go-ole:github.com/go-ole/go-ole \
46           github.com/goccy/go-json:github.com/goccy/go-json \
47           github.com/google/shlex:github.com/google/shlex \
48           github.com/google/uuid:github.com/google/uuid \
49           github.com/inconshreveable/mousetrap:github.com/inconshreveable/mousetrap \
50           github.com/json-iterator/go:github.com/json-iterator/go \
51           github.com/klauspost/compress:github.com/klauspost/compress \
52           github.com/mattn/go-ieproxy:github.com/mattn/go-ieproxy \
53           github.com/mattn/go-isatty:github.com/mattn/go-isatty \
54           github.com/minio/cli:github.com/minio/cli \
55           github.com/minio/colorjson:github.com/minio/colorjson \
56           github.com/minio/filepath:github.com/minio/filepath \
57           github.com/minio/madmin-go:github.com/minio/madmin-go \
58           github.com/minio/md5-simd:github.com/minio/md5-simd \
59           github.com/minio/minio-go/v7:github.com/minio/minio-go/v7 \
60           github.com/minio/pkg:github.com/minio/pkg \
61           github.com/minio/selfupdate:github.com/minio/selfupdate \
62           github.com/minio/sha256-simd:github.com/minio/sha256-simd \
63           github.com/mitchellh/go-homedir:github.com/mitchellh/go-homedir \
64           github.com/pkg/xattr:github.com/pkg/xattr \
65           github.com/posener/complete:github.com/posener/complete \
66           github.com/prometheus/client_golang:github.com/prometheus/client_golang \
67           github.com/prometheus/prom2json:github.com/prometheus/prom2json \
68           github.com/rjeczalik/notify:github.com/rjeczalik/notify \
69           github.com/rs/xid:github.com/rs/xid \
70           github.com/secure-io/sio-go:github.com/secure-io/sio-go \
71           github.com/shirou/gopsutil/v3:github.com/shirou/gopsutil/v3 \
72           github.com/tidwall/gjson:github.com/tidwall/gjson \
73           golang.org/x/crypto:go.googlesource.com/crypto \
74           golang.org/x/net:go.googlesource.com/net \
75           golang.org/x/text:go.googlesource.com/text \
76           gopkg.in/check.v1:gopkg.in/check.v1 \
77           gopkg.in/h2non/filetype.v1:gopkg.in/h2non/filetype.v1 \
78           gopkg.in/yaml.v2:gopkg.in/yaml.v2 \
79           github.com/charmbracelet/bubbles:github.com/charmbracelet/bubbles \
80           github.com/charmbracelet/lipgloss:github.com/charmbracelet/lipgloss \
81           github.com/gdamore/tcell/v2:github.com/gdamore/tcell/v2 \
82           github.com/golang-jwt/jwt/v4:github.com/golang-jwt/jwt/v4 \
83           github.com/navidys/tvxwidgets:github.com/navidys/tvxwidgets \
84           github.com/olekukonko/tablewriter:github.com/olekukonko/tablewriter \
85           github.com/prometheus/client_model:github.com/prometheus/client_model \
86           github.com/rivo/tview:github.com/rivo/tview \
87           github.com/tinylib/msgp:github.com/tinylib/msgp \
88           golang.org/x/term:go.googlesource.com/term \
89           github.com/beorn7/perks:github.com/beorn7/perks \
90           github.com/cespare/xxhash/v2:github.com/cespare/xxhash/v2 \
91           github.com/containerd/console:github.com/containerd/console \
92           github.com/coreos/go-semver:github.com/coreos/go-semver \
93           github.com/coreos/go-systemd/v22:github.com/coreos/go-systemd/v22 \
94           github.com/decred/dcrd/dcrec/secp256k1/v4:github.com/decred/dcrd/dcrec/secp256k1/v4//dcrec/secp256k1 \
95           github.com/fatih/structs:github.com/fatih/structs \
96           github.com/gdamore/encoding:github.com/gdamore/encoding \
97           github.com/gogo/protobuf:github.com/gogo/protobuf \
98           github.com/golang/protobuf:github.com/golang/protobuf \
99           github.com/hashicorp/errwrap:github.com/hashicorp/errwrap \
100           github.com/hashicorp/go-multierror:github.com/hashicorp/go-multierror \
101           github.com/klauspost/cpuid/v2:github.com/klauspost/cpuid/v2 \
102           github.com/kr/text:github.com/kr/text \
103           github.com/lestrrat-go/backoff/v2:github.com/lestrrat-go/backoff/v2 \
104           github.com/lestrrat-go/blackmagic:github.com/lestrrat-go/blackmagic \
105           github.com/lestrrat-go/httpcc:github.com/lestrrat-go/httpcc \
106           github.com/lestrrat-go/iter:github.com/lestrrat-go/iter \
107           github.com/lestrrat-go/jwx:github.com/lestrrat-go/jwx \
108           github.com/lestrrat-go/option:github.com/lestrrat-go/option \
109           github.com/lucasb-eyer/go-colorful:github.com/lucasb-eyer/go-colorful \
110           github.com/lufia/plan9stats:github.com/lufia/plan9stats \
111           github.com/mattn/go-colorable:github.com/mattn/go-colorable \
112           github.com/mattn/go-runewidth:github.com/mattn/go-runewidth \
113           github.com/matttproud/golang_protobuf_extensions:github.com/matttproud/golang_protobuf_extensions \
114           github.com/modern-go/concurrent:github.com/modern-go/concurrent \
115           github.com/modern-go/reflect2:github.com/modern-go/reflect2 \
116           github.com/muesli/ansi:github.com/muesli/ansi \
117           github.com/muesli/reflow:github.com/muesli/reflow \
118           github.com/muesli/termenv:github.com/muesli/termenv \
119           github.com/niemeyer/pretty:github.com/niemeyer/pretty \
120           github.com/philhofer/fwd:github.com/philhofer/fwd \
121           github.com/pkg/errors:github.com/pkg/errors \
122           github.com/power-devops/perfstat:github.com/power-devops/perfstat \
123           github.com/prometheus/common:github.com/prometheus/common \
124           github.com/prometheus/procfs:github.com/prometheus/procfs \
125           github.com/rivo/uniseg:github.com/rivo/uniseg \
126           github.com/sirupsen/logrus:github.com/sirupsen/logrus \
127           github.com/tidwall/match:github.com/tidwall/match \
128           github.com/tidwall/pretty:github.com/tidwall/pretty \
129           github.com/tklauser/go-sysconf:github.com/tklauser/go-sysconf \
130           github.com/tklauser/numcpus:github.com/tklauser/numcpus \
131           github.com/yusufpapurcu/wmi:github.com/yusufpapurcu/wmi \
132           go.etcd.io/etcd/api/v3:github.com/etcd-io/etcd/api/v3//api \
133           go.etcd.io/etcd/client/pkg/v3:github.com/etcd-io/etcd/api/v3//client/pkg \
134           go.etcd.io/etcd/client/v3:github.com/etcd-io/etcd/api/v3//client/v3 \
135           go.uber.org/atomic:go.uber.org/atomic \
136           go.uber.org/multierr:go.uber.org/multierr \
137           go.uber.org/zap:go.uber.org/zap \
138           golang.org/x/sync:go.googlesource.com/sync \
139           golang.org/x/sys:go.googlesource.com/sys \
140           google.golang.org/genproto:google.golang.org/genproto \
141           google.golang.org/grpc:google.golang.org/grpc \
142           google.golang.org/protobuf:google.golang.org/protobuf \
143           gopkg.in/ini.v1:gopkg.in/ini.v1 \
144           gopkg.in/yaml.v3:gopkg.in/yaml.v3"
145    for s in $sites; do
146        site_dest=$(echo $s | cut -d: -f1)
147        site_source=$(echo $s | cut -d: -f2)
148        mkdir -p vendor.copy/$site_dest
149        [ -n "$(ls -A vendor.copy/$site_dest/*.go 2> /dev/null)" ] && { echo "[INFO] vendor.fetch/$site_source -> $site_dest: go copy skipped (files present)" ; true ; } || { echo "[INFO] $site_dest: copying .go files" ; rsync -a --exclude='vendor/' --exclude='.git/' vendor.fetch/$site_source/ vendor.copy/$site_dest ; }
150    done
151
152    ln -sf vendor.copy vendor
153    # these are bad symlinks, go validates them and breaks the build if they are present
154    rm -f vendor/go.etcd.io/etcd/client/v3/example_*
155
156    cp ${WORKDIR}/modules.txt vendor/
157
158    ${GO} build -trimpath
159}
160
161do_install() {
162    install -d ${D}/${sbindir}
163    install ${S}/src/${GO_IMPORT}/mc ${D}/${sbindir}/mc
164}
165