commit 6f8051ab74dc48456e8fbbfcf331fc850bf56d32 Author: wcbing Date: Thu Jul 25 18:39:01 2024 +0800 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2d78410 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +get/module/__pycache__/ +deb/ +deb.db \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..00e1a97 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# wcbing(APT)软件源/仓库 + +供 Debian 系发行版用户使用的软件源,收集一些国内常用软件的二进制包。 + +收录的软件说明: +- 发布的是已打包的文件,不接受源码和自行打包。 +- 有固定的更新地址,如官网和 Github Releases。 +- 现只收录了 x86_64。 + +## 使用现有仓库 + +```sh +sudo curl -o /etc/apt/keyrings/wcbing.gpg https://deb.wcbing.top/wcbing.gpg + +echo "deb [signed-by=/etc/apt/keyrings/wcbing.gpg] https://deb.wcbing.top /" | sudo tee /etc/apt/sources.list.d/wcbing.list +``` + +接下来执行 `sudo apt update` 更新即可。 diff --git a/get/module/check.py b/get/module/check.py new file mode 100644 index 0000000..fc3979f --- /dev/null +++ b/get/module/check.py @@ -0,0 +1,46 @@ +import requests +import os +import sqlite3 + + +def check_download(name, version, url, arch="x86_64"): + conn = sqlite3.connect("deb.db") + cur = conn.cursor() + + res = cur.execute( + "SELECT version, url FROM " + arch + " WHERE name = ?", (name,) + ).fetchall() + if len(res): + db_version = res[0][0] + db_url = res[0][1] + print(name + ": " + db_version) + if db_version != version: + print("└ Update: " + db_version + " -> " + version) + # remove old version + old_file_path = os.path.join("deb", str(db_url.split("/")[-1])) + if os.path.exists(old_file_path): + os.remove(old_file_path) + # download + file_path = os.path.join("deb", str(url.split("/")[-1])) + with open(file_path, "wb") as fw: + fw.write(requests.get(url).content) + # wirte to db + cur.execute( + "UPDATE " + arch + " SET version = ?, url = ? WHERE name = ?", + (version, url, name), + ) + else: + print(name + "\n└ Add: " + version) + # download + file_path = os.path.join("deb", str(url.split("/")[-1])) + with open(file_path, "wb") as fw: + fw.write(requests.get(url).content) + # wirte to db + cur.execute( + "INSERT INTO " + arch + "(name, version, url) VALUES (?, ?, ?)", + (name, version, url), + ) + + cur.close() + conn.commit() + conn.close() diff --git a/init.py b/init.py new file mode 100755 index 0000000..629330d --- /dev/null +++ b/init.py @@ -0,0 +1,31 @@ +#!/bin/python3 + +import os +import sqlite3 + +# create dir +os.mkdir("deb") + +# create table +conn = sqlite3.connect("deb.db") +conn.execute( + """ + CREATE TABLE IF NOT EXISTS x86_64 ( + name TEXT UNIQUE, + version TEXT, + url TEXT + ); + """ +) +# conn.execute( +# """ +# CREATE TABLE IF NOT EXISTS arm64 ( +# name TEXT UNIQUE, +# version TEXT, +# url TEXT +# ); +# """ +# ) + +conn.commit() +conn.close() diff --git a/update_gen.sh b/update_gen.sh new file mode 100644 index 0000000..a637b49 --- /dev/null +++ b/update_gen.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# check for updates +date +find get -maxdepth 1 -type f -name "*.py" -exec python3 {} \; + +# generate the files +cd deb +apt-ftparchive packages . > Packages +apt-ftparchive release . > Release +gpg --yes --armor --detach-sign --sign -o Release.gpg Release +gpg --yes --clearsign -o InRelease Release + +echo done \ No newline at end of file