alist编译记录

该文提供了在Linux环境下安装和编译Alist的详细步骤,包括前端和后端的构建,使用npm和pnpm管理依赖,以及通过git克隆源码。文章还介绍了如何进行本地编译,设置ldflags,并提供了两种不同的国际化方案,一种通过Crowdin平台,另一种是直接下载中文翻译文件。
摘要由CSDN通过智能技术生成

服务器环境

Linux version 3.10.0-327.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Nov 19 22:10:57 UTC 2015

前端

yum install npm
npm install -g npm@9.5.0
npm install pnpm -g
git clone --recursive https://github.com/alist-org/alist-web.git
cd alist-web
pnpm run build

后端

yum install screen
screen -R alist # 开screen避免掉线编译中断
rpm --import https://mirror.go-repo.io/centos/RPM-GPG-KEY-GO-REPO
curl -s https://mirror.go-repo.io/centos/go-repo.repo | tee /etc/yum.repos.d/go-repo.repo
yum install golang
git clone https://github.com/alist-org/alist.git
cd alist
vi build-local.sh # 新建一个本地编译的脚本,复制以下内容
------
rm -rf ./public/dist/*
cp -r ../alist-web/dist ./public/ # 注意前端代码路径
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" 
-----

bash build-local.sh  # 编译

./alist admin # 查看管理员信息
./alist server # 启动服务
vi ./data/config.json # 可修改端口

国际化

方案1:
# crowdin 环境变量配置,先去crowdin官网注册获取api-token,创建一个project获取project id
# https://crowdin.com/project/alist/zh-CN
export CROWDIN_PROJECT_ID=***
export CROWDIN_PERSONAL_TOKEN=***
pnpm run i18n:release

方案2:直接下载中文翻译文件
[root@ecs-G3x6u alist]# wget https://crowdin.com/backend/download/project/alist/zh-CN.zip --no-check-certificate
[root@ecs-G3x6u alist]# unzip zh-CN.zip 
Archive:  zh-CN.zip
   creating: src/
   creating: src/lang/
   creating: src/lang/zh-CN/
  inflating: src/lang/zh-CN/settings.json  
  inflating: src/lang/zh-CN/metas.json  
  inflating: src/lang/zh-CN/settings_other.json  
  inflating: src/lang/zh-CN/manage.json  
  inflating: src/lang/zh-CN/storages.json  
  inflating: src/lang/zh-CN/login.json  
  inflating: src/lang/zh-CN/drivers.json  
  inflating: src/lang/zh-CN/global.json  
  inflating: src/lang/zh-CN/users.json  
  inflating: src/lang/zh-CN/home.json  
 extracting: src/lang/zh-CN/index.json  
  inflating: src/lang/zh-CN/tasks.json  
  inflating: src/lang/zh-CN/br.json  
  inflating: src/lang/zh-CN/indexes.json  
[root@ecs-G3x6u alist]# ls
alist  alist-web  src  zh-CN.zip
[root@ecs-G3x6u alist]# cp -r ./src/lang/zh-CN ./alist-web/src/
app/        components/ hooks/      index.d.ts  lang/       main.tsx    pages/      store/      types/      utils/      
[root@ecs-G3x6u alist]# cp -r ./src/lang/zh-CN ./alist-web/src/lang/
[root@ecs-G3x6u alist]# cd alist-web/
[root@ecs-G3x6u alist-web]# node ./scripts/i18n.mjs

参考

本文同步于个人Github博客:https://github.com/cloudswave/blog/issues/29,欢迎留言。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,编译原理词法分析程序可以分为以下几个步骤: 1. 读入源代码文件,将其转化为字符流。 2. 从字符流中读取一个字符,判断其是否为分隔符(空格、制表符、换行符等),如果是则忽略。 3. 如果不是分隔符,则根据该字符的类型进行分类处理。例如,如果是字母,则可能是标识符或关键字;如果是数字,则可能是整数或浮点数;如果是运算符或界符,则直接输出。 4. 继续读取字符,直到读到一个分隔符或者无法识别的字符为止。 5. 输出识别出来的单词,并记录其类型。 下面是一个简单的词法分析程序示例(使用 Python 语言实现): ```python import re # 定义关键字列表 keywords = ['if', 'else', 'while', 'for', 'int', 'float', 'char'] # 定义正则表达式 id_pattern = r'[a-zA-Z_]\w*' num_pattern = r'\d+(\.\d+)?' op_pattern = r'[+\-*/=<>!&|]|\|\||&&' delimiter_pattern = r'[(),;{}[\]]' # 读入源代码文件 with open('source_code.txt', 'r') as f: source_code = f.read() # 将源代码转化为字符流 char_stream = list(source_code) # 定义词法分析结果列表 lex_result = [] # 词法分析 while char_stream: # 读取一个字符 char = char_stream.pop(0) # 判断是否为分隔符 if re.match(r'\s', char): continue # 判断是否为标识符或关键字 if re.match(id_pattern, char): token = char while char_stream and re.match(id_pattern, char_stream[0]): token += char_stream.pop(0) if token in keywords: lex_result.append(('keyword', token)) else: lex_result.append(('identifier', token)) # 判断是否为数字 elif re.match(num_pattern, char): token = char while char_stream and re.match(num_pattern, char_stream[0]): token += char_stream.pop(0) lex_result.append(('number', token)) # 判断是否为运算符或界符 elif re.match(op_pattern, char) or re.match(delimiter_pattern, char): lex_result.append(('operator', char)) # 无法识别的字符 else: print('Error: unrecognized character') # 输出词法分析结果 for token in lex_result: print(token) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值