apt-packages-depend/add.py

86 lines
4.0 KiB
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
import os
import sys
import random
import datetime
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
#os.chdir(programPath)
# 获取版本号和架构
def GetDebVersion(deb: str):
global all
tempPath = f"/tmp/get-deb-{random.randint(0, 10000)}"
os.system(f"dpkg -e '{deb}' '{tempPath}'")
version = "1.0.0"
arch = "amd64"
package = "demo"
with open(f"{tempPath}/control", "r") as file:
all = file.read()
with open(f"{tempPath}/control", "r") as file:
while True:
read = file.readline().replace("\n", "")
if read == "":
break
if "Version:" in read:
version = read.replace("\n", "").replace("Version:", "").strip()
if "Architecture:" in read:
arch = read.replace("\n", "").replace("Architecture:", "").strip()
if "Package:" in read:
package = read.replace("\n", "").replace("Package:", "").strip()
os.system(f"rm -rfv '{tempPath}'")
return [arch, version, package]
debInfo = GetDebVersion(sys.argv[1])
if not os.path.exists(f"{programPath}/{debInfo[2][0].lower()}/{debInfo[2]}"):
os.makedirs(f"{programPath}/{debInfo[2][0].lower()}/{debInfo[2]}")
os.system(f"cp -v '{sys.argv[1]}' '{programPath}/{debInfo[2][0].lower()}/{debInfo[2]}/{debInfo[2]}_{debInfo[1]}_{debInfo[0]}.deb'")
os.chdir(programPath)
os.system(f"bash ../shell/incremental-updating-packages.sh '{programPath}'")
os.system("git add .")
os.system(f"git commit -m '新增 {debInfo[2]}_{debInfo[1]}_{debInfo[0]}.deb'")
os.system("git push")
# 更新 pages
try:
with open(f"{programPath}/../apt-packages-websize-depend/list.html", "r") as file:
html = file.read()
except:
html = ""
html = f"""<h2>{debInfo[2]}_{debInfo[1]}_{debInfo[0]}.deb</h2>
<p><b>下载链接:<a href='https://code.gitlink.org.cn/gfdgd-xi-org/apt-packages-program/raw/branch/master/{debInfo[2][0].lower()}/{debInfo[2]}/{debInfo[2]}_{debInfo[1]}_{debInfo[0]}.deb'>https://code.gitlink.org.cn/gfdgd-xi-org/apt-packages-program/raw/branch/master/{debInfo[2][0].lower()}/{debInfo[2]}/{debInfo[2]}_{debInfo[1]}_{debInfo[0]}.deb</a></b></p>
<pre><code>{all}</code></pre>
{html}"""
with open(f"{programPath}/../apt-packages-websize-depend/list.html", "w") as file:
file.write(html)
indexHtml = f"""<!DOCTYPE html>
<head>
<title>APT 依赖库列表By RacoonGX Team</title>
<meta name="viewport" content="width=device-width" initial-scale="1" />
<meta charset='UTF-8'>
<meta http-equiv="content-language" content="zh-cn">
<meta name="description" content="APT 依赖库列表By RacoonGX Team" >
</head>
<body>
<h1>APT 依赖库列表By RacoonGX Team</h1>
<p>点击下方链接下载</p>
<h3>推荐直接添加该源,添加方法:</h3>
<pre><code>
wget https://code.gitlink.org.cn/gfdgd-xi-org/apt-packages-program/raw/branch/master/sources/gitlink.sh; bash gitlink.sh; rm gitlink.sh
</code></pre>
<p>论坛:<a href='http://bbs.racoongx.cn'>http://bbs.racoongx.cn</a></p>
<p>程序分享站:<a href='https://bbs.racoongx.cn/t/cpu-China-APP'>https://bbs.racoongx.cn/t/cpu-China-APP</a></p>
<h3>更新时间:{datetime.datetime.now().year}{datetime.datetime.now().month}{datetime.datetime.now().day}{datetime.datetime.now().hour}:{datetime.datetime.now().minute}:{datetime.datetime.now().second}</h3>
<hr/>
{html}
<hr/>
<h1 id="copyright">©2020~{datetime.datetime.now().year} gfdgd xi、为什么您不喜欢熊出没和阿布呢</h1>
</body>
<script>
window.onload = function(){{
var d = new Date();
document.getElementById("copyright").innerHTML = "©2020~" + d.getFullYear() + " gfdgd xi、为什么您不喜欢熊出没和阿布呢";
}}
</script>
"""
with open(f"{programPath}/../apt-packages-websize-depend/index.html", "w") as file:
file.write(indexHtml)
os.system(f"cd '{programPath}/../apt-packages-websize-depend/'; git add . ; git commit -m '新增 {debInfo[2]}_{debInfo[1]}_{debInfo[0]}.deb' ; git push")