-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: 以后每次更新仓库的话,在这儿记录一下对应的操作 #174
Comments
🌝👎哪有那么多空闲时间比比这些,没有自动化工具一律差评 |
给 aptly/reprepro 写个包装脚本,记录每次命令。日志本身就可以作为你想要的新闻。 |
今天tg里不也提到的divert功能,就很适合干这种事情。把 /usr/bin/aptly divert到 /usr/bin/aptly.real ,然后 /usr/bin/aptly 放包装脚本 |
@yangfl 🌝自动化工具这么好写的吗。 #!/usr/bin/env python3
# -*- encoding: utf-8 -*-
import os
import sys
import pwd
import subprocess
import debian.debfile
import logging
class AptlyWrapper:
def __init__(self):
logging.basicConfig(level=logging.INFO,
file='/home/repo/repo.log',
format='%(asctime)s : %(message)s')
self.subcommand = None
self.username = None
self.operation = None
self.codename = None
self.packages = list()
self.arg_parse(sys.argv)
with open('/proc/self/loginuid') as f:
loginuid = int(f.read().strip())
p = pwd.getpwuid(loginuid)
self.username = p.pw_name
def arg_parse(self, args):
def do_parse(args):
for i, v in enumerate(args):
if v.strip()[0] != '-':
yield v.strip()
parser = do_parse(args[1:])
self.subcommand = next(parser)
if self.subcommand != 'repo':
return
self.operation = next(parser)
self.codename = next(parser)
packages = list()
for i in reversed(args):
if i.strip()[0] != '-' and i[-4:] == '.deb':
packages.append(i.strip())
else:
break
try:
for i in packages:
dpc = debian.debfile.DebFile(i).control.debcontrol()
self.packages.append((dpc['Package'], dpc['Version']))
except Exception:
pass
def run(self):
status = subprocess.run(sys.argv)
# 这个地方的错误不好处理
if self.subcommand != 'repo' or self.operation not in ['add', 'remove']:
return
logging.info('Run command line: %s', " ".join(sys.argv))
logging.info('Return value: %d', status.check_returncode())
for i in self.packages:
logging.info('%s: %s %s IN %s BY %s',
self.operation, i[0], i[1],
self.codename, self.username)
if __name__ == '__main__':
AptlyWrapper().run() |
🌝你是不是忘了auto_upload.sh了 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
对仓库的操作主要有:
标题格式为:[U|R|N]: package version IN codename BY login_user_name
U,R,N分别对应update,remove,new
login_user_name是repo.debiancn.org上的登录名。
比如:
如果有进一步的描述可以写在正文里,没有就算了。
我会每个月做一个整理,发一个统计出来,当做 repo.debiancn.org 新闻的一部分
@hosiet @yangfl @alim0x @cdluminate
The text was updated successfully, but these errors were encountered: