33 lines
1.3 KiB
Python
Executable File
33 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import os
|
|
import sys
|
|
import random
|
|
# 获取版本号和架构
|
|
def GetDebVersion(deb: str):
|
|
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:
|
|
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"{debInfo[2][0].lower()}/{debInfo[2]}"):
|
|
os.makedirs(f"{debInfo[2][0].lower()}/{debInfo[2]}")
|
|
os.system(f"mv -v '{sys.argv[1]}' '{debInfo[2][0].lower()}/{debInfo[2]}/{debInfo[2]}_{debInfo[1]}_{debInfo[0]}.deb'")
|
|
os.system(f"bash ../app-mirror-upload-program-auto.sh")
|
|
os.system("git add .")
|
|
os.system(f"git commit -m '新增 {debInfo[2]}_{debInfo[1]}_{debInfo[0]}.deb'")
|
|
os.system("git push")
|
|
#os.system(f"'{sys.argv[1]}'") |