将 deb 作为变量,提高可复用性

This commit is contained in:
wcbing 2024-08-15 19:22:45 +08:00
parent f76e10bb63
commit 92d76ff3c1
14 changed files with 32 additions and 28 deletions

View File

@ -43,7 +43,7 @@ echo "deb [signed-by=/etc/apt/keyrings/wcbing.gpg] https://packages.wcbing.top/d
1. clone 本仓库,进入仓库目录。
2. 确认系统安装有 `Requests` Python 库Debian 系应该自带。
2. 运行 `init.py` 初始化。
2. 运行 `init_deb.py` 初始化。
默认只新建 x86_64需要其他架构请修改其中的SQL语句。
3. 创建一个**无密码**的 GPG 密钥对,导出 GPG 公钥文件待用。
4. 创建定时任务,定时运行 `update_gen.sh`

View File

@ -1,5 +1,5 @@
import requests
from module.check import check_download
from module.check import deb
name = "clash-verge"
@ -15,4 +15,4 @@ x64_deb_url = (
release_url + "/download/" + vversion + "/" + name + "_" + version + "_amd64.deb"
)
check_download(name, version, x64_deb_url)
deb(name, version, x64_deb_url)

View File

@ -1,6 +1,6 @@
import requests
import re
from module.check import check_download
from module.check import deb
x64_deb_req = "https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64"
@ -9,4 +9,4 @@ version = re.findall("_(.*)-", res.headers["Location"])[0]
x64_deb_url = res.headers["Location"]
# print(version, x64_deb_url)
check_download("code", version, x64_deb_url)
deb("code", version, x64_deb_url)

View File

@ -1,6 +1,6 @@
import requests
import json
from module.check import check_download
from module.check import deb
version_url = "https://versionhistory.googleapis.com/v1/chrome/platforms/linux/channels/stable/versions"
res = requests.get(version_url)
@ -9,4 +9,4 @@ version = json.loads(res.text)["versions"][0]["version"]
x64_deb_url = "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
check_download("google-chrome-stable", version, x64_deb_url)
deb("google-chrome-stable", version, x64_deb_url)

View File

@ -1,5 +1,5 @@
import requests
from module.check import check_download
from module.check import deb
name = "hugo"
@ -16,4 +16,4 @@ x64_deb_url = (
+ name + "_" + version + "_linux-amd64.deb"
)
check_download(name, version, x64_deb_url)
deb(name, version, x64_deb_url)

View File

@ -1,7 +1,7 @@
import requests
import re
import json
from module.check import check_download
from module.check import deb
res = requests.get("https://im.qq.com/rainbow/linuxQQDownload")
res.encoding = "utf-8"
@ -15,4 +15,4 @@ version = download_list["version"]
x64_deb_url = download_list["x64DownloadUrl"]["deb"]
# print(version, x64_deb_url)
check_download("linuxqq", version, x64_deb_url)
deb("linuxqq", version, x64_deb_url)

View File

@ -1,6 +1,6 @@
import requests
import re
from module.check import check_download
from module.check import deb
x64_deb_url = "https://go.microsoft.com/fwlink?linkid=2149051"
@ -9,4 +9,4 @@ version = re.findall("_(.*)_", res.headers["Location"])[0]
x64_deb_url = res.headers["Location"]
# print(version, x64_deb_url)
check_download("microsoft-edge-stable", version, x64_deb_url)
deb("microsoft-edge-stable", version, x64_deb_url)

View File

@ -1,5 +1,5 @@
import requests
from module.check import check_download
from module.check import deb
name = "mihomo"
@ -16,4 +16,4 @@ x64_deb_url = (
+ name + "-linux-amd64-compatible-" + vversion + ".deb"
)
check_download(name, version, x64_deb_url)
deb(name, version, x64_deb_url)

View File

@ -3,8 +3,8 @@ import os
import sqlite3
def check_download(name, version, url, arch="x86_64"):
conn = sqlite3.connect("deb.db")
def check_download(name, version, url, arch, file_type):
conn = sqlite3.connect(file_type + ".db")
cur = conn.cursor()
res = cur.execute(
@ -17,11 +17,11 @@ def check_download(name, version, url, arch="x86_64"):
if db_version != version:
print("└ Update: " + db_version + " -> " + version)
# remove old version
old_file_path = os.path.join("deb", str(db_url.split("/")[-1]))
old_file_path = os.path.join(file_type, 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]))
file_path = os.path.join(file_type, str(url.split("/")[-1]))
with open(file_path, "wb") as fw:
fw.write(requests.get(url).content)
# wirte to db
@ -32,7 +32,7 @@ def check_download(name, version, url, arch="x86_64"):
else:
print(name + "\n└ Add: " + version)
# download
file_path = os.path.join("deb", str(url.split("/")[-1]))
file_path = os.path.join(file_type, str(url.split("/")[-1]))
with open(file_path, "wb") as fw:
fw.write(requests.get(url).content)
# wirte to db
@ -44,3 +44,7 @@ def check_download(name, version, url, arch="x86_64"):
cur.close()
conn.commit()
conn.close()
def deb(name, version, url, arch="x86_64"):
check_download(name, version, url, arch=arch, file_type="deb")

View File

@ -1,5 +1,5 @@
import requests
from module.check import check_download
from module.check import deb
name = "obsidian"
@ -15,4 +15,4 @@ x64_deb_url = (
release_url + "/download/" + vversion + "/" + name + "_" + version + "_amd64.deb"
)
check_download(name, version, x64_deb_url)
deb(name, version, x64_deb_url)

View File

@ -1,6 +1,6 @@
import requests
import re
from module.check import check_download
from module.check import deb
res = requests.get("https://y.qq.com/download/download.html")
res.encoding = "utf-8"
@ -12,4 +12,4 @@ version = re.findall(
x64_deb_url = re.findall(r"https://dl\S+\.deb", res.text)[0]
# print(version, x64_deb_url)
check_download("qqmusic", version, x64_deb_url)
deb("qqmusic", version, x64_deb_url)

View File

@ -1,5 +1,5 @@
import requests
from module.check import check_download
from module.check import deb
name = "rustdesk"
@ -14,4 +14,4 @@ x64_deb_url = (
release_url + "/download/" + version + "/" + name + "-" + version + "-x86_64.deb"
)
check_download(name, version, x64_deb_url)
deb(name, version, x64_deb_url)

View File

@ -1,6 +1,6 @@
import requests
import json
from module.check import check_download
from module.check import deb
"""
https://meeting.tencent.com/web-service/query-download-info?q=[\
@ -25,4 +25,4 @@ version = download_list["info-list"][0]["version"]
x64_deb_url = download_list["info-list"][0]["url"]
# print(version, x64_deb_url)
check_download("wemeet", version, x64_deb_url)
deb("wemeet", version, x64_deb_url)