Compare commits

..

5 Commits

3 changed files with 33 additions and 15 deletions

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM debian:12-slim
RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-utils \
python3-apt \
python3-requests \
curl \
jq \
gpg \
gpg-agent && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /mnt
CMD ["/bin/bash"]

View File

@ -12,6 +12,9 @@ import requests
import sys import sys
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from threading import Lock from threading import Lock
import apt_pkg
apt_pkg.init() # 初始化 apt_pkg
package_version = {arch: {} for arch in ["all", "amd64", "i386", "arm64"]} package_version = {arch: {} for arch in ["all", "amd64", "i386", "arm64"]}
package_info = {arch: {} for arch in ["all", "amd64", "i386", "arm64"]} package_info = {arch: {} for arch in ["all", "amd64", "i386", "arm64"]}
@ -92,13 +95,8 @@ def get_latest(deb_packages: bytes):
arch = find_arch.search(v).group(1).decode() arch = find_arch.search(v).group(1).decode()
tmp_version = find_version.search(v).group(1).decode() tmp_version = find_version.search(v).group(1).decode()
with lock[arch]: with lock[arch]:
if ( # 使用 apt_pkg 进行版本比较
name not in package_version[arch] if name not in package_version[arch] or apt_pkg.version_compare(tmp_version, package_version[arch][name]) > 0:
or os.system(
f"dpkg --compare-versions {tmp_version} gt {package_version[arch][name]}"
)
== 0
):
package_version[arch][name] = tmp_version package_version[arch][name] = tmp_version
package_info[arch][name] = v package_info[arch][name] = v
except Exception as e: except Exception as e:
@ -111,7 +109,7 @@ def process_repo(r: dict):
获取仓库中不同架构子仓库的内容最后调用 get_latest 去重并保存 获取仓库中不同架构子仓库的内容最后调用 get_latest 去重并保存
""" """
try: try:
for arch, path in r["path"].items(): for path in r["path"].values():
get_latest(get_remote_packages(r["repo"], path)) get_latest(get_remote_packages(r["repo"], path))
except Exception as e: except Exception as e:
logging.error(f"Error processing repo {r.get('name', 'unknown')}: {e}") logging.error(f"Error processing repo {r.get('name', 'unknown')}: {e}")

17
run.sh
View File

@ -7,25 +7,28 @@ find get -type f -name "*.sh" -exec sh {} \;
# generate the html # generate the html
./gen-list-html.py ./gen-list-html.py
# generate the Packages file
## generate the local Packages file
cd deb cd deb
# generate the local Packages
apt-ftparchive packages . > tmpPackages apt-ftparchive packages . > tmpPackages
sed -i "s|\./\(https\?\):/|\1://|g" tmpPackages sed -i "s|\./\(https\?\):/|\1://|g" tmpPackages
cd .. cd ..
## merge the Packages file from local package
cat $(find packages -name "*.package") >> deb/tmpPackages cat $(find packages -name "*.package") >> deb/tmpPackages
# merge the Packages files from third-party repositories
## merge the Packages files from third-party repositories
./merge-apt-repo.py --local deb/tmpPackages ./merge-apt-repo.py --local deb/tmpPackages
# generate the Release file # generate the Release file
cd deb/dists/wcbing cd deb/dists/wcbing && \
echo 'Origin: wcbing APT Repo echo 'Origin: wcbing APT Repo
Label: wcbing Label: wcbing
Suite: wcbing Suite: wcbing
Codename: wcbing Codename: wcbing
Architectures: amd64 arm64 Architectures: amd64 arm64
Components: main Components: main
Description: wcbing APT Repo || wcbing 的 APT 仓库' > Release Description: wcbing APT Repo || wcbing 的 APT 仓库' > Release && \
apt-ftparchive release . >> Release apt-ftparchive release . >> Release && \
gpg --yes --detach-sign -a -o Release.gpg Release gpg --yes --detach-sign -a -o Release.gpg Release && \
gpg --yes --clearsign -o InRelease Release gpg --yes --clearsign -o InRelease Release