/usr/share/debomatic/modules/Repository.py is in debomatic 0.21-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | # Deb-o-Matic - Contents module
#
# Copyright (C) 2011-2015 Luca Falavigna
#
# Authors: Luca Falavigna <dktrkranz@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Generate local repository of built packages
import os
from datetime import datetime
from subprocess import call, PIPE
class DebomaticModule_Repository:
def __init__(self):
self.af = '/usr/bin/apt-ftparchive'
self.gpg = '/usr/bin/gpg'
def pre_build(self, args):
self.update_repository(args)
def post_build(self, args):
self.update_repository(args)
def pre_chroot(self, args):
if args.action:
self.update_repository(args)
def update_repository(self, args):
if args.opts.has_section('repository'):
gpgkey = args.opts.get('repository', 'gpgkey')
pubring = args.opts.get('repository', 'pubring')
secring = args.opts.get('repository', 'secring')
else:
return
if not os.access(self.af, os.X_OK):
return
if not os.access(self.gpg, os.X_OK):
return
cwd = os.getcwd()
distribution = args.distribution
if args.hostarchitecture:
arch = args.hostarchitecture
else:
arch = args.architecture
archive = args.directory
pool = os.path.join(archive, 'pool')
dists = os.path.join(archive, 'dists', distribution)
packages = os.path.join(dists, 'main', 'binary-%s' % arch)
packages_file = os.path.join(packages, 'Packages')
arch_release_file = os.path.join(packages, 'Release')
release_file = os.path.join(dists, 'Release')
release_gpg = os.path.join(dists, 'Release.gpg')
inrelease_gpg = os.path.join(dists, 'InRelease')
for dir in (pool, dists, packages):
if not os.path.isdir(dir):
os.makedirs(dir)
os.chdir(archive)
with open(packages_file, 'w') as fd:
call([self.af, 'packages', 'pool'], stdout=fd, stderr=PIPE)
with open(arch_release_file, 'w') as fd:
fd.write('Origin: Deb-O-Matic\n')
fd.write('Label: Deb-O-Matic\n')
fd.write('Archive: %s\n' % distribution)
fd.write('Component: main\n')
fd.write('Architecture: %s\n' % arch)
with open(release_file, 'w') as fd:
date = datetime.now().strftime('%A, %d %B %Y %H:%M:%S')
call([self.af, '-qq',
'-o', 'APT::FTPArchive::Release::Origin=Deb-o-Matic',
'-o', 'APT::FTPArchive::Release::Label=Deb-o-Matic',
'-o', 'APT::FTPArchive::Release::Suite=%s' % distribution,
'-o', 'APT::FTPArchive::Release::Date=%s' % date,
'-o', 'APT::FTPArchive::Release::Architectures=%s' % arch,
'-o', 'APT::FTPArchive::Release::Components=main',
'release', 'dists/%s' % distribution],
stdout=fd, stderr=PIPE)
with open(release_file, 'r+') as fd:
data = fd.read()
fd.seek(0)
fd.write(data.replace('MD5Sum', 'NotAutomatic: yes\nMD5Sum'))
call([self.gpg, '--no-default-keyring', '--keyring', pubring,
'--secret-keyring', secring, '-u', gpgkey, '--yes', '-a',
'-o', release_gpg, '-s', release_file])
call([self.gpg, '--no-default-keyring', '--keyring', pubring,
'--secret-keyring', secring, '-u', gpgkey, '--yes', '-a',
'-o', inrelease_gpg, '--clearsign', release_file])
os.chdir(cwd)
|