From b17392d18365b610a3eccb56ebc4d3eb9e130296 Mon Sep 17 00:00:00 2001 From: Petalzu Date: Thu, 26 Sep 2024 22:56:25 +0800 Subject: [PATCH] Modify descriptions and documentation --- LICENSE | 22 ++++++++++++++++++ Makefile | 9 ++++---- README.md | 64 +++++++++++++++++++++++++++++++-------------------- doc/DESIGN.md | 23 +++++++++++++++++- doc/SERVER.md | 13 ++++++----- doc/TEST.md | 2 +- 6 files changed, 96 insertions(+), 37 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bf03df2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2024 Petalzu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/Makefile b/Makefile index 6133f12..46bd5ea 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,8 @@ ifeq ($(ARCH), riscv64) TARGET = tinybpt OPENSSL_INCLUDE_DIR = /usr/local/openssl/riscv64/include OPENSSL_LIBRARIES = /usr/local/openssl/riscv64/lib - CXXFLAGS = -Wall -I./include -I$(OPENSSL_INCLUDE_DIR) -O2 -DCPPHTTPLIB_OPENSSL_SUPPORT - LDFLAGS = -static -L$(OPENSSL_LIBRARIES) + CXXFLAGS = -flto -fno-rtti -Wall -I./include -I$(OPENSSL_INCLUDE_DIR) -Os -O2 -DCPPHTTPLIB_OPENSSL_SUPPORT + LDFLAGS = -static -flto -L$(OPENSSL_LIBRARIES) -w -s LIBS = -lssl -lcrypto STRIP = ${ARCH}-linux-gnu-strip else ifeq ($(ARCH), x86_64) @@ -55,8 +55,9 @@ check: install: $(TARGET) @platform=$$(uname -m); \ if [ "$$platform" = "$(ARCH)" ]; then \ - mkdir -p /etc/tinybpt && mkdir -p /etc/ssl/certs; \ - cp $(TARGET) /bin/ && cp tinybpt_db.json /etc/tinybpt/ && cp cacert.pem /etc/ssl/certs/; \ + mkdir -p ./output/etc/tinybpt && mkdir -p ./output/etc/ssl/certs && mkdir -p ./output/bin; \ + cp $(TARGET) ./output/bin/ && cp tinybpt_db.json ./output/etc/tinybpt/ && cp cacert.pem ./output/etc/ssl/certs/; \ + echo "TinyBPT installed successfully, please check the output directory"; \ else \ echo "Error: Unsupported platform $$platform"; \ exit 1; \ diff --git a/README.md b/README.md index f9d3607..be4be4b 100644 --- a/README.md +++ b/README.md @@ -1,70 +1,84 @@ -# Tinybpt +# TinyBPT ## 介绍 -Tinybpt (Tiny Buildroot Packaging Tool) 是一个 buildroot 的包管理工具,主要处理 buildroot 的包依赖关系,提供包的安装、卸载等功能。 +TinyBPT (Tiny Buildroot Packaging Tool) 是一个 `buildroot` 的包管理工具,主要处理 `buildroot` 的包依赖关系,提供包的安装、卸载等功能。 ## 安装方法 +### 直接安装 + +如果要在 `buildroot` 构建的子系统中安装,则需要在主机下载后通过构建本地 `HTTP` 服务的方式提供给子系统下载。 + ```shell -# Online install -wget https://mirrors.lzu.edu.cn/buildroot-pkgs/riscv64/tinybpt-v0.1.0.tar.gz -# Use apache or other http service transfer to your riscv64 board -tar -xvf tinybpt.tar.gz -cd tinybpt +wget https://mirrors.lzu.edu.cn/buildroot-pkgs/riscv64/tinybpt/tinybpt-v0.1.0.tar.gz mkdir -p /etc/tinybpt && mkdir -p /etc/ssl/certs -cp tinybpt /bin/ && cp tinybpt_db.json /etc/tinybpt/ && cp cacert.pem /etc/ssl/certs/ +tar -xvf tinybpt-v0.1.0.tar.gz -C / +cd tinybpt +``` -# Local Build Use Makefile -git clone https://gitee.com/tinylab/buildroot-toolkit.git -cd buildroot-toolkit -# Download CA Certificates +### 本地 Makefile 编译安装 + +本地编译需要先编译 `OpenSSL`,详见 `doc/DESIGN.md` 中的说明。 + +```shell +git clone https://gitee.com/tinylab/tinybpt.git +cd tinybpt wget https://curl.se/ca/cacert.pem -# Compile openssl (version > 3.0.0) and install it to /usr/local/openssl/riscv64 -# Or ARCH=x86_64 -make ARCH=riscv64 +make make install +``` + +### 本地 CMake 编译安装 -# Local Build Use CMake -git clone https://gitee.com/tinylab/buildroot-toolkit.git tinybpt +```shell +git clone https://gitee.com/tinylab/tinybpt.git tinybpt cmake -S tinybpt -B build \ -G Ninja ninja -C build ninja -C tinybpt/build install +``` -# Specify db & download path +### 使用环境变量指定依赖和下载路径(可选) + +默认情况下,TinyBPT 会将依赖和下载的文件存储在 `/etc/tinybpt` 和 `/var/cache/tinybpt` 目录下,如果需要指定其他路径,可以使用环境变量 `TINYBPT_DB_PATH` 和 `TINYBPT_DOWNLOAD_PATH`。 + +```shell export TINYBPT_DB_PATH=/tinybpt_db.json -export TINYBPT_DOWNLOAD_PATH=/download +export TINYBPT_DOWNLOAD_PATH= ``` ## 使用方法 ```shell +# tinybpt Tiny buildroot packaging tool Usage: tinybpt [options] Commands: - install Install package - uninstall Uninstall package - list -all/-installed List all/installed packages - find Find package + install Install package + uninstall [-f] Uninstall package (use -f to force uninstall) + list -all/-installed List all/installed packages + find Find package Options: -h, -help Show help information -V, -version Show version information - -set-mirror Set mirror URL - -get-mirror Show mirror URL + -set-mirror Set mirror URL + -get-mirror Show mirror URL ``` ## 基本操作 使用 `tinybpt install/uninstall/list/find ` 进行包的安装、卸载、查找、列出操作。 +## 服务端配置 + ## 其他说明 - 本工具仅支持 riscv64 buildroot 用户使用。 diff --git a/doc/DESIGN.md b/doc/DESIGN.md index 4cea6a1..42a5159 100644 --- a/doc/DESIGN.md +++ b/doc/DESIGN.md @@ -1,7 +1,7 @@ # 设计文档 -## 数据结构 +## 软件架构 ``` +-------------------+ +-------------------+ @@ -85,6 +85,27 @@ 在任意版本 `buildroot` 目录下,运行 `script/` 目录下相关脚本解析依赖并通过后续服务端配置对比处理。 +### 编译流程 + +请先配置 `riscv64` 的 `openssl` 依赖,并采用如下编译方式: + +```shell +./Configure linux64-riscv64 no-zlib no-rc2 no-idea no-des no-bf no-cast no-md2 no-mdc2 no-dh no-err no-rc5 no-camellia no-seed no-tests -static --prefix=/usr/local/openssl/riscv64 --cross-compile-prefix=riscv64-linux-gnu- -flto + +make -j$(nproc) +make install_sw +``` + +然后移动到 `tinybpt` 目录下,执行如下命令: + +```shell +make ARCH=riscv64 -j$(nproc) +``` + +如果这些流程均在主机(非 `riscv` 机器)中完成,则需要将编译好的二进制文件,依赖文件和 `CA` 证书移动到嵌入式设备(`riscv` 机器)中。 + +如果是以调试为目的,可以使用 `ARCH=x86_64` 选项进行编译,或者使用 `CMake` 。编译完成后,只需要将依赖文件移动到相应位置,或者在环境变量中设置 `TINYBPT_DB_PATH` 。 + ### 工作流程 - **下载包**: 客户端从服务器下载指定的包文件。 diff --git a/doc/SERVER.md b/doc/SERVER.md index 2194f7a..f15e023 100644 --- a/doc/SERVER.md +++ b/doc/SERVER.md @@ -29,20 +29,21 @@ buildroot/ -- 源码镜像,直接镜像 buildroot 官方所有包的源码库 buildroot-pkgs/ -- 二进制包发布目录 riscv64/ -- 处理器架构,独立的话方便第三方镜像 main/2024.02.6/ -- main 用于存放所有 buildroot lts 版本的二进制包(动态编译) - kernel/v6.10/ -- kernel 用于存放 Linux lts 内核版本下的 tools 二进制包(以静态编译) - rootfs -- rootfs 用于存放 rootfs 包 - tinybpt-v0.1.0.tar.gz -- tinybpt 二进制包 + tools/v6.10/ -- tools 用于存放 Linux lts 内核版本下的 tools 二进制包(以静态编译) + rootfs/ -- rootfs 用于存放 rootfs 包 + tinybpt/ + tinybpt-v0.1.0.tar.gz -- tinybpt 二进制包 aarch64/ main/2024.02.6/ - kernel/v6.10/ + tools/v6.10/ x86_64/ main/2024.02.6/ - kernel/v6.10/ + tools/v6.10/ ``` ### 编译选项 -编译配置在 `/web/settings/.config` 中,使用编译配置替换原有配置。 +如果要自行编译,编译配置在 `/web/settings/.config` 中,使用编译配置替换原有配置,或使用 `make menuconfig` 自行勾选需要编译的包。 ```shell cd buildroot diff --git a/doc/TEST.md b/doc/TEST.md index c312091..f6268dc 100644 --- a/doc/TEST.md +++ b/doc/TEST.md @@ -2,7 +2,7 @@ 运行 `script/test.sh` 以运行测试用例。 -应看到以下输出: +应看到以下输出(版本号应随更新有所变化): ``` Running: ./tinybpt -- Gitee