mirror of https://github.com/Xhofe/alist
👷 add prebuilt for musl-libc
parent
75a983a965
commit
04724f7f0f
40
build.sh
40
build.sh
|
@ -57,7 +57,7 @@ BUILD() {
|
||||||
if [ "$1" == "release" ]; then
|
if [ "$1" == "release" ]; then
|
||||||
xgo -out "$appName" -ldflags="$ldflags" -tags=jsoniter .
|
xgo -out "$appName" -ldflags="$ldflags" -tags=jsoniter .
|
||||||
else
|
else
|
||||||
xgo -targets=linux/amd64,windows/amd64 -out alist -ldflags="$ldflags" -tags=jsoniter .
|
xgo -targets=linux/amd64,windows/amd64 -out "$appName" -ldflags="$ldflags" -tags=jsoniter .
|
||||||
fi
|
fi
|
||||||
mkdir "build"
|
mkdir "build"
|
||||||
mv alist-* build
|
mv alist-* build
|
||||||
|
@ -68,6 +68,43 @@ BUILD() {
|
||||||
cd ../..
|
cd ../..
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BUILD_MUSL() {
|
||||||
|
appName="alist"
|
||||||
|
builtAt="$(date +'%F %T %z')"
|
||||||
|
goVersion=$(go version | sed 's/go version //')
|
||||||
|
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
|
||||||
|
gitCommit=$(git log --pretty=format:"%h" -1)
|
||||||
|
gitTag=$(git describe --long --tags --dirty --always)
|
||||||
|
ldflags="\
|
||||||
|
-w -s \
|
||||||
|
-X 'github.com/Xhofe/alist/conf.BuiltAt=$builtAt' \
|
||||||
|
-X 'github.com/Xhofe/alist/conf.GoVersion=$goVersion' \
|
||||||
|
-X 'github.com/Xhofe/alist/conf.GitAuthor=$gitAuthor' \
|
||||||
|
-X 'github.com/Xhofe/alist/conf.GitCommit=$gitCommit' \
|
||||||
|
-X 'github.com/Xhofe/alist/conf.GitTag=$gitTag' \
|
||||||
|
"
|
||||||
|
BASE="https://musl.cc"
|
||||||
|
files=(x86_64-linux-musl-cross aarch64-linux-musl-cross arm-linux-musleabihf-cross mips-linux-musl-cross mips64-linux-musl-cross mips64el-linux-musl-cross mipsel-linux-musl-cross powerpc64le-linux-musl-cross s390x-linux-musl-cross)
|
||||||
|
for i in "${files[@]}"; do
|
||||||
|
url="${base_url}${i}.tgz"
|
||||||
|
curl -L -o "${i}.tgz" "${url}"
|
||||||
|
sudo tar xf "${i}.tgz" --strip-components 1 -C /usr/local
|
||||||
|
done
|
||||||
|
cd alist
|
||||||
|
OS_ARCHES=(linux-musl-amd64 linux-musl-arm64 linux-musl-arm linux-musl-mips linux-musl-mips64 linux-musl-mips64le linux-musl-mipsle linux-musl-ppc64le linux-musl-s390x)
|
||||||
|
CGO_ARGS=(x86_64-linux-musl-gcc aarch64-linux-musl-gcc arm-linux-musleabihf-gcc mips-linux-musl-gcc mips64-linux-musl-gcc mips64el-linux-musl-gcc mipsel-linux-musl-gcc powerpc64le-linux-musl-gcc s390x-linux-musl-gcc)
|
||||||
|
for i in "${!BUILDS[@]}"; do
|
||||||
|
os_arch=${OS_ARCHES[$i]}
|
||||||
|
cgo_cc=${CGO_ARGS[$i]}
|
||||||
|
echo building for ${os_arch}
|
||||||
|
export GOOS=${os_arch%%-*}
|
||||||
|
export GOARCH=${os_arch##*-}
|
||||||
|
export CC=${cgo_cc}
|
||||||
|
export CGO_ENABLED=1
|
||||||
|
go build -o ./build/$appName-$os_arch -ldflags="$ldflags" -tags=jsoniter alist.go
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
RELEASE() {
|
RELEASE() {
|
||||||
cd alist/build
|
cd alist/build
|
||||||
mkdir compress
|
mkdir compress
|
||||||
|
@ -94,6 +131,7 @@ elif [ "$1" = "build" ]; then
|
||||||
BUILD build
|
BUILD build
|
||||||
elif [ "$1" = "release" ]; then
|
elif [ "$1" = "release" ]; then
|
||||||
BUILD release
|
BUILD release
|
||||||
|
BUILD_MUSL
|
||||||
RELEASE
|
RELEASE
|
||||||
else
|
else
|
||||||
echo -e "${RED_COLOR} Parameter error ${RES}"
|
echo -e "${RED_COLOR} Parameter error ${RES}"
|
||||||
|
|
Loading…
Reference in New Issue