#!/bin/bash

# Slackware build script for gopls

# Copyright 2023-2026 Andrew Clemons, Tokyo Japan
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

cd $(dirname $0) ; CWD=$(pwd)

PRGNAM=gopls
VERSION=${VERSION:-0.23.0}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  exit 0
fi

TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf tools-$PRGNAM-v$VERSION
tar xvf $CWD/tools-$PRGNAM-v$VERSION.tar.gz
cd tools-$PRGNAM-v$VERSION

# Vendor the Go module dependencies offline.
mapfile -t GO_MODULES < <(go mod edit -json gopls/go.mod | python3 -c "
import json
import sys
for r in json.load(sys.stdin).get('Require', []):
    print(r['Path'])
")
mapfile -t GO_TARBALLS < <(grep -oE 'https?://[^ ]+\.tar\.gz' $CWD/$PRGNAM.info | sed 's#.*/##')

GO_PAIRS=()
for i in "${!GO_MODULES[@]}"; do
  GO_PAIRS+=("${GO_MODULES[$i]} ${GO_TARBALLS[$(( i + 1 ))]}")
done

mapfile -t GO_PAIRS < <(printf '%s\n' "${GO_PAIRS[@]}" | sort)

rm -rf gopls/vendor
mkdir -p gopls/vendor

for PAIR in "${GO_PAIRS[@]}"; do
  MODULE="${PAIR% *}"
  TARBALL="${PAIR##* }"

  MODTMP="$(mktemp -d)"
  tar xf $CWD/$TARBALL -C "$MODTMP"
  MODTOP="$(find "$MODTMP" -mindepth 1 -maxdepth 1 -type d | head -1)"

  MODSRC="$(grep -rlxF "module $MODULE" --include=go.mod "$MODTOP" 2>/dev/null | head -1 || true)"
  if [ -n "$MODSRC" ]; then
    MODSRC="$(dirname "$MODSRC")"
  else
    MODSRC="$MODTOP"
  fi

  find "$MODSRC" -mindepth 2 -name go.mod -printf '%h\n' | sort -ru | xargs -r rm -rf

  mkdir -p "gopls/vendor/$(dirname "$MODULE")"
  rm -rf "gopls/vendor/$MODULE"
  mv "$MODSRC" "gopls/vendor/$MODULE"

  rm -rf "$MODTMP"
done

cat > gopls/vendor/modules.txt << "EOF"
# github.com/BurntSushi/toml v1.6.0
## explicit; go 1.18
github.com/BurntSushi/toml
github.com/BurntSushi/toml/internal
# github.com/fatih/camelcase v1.0.0
## explicit
github.com/fatih/camelcase
# github.com/fatih/gomodifytags v1.17.1-0.20250423142747-f3939df9aa3c
## explicit; go 1.13
github.com/fatih/gomodifytags/modifytags
# github.com/fatih/structtag v1.2.0
## explicit; go 1.12
github.com/fatih/structtag
# github.com/fsnotify/fsnotify v1.9.0
## explicit; go 1.17
github.com/fsnotify/fsnotify
github.com/fsnotify/fsnotify/internal
# github.com/google/go-cmp v0.7.0
## explicit; go 1.21
github.com/google/go-cmp/cmp
github.com/google/go-cmp/cmp/cmpopts
github.com/google/go-cmp/cmp/internal/diff
github.com/google/go-cmp/cmp/internal/flags
github.com/google/go-cmp/cmp/internal/function
github.com/google/go-cmp/cmp/internal/value
# github.com/google/jsonschema-go v0.4.3
## explicit; go 1.23.0
github.com/google/jsonschema-go/jsonschema
# github.com/google/safehtml v0.1.0
## explicit; go 1.14
github.com/google/safehtml
github.com/google/safehtml/internal/raw
github.com/google/safehtml/internal/safehtmlutil
github.com/google/safehtml/internal/template/raw
github.com/google/safehtml/template
github.com/google/safehtml/uncheckedconversions
# github.com/jba/templatecheck v0.7.1
## explicit; go 1.18
github.com/jba/templatecheck
# github.com/modelcontextprotocol/go-sdk v1.6.0
## explicit; go 1.25.0
github.com/modelcontextprotocol/go-sdk/auth
github.com/modelcontextprotocol/go-sdk/internal/json
github.com/modelcontextprotocol/go-sdk/internal/jsonrpc2
github.com/modelcontextprotocol/go-sdk/internal/mcpgodebug
github.com/modelcontextprotocol/go-sdk/internal/util
github.com/modelcontextprotocol/go-sdk/internal/xcontext
github.com/modelcontextprotocol/go-sdk/jsonrpc
github.com/modelcontextprotocol/go-sdk/mcp
github.com/modelcontextprotocol/go-sdk/oauthex
# github.com/segmentio/asm v1.2.1
## explicit; go 1.18
github.com/segmentio/asm/ascii
github.com/segmentio/asm/base64
github.com/segmentio/asm/cpu
github.com/segmentio/asm/cpu/arm
github.com/segmentio/asm/cpu/arm64
github.com/segmentio/asm/cpu/cpuid
github.com/segmentio/asm/cpu/x86
github.com/segmentio/asm/internal/unsafebytes
github.com/segmentio/asm/keyset
# github.com/segmentio/encoding v0.5.4
## explicit; go 1.23
github.com/segmentio/encoding/ascii
github.com/segmentio/encoding/iso8601
github.com/segmentio/encoding/json
# github.com/yosida95/uritemplate/v3 v3.0.2
## explicit; go 1.14
github.com/yosida95/uritemplate/v3
# golang.org/x/exp/typeparams v0.0.0-20260611194520-c48552f49976
## explicit; go 1.25.0
golang.org/x/exp/typeparams
# golang.org/x/mod v0.37.0
## explicit; go 1.25.0
golang.org/x/mod/internal/lazyregexp
golang.org/x/mod/modfile
golang.org/x/mod/module
golang.org/x/mod/semver
# golang.org/x/net v0.56.0
## explicit; go 1.25.0
golang.org/x/net/html
golang.org/x/net/html/atom
# golang.org/x/oauth2 v0.36.0
## explicit; go 1.25.0
golang.org/x/oauth2
golang.org/x/oauth2/internal
# golang.org/x/sync v0.21.0
## explicit; go 1.25.0
golang.org/x/sync/errgroup
# golang.org/x/sys v0.46.0
## explicit; go 1.25.0
golang.org/x/sys/cpu
golang.org/x/sys/unix
golang.org/x/sys/windows
# golang.org/x/telemetry v0.0.0-20260625142307-59b4966ccb57
## explicit; go 1.25.0
golang.org/x/telemetry
golang.org/x/telemetry/counter
golang.org/x/telemetry/counter/countertest
golang.org/x/telemetry/internal/config
golang.org/x/telemetry/internal/configstore
golang.org/x/telemetry/internal/counter
golang.org/x/telemetry/internal/crashmonitor
golang.org/x/telemetry/internal/mmap
golang.org/x/telemetry/internal/telemetry
golang.org/x/telemetry/internal/upload
# golang.org/x/text v0.38.0
## explicit; go 1.25.0
golang.org/x/text/unicode/rangetable
golang.org/x/text/unicode/runenames
# golang.org/x/tools v0.47.1-0.20260707181000-a299dadba899
## explicit; go 1.25.0
golang.org/x/tools/go/analysis
golang.org/x/tools/go/analysis/analysistest
golang.org/x/tools/go/analysis/checker
golang.org/x/tools/go/analysis/internal
golang.org/x/tools/go/analysis/internal/analysisflags
golang.org/x/tools/go/analysis/internal/checker
golang.org/x/tools/go/analysis/multichecker
golang.org/x/tools/go/analysis/passes/appends
golang.org/x/tools/go/analysis/passes/asmdecl
golang.org/x/tools/go/analysis/passes/assign
golang.org/x/tools/go/analysis/passes/atomic
golang.org/x/tools/go/analysis/passes/atomicalign
golang.org/x/tools/go/analysis/passes/bools
golang.org/x/tools/go/analysis/passes/buildssa
golang.org/x/tools/go/analysis/passes/buildtag
golang.org/x/tools/go/analysis/passes/cgocall
golang.org/x/tools/go/analysis/passes/composite
golang.org/x/tools/go/analysis/passes/copylock
golang.org/x/tools/go/analysis/passes/ctrlflow
golang.org/x/tools/go/analysis/passes/deepequalerrors
golang.org/x/tools/go/analysis/passes/defers
golang.org/x/tools/go/analysis/passes/directive
golang.org/x/tools/go/analysis/passes/errorsas
golang.org/x/tools/go/analysis/passes/fieldalignment
golang.org/x/tools/go/analysis/passes/framepointer
golang.org/x/tools/go/analysis/passes/hostport
golang.org/x/tools/go/analysis/passes/httpresponse
golang.org/x/tools/go/analysis/passes/ifaceassert
golang.org/x/tools/go/analysis/passes/inline
golang.org/x/tools/go/analysis/passes/inspect
golang.org/x/tools/go/analysis/passes/internal/gofixdirective
golang.org/x/tools/go/analysis/passes/loopclosure
golang.org/x/tools/go/analysis/passes/lostcancel
golang.org/x/tools/go/analysis/passes/modernize
golang.org/x/tools/go/analysis/passes/nilfunc
golang.org/x/tools/go/analysis/passes/nilness
golang.org/x/tools/go/analysis/passes/printf
golang.org/x/tools/go/analysis/passes/scannererr
golang.org/x/tools/go/analysis/passes/shadow
golang.org/x/tools/go/analysis/passes/shift
golang.org/x/tools/go/analysis/passes/sigchanyzer
golang.org/x/tools/go/analysis/passes/slog
golang.org/x/tools/go/analysis/passes/sortslice
golang.org/x/tools/go/analysis/passes/sqlrowserr
golang.org/x/tools/go/analysis/passes/stdmethods
golang.org/x/tools/go/analysis/passes/stdversion
golang.org/x/tools/go/analysis/passes/stringintconv
golang.org/x/tools/go/analysis/passes/structtag
golang.org/x/tools/go/analysis/passes/testinggoroutine
golang.org/x/tools/go/analysis/passes/tests
golang.org/x/tools/go/analysis/passes/timeformat
golang.org/x/tools/go/analysis/passes/unmarshal
golang.org/x/tools/go/analysis/passes/unreachable
golang.org/x/tools/go/analysis/passes/unsafeptr
golang.org/x/tools/go/analysis/passes/unusedresult
golang.org/x/tools/go/analysis/passes/unusedwrite
golang.org/x/tools/go/analysis/passes/waitgroup
golang.org/x/tools/go/analysis/singlechecker
golang.org/x/tools/go/analysis/suite/fix
golang.org/x/tools/go/analysis/suite/vet
golang.org/x/tools/go/analysis/unitchecker
golang.org/x/tools/go/ast/astutil
golang.org/x/tools/go/ast/edge
golang.org/x/tools/go/ast/inspector
golang.org/x/tools/go/buildutil
golang.org/x/tools/go/callgraph
golang.org/x/tools/go/callgraph/cha
golang.org/x/tools/go/callgraph/internal/chautil
golang.org/x/tools/go/callgraph/vta
golang.org/x/tools/go/callgraph/vta/internal/trie
golang.org/x/tools/go/cfg
golang.org/x/tools/go/gcexportdata
golang.org/x/tools/go/internal/cgo
golang.org/x/tools/go/loader
golang.org/x/tools/go/packages
golang.org/x/tools/go/ssa
golang.org/x/tools/go/ssa/ssautil
golang.org/x/tools/go/types/objectpath
golang.org/x/tools/go/types/typeutil
golang.org/x/tools/imports
golang.org/x/tools/internal/aliases
golang.org/x/tools/internal/analysis/analyzerutil
golang.org/x/tools/internal/analysis/driverutil
golang.org/x/tools/internal/analysis/typeindex
golang.org/x/tools/internal/astutil
golang.org/x/tools/internal/astutil/free
golang.org/x/tools/internal/diff
golang.org/x/tools/internal/diff/lcs
golang.org/x/tools/internal/drivertest
golang.org/x/tools/internal/event
golang.org/x/tools/internal/event/core
golang.org/x/tools/internal/event/export
golang.org/x/tools/internal/event/export/metric
golang.org/x/tools/internal/event/export/otel
golang.org/x/tools/internal/event/export/prometheus
golang.org/x/tools/internal/event/keys
golang.org/x/tools/internal/event/label
golang.org/x/tools/internal/expect
golang.org/x/tools/internal/facts
golang.org/x/tools/internal/flow
golang.org/x/tools/internal/fmtstr
golang.org/x/tools/internal/gcimporter
golang.org/x/tools/internal/gocommand
golang.org/x/tools/internal/gopathwalk
golang.org/x/tools/internal/graph
golang.org/x/tools/internal/imports
golang.org/x/tools/internal/jsonrpc2
golang.org/x/tools/internal/jsonrpc2/servertest
golang.org/x/tools/internal/jsonrpc2_v2
golang.org/x/tools/internal/modindex
golang.org/x/tools/internal/moreiters
golang.org/x/tools/internal/packagepath
golang.org/x/tools/internal/packagesinternal
golang.org/x/tools/internal/pkgbits
golang.org/x/tools/internal/pprof
golang.org/x/tools/internal/proxydir
golang.org/x/tools/internal/refactor
golang.org/x/tools/internal/refactor/inline
golang.org/x/tools/internal/robustio
golang.org/x/tools/internal/stdlib
golang.org/x/tools/internal/testenv
golang.org/x/tools/internal/testfiles
golang.org/x/tools/internal/typeparams
golang.org/x/tools/internal/typesinternal
golang.org/x/tools/internal/typesinternal/typeindex
golang.org/x/tools/internal/versions
golang.org/x/tools/refactor/satisfy
golang.org/x/tools/txtar
# golang.org/x/vuln v1.4.0
## explicit; go 1.25.0
golang.org/x/vuln/internal
golang.org/x/vuln/internal/buildinfo
golang.org/x/vuln/internal/client
golang.org/x/vuln/internal/derrors
golang.org/x/vuln/internal/gosym
golang.org/x/vuln/internal/goversion
golang.org/x/vuln/internal/govulncheck
golang.org/x/vuln/internal/openvex
golang.org/x/vuln/internal/osv
golang.org/x/vuln/internal/sarif
golang.org/x/vuln/internal/scan
golang.org/x/vuln/internal/semver
golang.org/x/vuln/internal/traces
golang.org/x/vuln/internal/vulncheck
golang.org/x/vuln/internal/web
golang.org/x/vuln/scan
# gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15
## explicit
# gopkg.in/yaml.v3 v3.0.1
## explicit
gopkg.in/yaml.v3
# honnef.co/go/tools v0.8.0-rc.1
## explicit; go 1.26.0
honnef.co/go/tools/analysis/callcheck
honnef.co/go/tools/analysis/code
honnef.co/go/tools/analysis/dfa
honnef.co/go/tools/analysis/dfa/dense
honnef.co/go/tools/analysis/edit
honnef.co/go/tools/analysis/facts/deprecated
honnef.co/go/tools/analysis/facts/generated
honnef.co/go/tools/analysis/facts/nilness
honnef.co/go/tools/analysis/facts/purity
honnef.co/go/tools/analysis/facts/tokenfile
honnef.co/go/tools/analysis/lint
honnef.co/go/tools/analysis/report
honnef.co/go/tools/config
honnef.co/go/tools/go/ast/astutil
honnef.co/go/tools/go/ir
honnef.co/go/tools/go/ir/irutil
honnef.co/go/tools/go/types/typeutil
honnef.co/go/tools/internal/iterutil
honnef.co/go/tools/internal/passes/buildir
honnef.co/go/tools/internal/sharedcheck
honnef.co/go/tools/internal/xtools-internal/aliases
honnef.co/go/tools/internal/xtools-internal/analysis/typeindex
honnef.co/go/tools/internal/xtools-internal/astutil
honnef.co/go/tools/internal/xtools-internal/graph
honnef.co/go/tools/internal/xtools-internal/moreiters
honnef.co/go/tools/internal/xtools-internal/typeparams
honnef.co/go/tools/internal/xtools-internal/typesinternal
honnef.co/go/tools/internal/xtools-internal/typesinternal/typeindex
honnef.co/go/tools/internal/xtools-internal/versions
honnef.co/go/tools/knowledge
honnef.co/go/tools/pattern
honnef.co/go/tools/printf
honnef.co/go/tools/quickfix
honnef.co/go/tools/quickfix/qf1001
honnef.co/go/tools/quickfix/qf1002
honnef.co/go/tools/quickfix/qf1003
honnef.co/go/tools/quickfix/qf1004
honnef.co/go/tools/quickfix/qf1005
honnef.co/go/tools/quickfix/qf1006
honnef.co/go/tools/quickfix/qf1007
honnef.co/go/tools/quickfix/qf1008
honnef.co/go/tools/quickfix/qf1009
honnef.co/go/tools/quickfix/qf1010
honnef.co/go/tools/quickfix/qf1011
honnef.co/go/tools/quickfix/qf1012
honnef.co/go/tools/simple
honnef.co/go/tools/simple/s1000
honnef.co/go/tools/simple/s1001
honnef.co/go/tools/simple/s1002
honnef.co/go/tools/simple/s1003
honnef.co/go/tools/simple/s1004
honnef.co/go/tools/simple/s1005
honnef.co/go/tools/simple/s1006
honnef.co/go/tools/simple/s1007
honnef.co/go/tools/simple/s1008
honnef.co/go/tools/simple/s1009
honnef.co/go/tools/simple/s1010
honnef.co/go/tools/simple/s1011
honnef.co/go/tools/simple/s1012
honnef.co/go/tools/simple/s1016
honnef.co/go/tools/simple/s1017
honnef.co/go/tools/simple/s1018
honnef.co/go/tools/simple/s1019
honnef.co/go/tools/simple/s1020
honnef.co/go/tools/simple/s1021
honnef.co/go/tools/simple/s1023
honnef.co/go/tools/simple/s1024
honnef.co/go/tools/simple/s1025
honnef.co/go/tools/simple/s1028
honnef.co/go/tools/simple/s1029
honnef.co/go/tools/simple/s1030
honnef.co/go/tools/simple/s1031
honnef.co/go/tools/simple/s1032
honnef.co/go/tools/simple/s1033
honnef.co/go/tools/simple/s1034
honnef.co/go/tools/simple/s1035
honnef.co/go/tools/simple/s1036
honnef.co/go/tools/simple/s1037
honnef.co/go/tools/simple/s1038
honnef.co/go/tools/simple/s1039
honnef.co/go/tools/simple/s1040
honnef.co/go/tools/staticcheck
honnef.co/go/tools/staticcheck/fakejson
honnef.co/go/tools/staticcheck/fakereflect
honnef.co/go/tools/staticcheck/fakexml
honnef.co/go/tools/staticcheck/sa1000
honnef.co/go/tools/staticcheck/sa1001
honnef.co/go/tools/staticcheck/sa1002
honnef.co/go/tools/staticcheck/sa1003
honnef.co/go/tools/staticcheck/sa1004
honnef.co/go/tools/staticcheck/sa1005
honnef.co/go/tools/staticcheck/sa1006
honnef.co/go/tools/staticcheck/sa1007
honnef.co/go/tools/staticcheck/sa1008
honnef.co/go/tools/staticcheck/sa1010
honnef.co/go/tools/staticcheck/sa1011
honnef.co/go/tools/staticcheck/sa1012
honnef.co/go/tools/staticcheck/sa1013
honnef.co/go/tools/staticcheck/sa1014
honnef.co/go/tools/staticcheck/sa1015
honnef.co/go/tools/staticcheck/sa1016
honnef.co/go/tools/staticcheck/sa1017
honnef.co/go/tools/staticcheck/sa1018
honnef.co/go/tools/staticcheck/sa1019
honnef.co/go/tools/staticcheck/sa1020
honnef.co/go/tools/staticcheck/sa1021
honnef.co/go/tools/staticcheck/sa1023
honnef.co/go/tools/staticcheck/sa1024
honnef.co/go/tools/staticcheck/sa1025
honnef.co/go/tools/staticcheck/sa1026
honnef.co/go/tools/staticcheck/sa1027
honnef.co/go/tools/staticcheck/sa1028
honnef.co/go/tools/staticcheck/sa1029
honnef.co/go/tools/staticcheck/sa1030
honnef.co/go/tools/staticcheck/sa1031
honnef.co/go/tools/staticcheck/sa1032
honnef.co/go/tools/staticcheck/sa2000
honnef.co/go/tools/staticcheck/sa2001
honnef.co/go/tools/staticcheck/sa2002
honnef.co/go/tools/staticcheck/sa2003
honnef.co/go/tools/staticcheck/sa3000
honnef.co/go/tools/staticcheck/sa3001
honnef.co/go/tools/staticcheck/sa4000
honnef.co/go/tools/staticcheck/sa4001
honnef.co/go/tools/staticcheck/sa4003
honnef.co/go/tools/staticcheck/sa4004
honnef.co/go/tools/staticcheck/sa4005
honnef.co/go/tools/staticcheck/sa4006
honnef.co/go/tools/staticcheck/sa4008
honnef.co/go/tools/staticcheck/sa4009
honnef.co/go/tools/staticcheck/sa4010
honnef.co/go/tools/staticcheck/sa4011
honnef.co/go/tools/staticcheck/sa4012
honnef.co/go/tools/staticcheck/sa4013
honnef.co/go/tools/staticcheck/sa4014
honnef.co/go/tools/staticcheck/sa4015
honnef.co/go/tools/staticcheck/sa4016
honnef.co/go/tools/staticcheck/sa4017
honnef.co/go/tools/staticcheck/sa4018
honnef.co/go/tools/staticcheck/sa4019
honnef.co/go/tools/staticcheck/sa4020
honnef.co/go/tools/staticcheck/sa4021
honnef.co/go/tools/staticcheck/sa4022
honnef.co/go/tools/staticcheck/sa4023
honnef.co/go/tools/staticcheck/sa4024
honnef.co/go/tools/staticcheck/sa4025
honnef.co/go/tools/staticcheck/sa4026
honnef.co/go/tools/staticcheck/sa4027
honnef.co/go/tools/staticcheck/sa4028
honnef.co/go/tools/staticcheck/sa4029
honnef.co/go/tools/staticcheck/sa4030
honnef.co/go/tools/staticcheck/sa4031
honnef.co/go/tools/staticcheck/sa4032
honnef.co/go/tools/staticcheck/sa5000
honnef.co/go/tools/staticcheck/sa5001
honnef.co/go/tools/staticcheck/sa5002
honnef.co/go/tools/staticcheck/sa5003
honnef.co/go/tools/staticcheck/sa5004
honnef.co/go/tools/staticcheck/sa5005
honnef.co/go/tools/staticcheck/sa5007
honnef.co/go/tools/staticcheck/sa5008
honnef.co/go/tools/staticcheck/sa5009
honnef.co/go/tools/staticcheck/sa5010
honnef.co/go/tools/staticcheck/sa5011
honnef.co/go/tools/staticcheck/sa5012
honnef.co/go/tools/staticcheck/sa6000
honnef.co/go/tools/staticcheck/sa6001
honnef.co/go/tools/staticcheck/sa6002
honnef.co/go/tools/staticcheck/sa6003
honnef.co/go/tools/staticcheck/sa6005
honnef.co/go/tools/staticcheck/sa6006
honnef.co/go/tools/staticcheck/sa9001
honnef.co/go/tools/staticcheck/sa9002
honnef.co/go/tools/staticcheck/sa9003
honnef.co/go/tools/staticcheck/sa9004
honnef.co/go/tools/staticcheck/sa9005
honnef.co/go/tools/staticcheck/sa9006
honnef.co/go/tools/staticcheck/sa9007
honnef.co/go/tools/staticcheck/sa9008
honnef.co/go/tools/staticcheck/sa9009
honnef.co/go/tools/staticcheck/sa9010
honnef.co/go/tools/stylecheck
honnef.co/go/tools/stylecheck/st1000
honnef.co/go/tools/stylecheck/st1001
honnef.co/go/tools/stylecheck/st1003
honnef.co/go/tools/stylecheck/st1005
honnef.co/go/tools/stylecheck/st1006
honnef.co/go/tools/stylecheck/st1008
honnef.co/go/tools/stylecheck/st1011
honnef.co/go/tools/stylecheck/st1012
honnef.co/go/tools/stylecheck/st1013
honnef.co/go/tools/stylecheck/st1015
honnef.co/go/tools/stylecheck/st1016
honnef.co/go/tools/stylecheck/st1017
honnef.co/go/tools/stylecheck/st1018
honnef.co/go/tools/stylecheck/st1019
honnef.co/go/tools/stylecheck/st1020
honnef.co/go/tools/stylecheck/st1021
honnef.co/go/tools/stylecheck/st1022
honnef.co/go/tools/stylecheck/st1023
# mvdan.cc/gofumpt v0.10.0
## explicit; go 1.25.0
mvdan.cc/gofumpt/format
mvdan.cc/gofumpt/internal/govendor/go/doc/comment
mvdan.cc/gofumpt/internal/govendor/go/format
mvdan.cc/gofumpt/internal/govendor/go/printer
mvdan.cc/gofumpt/internal/version
# mvdan.cc/xurls/v2 v2.6.0
## explicit; go 1.22.0
mvdan.cc/xurls/v2
EOF

chown -R root:root .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

cd gopls
go build -mod=vendor -ldflags "-X main.version=v$VERSION"
install -D -m0755 gopls $PKG/usr/bin/gopls

find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a \
  README.md \
  $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
