alist官方没有支持Loongarch架构的包,所以自行编译了一版,后面放出下载链接,可以直接下载使用。
- 下载源码
#后端
git clone https://github.com/alist-org/alist.git
#前端
git clone --recurse-submodules https://github.com/alist-org/alist-web.git
#切记--recurse-submodules一定要加上。否则下载过来的项目不含solid-router文件夹,最终会导致编译时报solid-router/src no such file or directory错误
- 前端编译:
pnpm install && pnpm build
- 解决loongarch没有pnpm问题
这里需要安装pnpm,为什么不用npm,答案是编译会不通过,研究了一下,改配置不如直接装pnpm,但是同样,现在pnpm没有龙架构的包,由于龙芯有lat二进制翻译,我们直接下载linux-x86的包运行就可以了。当然这样会导致后续各别包下载的架构需要手动调整,后面再讲。
下载后添加执行权限,添加软链接。
chmod +x pnpm-linux-x64
sudo ln -s /你的下载文件夹/pnpm-linux-x64 /usr/bin/pnpm
pnpm -v
如果正常返回版本,设置成功。
下面需要为pnpm添加龙芯nodejs源。
pnpm config set registry https://registry.loongnix.cn:4873
接下来就是
pnpm install
如果报错多装几次,龙芯源有时候会抽风。
然后
pnpm build
这里一般会报一个esbuild架构不匹配问题。需要esbuild/linux-loong64架构的包。
由于我们是用的linux-x86版本的pnpm,node_modules中存在的是linux-x86架构的包。解决方法是手动安装一下esbuild的二进制文件。注意,这里必须配置龙芯的源。否则找不到。0.14.54版本必须指定。否则默认安装的版本过高,后续build会报版本不一致错误。
pnpm install @esbuild/linux-loong64@0.14.54
- 注:这里如果NODE版本过低,会提示下面的错误
Error: Cannot find module 'node:path'
方法是提升本机的NODE版本。由于apt 直接安装的NODE版本是14.16.1,我们把版本提升到18以上再来build。
龙芯版本的nodejs可以看下面这个地址的安装说明:
使用nvm安装18版本即可
PC:~/Downloads/soft/alist-web$ nvm ls-remote node
v10.24.1 (LTS: Dubnium)
v10.24.2 (Latest LTS: Dubnium)
v12.19.1 (LTS: Erbium)
v12.22.12 (Latest LTS: Erbium)
v14.16.1 (LTS: Fermium)
v14.21.3 (Latest LTS: Fermium)
v16.3.0
v16.5.0
v16.17.1 (LTS: Gallium)
v16.20.1 (LTS: Gallium)
v16.20.2 (Latest LTS: Gallium)
-> v18.13.0 (LTS: Hydrogen)
v18.18.1 (Latest LTS: Hydrogen)
v20.8.0
nvm install 18.13.0
验证node版本
node -v
v18.13.0
- 注:添加中文语言包
下载中文语言包:
Translating alist to Chinese Simplified language - Crowdin
放入下图位置
执行
node ./scripts/i18n.mjs
好了。做完这些。再执行pnpm build应该就可以得到dist文件夹了。
编译完成,我们把他复制到alist后端目录下的public文件夹中。
cp -r dist/ ../alist/public/
- 后端编译
- 安装go
- 龙芯上的Golang | 龙芯开源社区
http://www.loongnix.cn/zh/toolchain/Golang/downloads-Go1.21/index.html上述页面下载loongarch下的go-lang安装包,1.19以上版本。下载后解压,然后添加软链接
sudo ln -s /data/home/uos/Downloads/go1.21.5.linux-loong64/go/bin/go /usr/bin/
输入go version,可以正常打印出版本号。安装成功
gcc,git可以直接apt install ,也可以在开源社区下载安装。我这里之前安装过了,不再详述。
下面开始编译ALIST后端
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)
version=$(git describe --long --tags --dirty --always)
webVersion=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/alist-web/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
ldflags="\
-w -s \
-X 'github.com/alist-org/alist/v3/internal/conf.BuiltAt=$builtAt' \
-X 'github.com/alist-org/alist/v3/internal/conf.GoVersion=$goVersion' \
-X 'github.com/alist-org/alist/v3/internal/conf.GitAuthor=$gitAuthor' \
-X 'github.com/alist-org/alist/v3/internal/conf.GitCommit=$gitCommit' \
-X 'github.com/alist-org/alist/v3/internal/conf.Version=$version' \
-X 'github.com/alist-org/alist/v3/internal/conf.WebVersion=$webVersion' \
"
go build -ldflags="$ldflags" .
打开终端,直接粘贴进去,如果环境没有问题,会剩下最后一行go build...直接回车即可。
由于go的默认代理较慢,编译时会较容易出现dial tcp 142.251.43.17:443: i/o timeout的错误。国内可加入如下语句切换go的源。
go env -w GOPROXY=https://goproxy.cn
我的编译日志
go build -ldflags="$ldflags" .
go: downloading github.com/charmbracelet/bubbles v0.16.1
go: downloading github.com/charmbracelet/bubbletea v0.24.2
go: downloading github.com/charmbracelet/lipgloss v0.9.1
go: downloading github.com/gin-gonic/gin v1.9.1
go: downloading github.com/go-resty/resty/v2 v2.9.1
go: downloading github.com/sirupsen/logrus v1.9.3
go: downloading github.com/spf13/cobra v1.7.0
go: downloading github.com/caarlos0/env/v9 v9.0.0
go: downloading github.com/natefinch/lumberjack v2.0.0+incompatible
go: downloading github.com/xhofe/tache v0.1.1
go: downloading gorm.io/driver/mysql v1.4.7
go: downloading gorm.io/driver/postgres v1.4.8
go: downloading gorm.io/driver/sqlite v1.4.4
go: downloading gorm.io/gorm v1.24.5
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/go-webauthn/webauthn v0.8.6
go: downloading github.com/Xhofe/go-cache v0.0.0-20220723083548-714439c8af9a
go: downloading github.com/deckarep/golang-set/v2 v2.3.1
go: downloading github.com/google/uuid v1.3.1
go: downloading github.com/gin-contrib/cors v1.4.0
go: downloading github.com/json-iterator/go v1.1.12
go: downloading golang.org/x/exp v0.0.0-20231006140011-7918f672742d
go: downloading github.com/mattn/go-runewidth v0.0.15
go: downloading github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81
go: downloading github.com/mattn/go-localereader v0.0.1
go: downloading github.com/mattn/go-isatty v0.0.19
go: downloading github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b
go: downloading github.com/muesli/cancelreader v0.2.2
go: downloading github.com/muesli/reflow v0.3.0
go: downloading github.com/muesli/termenv v0.15.2
go: downloading golang.org/x/sync v0.3.0
go: downloading golang.org/x/term v0.13.0
go: downloading golang.org/x/sys v0.13.0
go: downloading github.com/gin-contrib/sse v0.1.0
go: downloading golang.org/x/net v0.17.0
go: downloading github.com/maruel/natural v1.1.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/go-sql-driver/mysql v1.7.0
go: downloading github.com/jackc/pgx/v5 v5.3.0
go: downloading github.com/jaevor/go-nanoid v1.3.0
go: downloading github.com/xhofe/gsync v0.0.0-20230917091818-2111ceb38a25
go: downloading github.com/mattn/go-sqlite3 v1.14.15
go: downloading github.com/SheltonZhu/115driver v1.0.21
go: downloading github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible
go: downloading github.com/orzogc/fake115uploader v0.3.3-0.20230715111618-58f9eb76f831
go: downloading golang.org/x/time v0.3.0
go: downloading github.com/aws/aws-sdk-go v1.46.7
go: downloading github.com/avast/retry-go v3.0.0+incompatible
go: downloading github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564
go: downloading github.com/Xhofe/rateg v0.0.0-20230728072201-251a4e1adad4
go: downloading google.golang.org/appengine v1.6.7
go: downloading github.com/rclone/rclone v1.63.1
go: downloading github.com/jlaffaye/ftp v0.2.0
go: downloading github.com/golang-jwt/jwt/v4 v4.5.0
go: downloading github.com/ipfs/go-ipfs-api v0.7.0
go: downloading github.com/disintegration/imaging v1.6.2
go: downloading github.com/djherbis/times v1.5.0
go: downloading github.com/u2takey/ffmpeg-go v0.5.0
go: downloading golang.org/x/image v0.11.0
go: downloading github.com/t3rm1n4l/go-mega v0.0.0-20230228171823-a01a2cda13ca
go: downloading github.com/foxxorcat/mopan-sdk-go v0.1.4
go: downloading github.com/pkg/sftp v1.13.6
go: downloading golang.org/x/crypto v0.14.0
go: downloading github.com/hirochachacha/go-smb2 v1.1.0
go: downloading github.com/upyun/go-sdk/v3 v3.0.4
go: downloading github.com/foxxorcat/weiyun-sdk-go v0.1.3
go: downloading github.com/Xhofe/wopan-sdk-go v0.1.2
go: downloading github.com/jinzhu/now v1.1.5
go: downloading github.com/jinzhu/inflection v1.0.0
go: downloading github.com/coreos/go-oidc v2.2.1+incompatible
go: downloading github.com/pquerna/otp v1.4.0
go: downloading golang.org/x/oauth2 v0.12.0
go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: downloading github.com/modern-go/reflect2 v1.0.2
go: downloading github.com/rivo/uniseg v0.4.4
go: downloading github.com/aymanbagabas/go-osc52/v2 v2.0.1
go: downloading github.com/lucasb-eyer/go-colorful v1.2.0
go: downloading github.com/go-playground/validator/v10 v10.14.0
go: downloading github.com/pelletier/go-toml/v2 v2.0.8
go: downloading github.com/ugorji/go/codec v1.2.11
go: downloading google.golang.org/protobuf v1.31.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/blevesearch/bleve/v2 v2.3.10
go: downloading github.com/gaoyb7/115drive-webdav v0.1.8
go: downloading github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
go: downloading github.com/aead/ecdh v0.2.0
go: downloading github.com/andreburgaud/crypt2go v1.2.0
go: downloading github.com/pierrec/lz4/v4 v4.1.18
go: downloading github.com/golang/protobuf v1.5.3
go: downloading github.com/hashicorp/go-multierror v1.1.1
go: downloading github.com/blang/semver/v4 v4.0.0
go: downloading github.com/ipfs/boxo v0.12.0
go: downloading github.com/libp2p/go-libp2p v0.27.8
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading github.com/multiformats/go-multiaddr v0.9.0
go: downloading github.com/multiformats/go-multibase v0.2.0
go: downloading github.com/u2takey/go-utils v0.3.1
go: downloading github.com/Max-Sum/base32768 v0.0.0-20230304063302-18e6ce5945fd
go: downloading github.com/rfjakob/eme v1.1.2
go: downloading github.com/kr/fs v0.1.0
go: downloading github.com/gorilla/websocket v1.5.0
go: downloading github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc
go: downloading github.com/pquerna/cachecontrol v0.1.0
go: downloading gopkg.in/square/go-jose.v2 v2.6.0
go: downloading github.com/golang-jwt/jwt/v5 v5.0.0
go: downloading github.com/google/go-tpm v0.9.0
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading github.com/gabriel-vasile/mimetype v1.4.2
go: downloading github.com/go-playground/universal-translator v0.18.1
go: downloading github.com/leodido/go-urn v1.2.4
go: downloading golang.org/x/text v0.13.0
go: downloading github.com/jackc/pgpassfile v1.0.0
go: downloading github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a
go: downloading github.com/bluele/gcache v0.0.2
go: downloading github.com/blevesearch/bleve_index_api v1.0.6
go: downloading github.com/blevesearch/geo v0.1.18
go: downloading github.com/jmespath/go-jmespath v0.4.0
go: downloading github.com/hashicorp/errwrap v1.1.0
go: downloading github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3
go: downloading github.com/libp2p/go-flow-metrics v0.1.0
go: downloading github.com/ipfs/go-cid v0.4.1
go: downloading github.com/mr-tron/base58 v1.2.0
go: downloading github.com/multiformats/go-multicodec v0.9.0
go: downloading github.com/multiformats/go-multihash v0.2.3
go: downloading github.com/multiformats/go-base32 v0.1.0
go: downloading github.com/multiformats/go-base36 v0.2.0
go: downloading github.com/multiformats/go-varint v0.0.7
go: downloading github.com/prometheus/client_golang v1.16.0
go: downloading github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004
go: downloading github.com/geoffgarside/ber v1.1.0
go: downloading github.com/go-webauthn/x v0.1.4
go: downloading github.com/fxamacker/cbor/v2 v2.4.0
go: downloading github.com/go-playground/locales v0.14.1
go: downloading github.com/RoaringBitmap/roaring v1.2.3
go: downloading github.com/blevesearch/scorch_segment_api/v2 v2.1.6
go: downloading github.com/blevesearch/vellum v1.0.10
go: downloading github.com/blevesearch/zapx/v11 v11.3.10
go: downloading github.com/blevesearch/zapx/v12 v12.3.10
go: downloading github.com/blevesearch/zapx/v13 v13.3.10
go: downloading github.com/blevesearch/zapx/v14 v14.3.10
go: downloading github.com/blevesearch/zapx/v15 v15.3.13
go: downloading go.etcd.io/bbolt v1.3.7
go: downloading github.com/blevesearch/upsidedown_store_api v1.0.2
go: downloading github.com/blevesearch/gtreap v0.1.1
go: downloading github.com/benbjohnson/clock v1.3.0
go: downloading github.com/multiformats/go-multistream v0.4.1
go: downloading github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0
go: downloading github.com/minio/sha256-simd v1.0.0
go: downloading github.com/libp2p/go-buffer-pool v0.1.0
go: downloading github.com/golang/geo v0.0.0-20210211234256-740aa86cb551
go: downloading github.com/coreos/go-semver v0.3.1
go: downloading github.com/mattn/go-colorable v0.1.13
go: downloading github.com/x448/float16 v0.8.4
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.2.0
go: downloading github.com/prometheus/client_model v0.4.0
go: downloading github.com/prometheus/common v0.44.0
go: downloading github.com/prometheus/procfs v0.11.1
go: downloading github.com/bits-and-blooms/bitset v1.2.0
go: downloading github.com/blevesearch/mmap-go v1.0.4
go: downloading github.com/golang/snappy v0.0.4
go: downloading github.com/klauspost/cpuid/v2 v2.2.5
go: downloading github.com/shirou/gopsutil/v3 v3.23.7
go: downloading github.com/abbot/go-http-auth v0.4.0
go: downloading github.com/go-chi/chi/v5 v5.0.10
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.4
go: downloading github.com/blevesearch/snowballstem v0.9.0
go: downloading github.com/blevesearch/segment v0.9.1
go: downloading lukechampine.com/blake3 v1.1.7
go: downloading github.com/spaolacci/murmur3 v1.1.0
go: downloading github.com/blevesearch/go-porterstemmer v1.0.3
# github.com/alist-org/alist/v3
/data/home/uos/Downloads/go1.21.5.linux-loong64/go/pkg/tool/linux_loong64/link: mapping output file failed: no space left on device
最后提示没有空间了,重新执行了一下,1秒钟完成。
如果没有问题,当前目录下即可生成loongarch 架构的alist文件了,由于我们编译的时候跳过了语言包,所以只有英文界面。输入
./alist server
即可在浏览器中看到alist的界面了。
已经更新加载中文包版本
下载链接: