...
 
Commits (505)
......@@ -7,3 +7,8 @@ omit =
*/tests/*
source = .
concurrency = multiprocessing
[report]
exclude_lines =
pragma: no cover
if __name__ == .__main__.:
......@@ -3,41 +3,28 @@
except:
- deploy@ftp-team/dak
test buster:
test bullseye:
<<: *template
image: debian:buster
image: debian:bullseye
parallel: 3
script: debian/run-ci --with-coverage
artifacts:
expire_in: 1 day
paths:
- coverage
- output
tests buster python3:
<<: *template
image: debian:buster
parallel: 2
script: debian/run-ci --python3
artifacts:
paths:
- coverage
- output
tests bullseye python3:
test bookworm:
<<: *template
image: debian:bullseye
parallel: 2
script: debian/run-ci --python3
image: debian:bookworm
parallel: 3
script: debian/run-ci --with-coverage
artifacts:
paths:
- coverage
- output
allow_failure: true
flake8:
<<: *template
image: debian:buster
image: debian:bullseye
script:
- apt-get update
- apt-get install -y flake8
......@@ -45,10 +32,10 @@ flake8:
get coverage:
<<: *template
image: debian:buster
image: debian:bullseye
stage: coverage
dependencies:
- test buster
- test bullseye
script:
- debian/run-coverage
artifacts:
......@@ -56,8 +43,21 @@ get coverage:
- coverage
- logs
sphinx:
image: debian:bookworm
script:
- apt-get update
- apt-get install -y build-essential python3-sphinx
- apt-get build-dep -y .
- make -C docs html
artifacts:
paths:
- docs/_build/html
except:
- deploy@ftp-team/dak
contributors:
image: debian:buster
image: debian:bullseye
stage: deploy
dependencies: []
script:
......@@ -75,9 +75,11 @@ pages:
- mkdir -p public/epydoc
- epydoc -q --html --graph all --css white -n DAK -o public/epydoc --include-log --show-imports dak daklib dakweb
- mv coverage public/coverage
- mv docs/_build/html public/docs
stage: deploy
dependencies:
- get coverage
- sphinx
artifacts:
paths:
- public
......
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
......
......@@ -38,7 +38,7 @@ BrowserMatch EmailSiphon spammer
Use DebianBuilddHostList
# ftp-master.d.o; for code-signing service
Require ip 138.16.160.17
Require ip 192.91.235.231
# whitelisted for Joerg Jaspert
Require ip 78.46.40.15
......@@ -46,6 +46,9 @@ BrowserMatch EmailSiphon spammer
Require ip 213.146.108.162
Require ip 2a01:198:5d0:0:21c:c0ff:fead:e3a3
# Proxy node of ci.debian.net for autopkgtesting the embargoed queue
Require ip 52.34.117.196
# AuthName "security.debian.org"
# AuthType Basic
# AuthUserFile /srv/security-master.debian.org/apache.htpasswd
......
......@@ -8,7 +8,7 @@ set -u
export SCRIPTVARS=/srv/security-master.debian.org/dak/config/debian-security/vars
. $SCRIPTVARS
DISTS="oldoldstable oldstable stable testing-security"
DISTS="oldoldstable oldstable stable-security testing-security"
if [ -e $ftpdir/Archive_Maintenance_In_Progress ]; then
exit 0
......@@ -21,7 +21,7 @@ trigger_wb() {
local send=
case "${dist}" in
oldoldstable|oldstable|stable|testing-security)
oldoldstable|oldstable|stable-security|testing-security)
send=$(dak admin suite-config get-value "${dist}" codename)
send=${send%-security}
;;
......
......@@ -9,13 +9,9 @@ function fix_overrides() {
done
find . -maxdepth 1 -mindepth 1 -type l -delete
for suite in oldoldstable oldstable stable testing; do
case $suite in
oldoldstable|oldstable|stable|testing)
override_suite=$(dak admin suite-config get-value "${suite}" codename)
;;
*) echo "Unknown suite type ($suite)"; exit 1;;
esac
for suite in oldstable stable-security testing-security; do
override_suite=$(dak admin suite-config get-value "${suite}" codename)
override_suite="${override_suite%-security}"
for component in $components; do
for override_type in $override_types; do
case $override_type in
......
......@@ -13,7 +13,6 @@ Dinstall
PackagesServer "packages.debian.org";
TrackingServer "tracker.debian.org";
Bcc "archive@ftp-master.debian.org";
// GroupOverrideFilename "override.group-maint";
SkipTime 300;
CloseBugs "false";
OverrideDisparityCheck "false";
......@@ -21,15 +20,14 @@ Dinstall
DefaultSuite "stable";
SuiteSuffix "updates/";
SuiteSuffixSuites {
"oldoldstable"; "oldstable"; "stable";
"buildd-oldoldstable"; "buildd-oldstable"; "buildd-stable";
"oldstable-debug"; "stable-debug";
"oldoldoldstable"; "oldoldstable"; "oldstable";
"buildd-oldoldoldstable"; "buildd-oldoldstable"; "buildd-oldstable";
"oldoldstable-debug"; "oldstable-debug";
};
UploadMailRecipients {
"mail:dak@security.debian.org";
"signer";
};
LegacyStableHasNoSections "false";
AllowSourceOnlyUploads "true";
};
......@@ -67,13 +65,6 @@ Import-LDAP-Fingerprints
LDAPDn "ou=users,dc=debian,dc=org";
LDAPServer "ldap://db.debian.org";
CACertFile "/etc/ssl/ca-debian/ca-certificates.crt";
ExtraKeyrings
{
"/srv/keyring.debian.org/keyrings/removed-keys.pgp";
"/srv/keyring.debian.org/keyrings/removed-keys.gpg";
"/srv/keyring.debian.org/keyrings/extra-keys.pgp";
};
KeyServer "wwwkeys.eu.pgp.net";
};
Clean-Queues
......@@ -108,11 +99,13 @@ SuiteMappings
"silent-map oldstable-security oldstable";
"silent-map oldoldstable-security oldoldstable";
"silent-map testing-security testing";
"silent-map jessie-security oldoldstable";
"silent-map stretch-security oldstable";
"silent-map buster-security stable";
"silent-map bullseye-security testing-security";
"silent-map bullseye testing-security";
"silent-map jessie-security oldoldoldstable";
"silent-map stretch-security oldoldstable";
"silent-map buster-security oldstable";
"silent-map bullseye-security stable-security";
"silent-map bullseye stable-security";
"silent-map bookworm-security testing-security";
"silent-map bookworm testing-security";
};
Dir
......@@ -159,6 +152,7 @@ ComponentMappings
{
"main updates/main";
"contrib updates/contrib";
"non-free-firmware updates/non-free-firmware";
"non-free updates/non-free";
};
......@@ -175,6 +169,10 @@ Urgency
};
};
ByUser {
dak "/srv/security-master.debian.org/dak/config/debian-security/dak.conf-priv";
};
Include {
"/srv/security-master.debian.org/dak/config/debian/common.conf";
"/srv/security-master.debian.org/dak/config/debian/external-signatures.conf";
......@@ -183,7 +181,8 @@ Include {
External-Signature-Requests {
Default-Suites {
"testing-security";
"stable";
"stable-security";
"oldstable";
};
Export "/srv/security-master.debian.org/build-queues/project/external-signatures/requests.json";
ExportSigningKeys { "AA6C6D7FECC2E7EED05CDB4EAAC8C6B0AF06C355"; };
......
Dinstall {
// Mail-Signature-Key "0624E959E0209B869917FB26A3ADB4776A5D187D";
};
name_real="Debian Security Archive Automatic Signing Key"
name_email="ftpmaster@debian.org"
name_comment="10/buster"
name_comment="12/bookworm"
......@@ -21,6 +21,6 @@ source ${configdir}/../common/variables
declare -r uploadhost=ftp-master.debian.org
declare -r uploaddir=/pub/UploadQueue/
components="main non-free contrib"
components="main non-free-firmware non-free contrib"
override_types="deb dsc udeb"
declare -r suites=$(dak admin s list)
......@@ -9,8 +9,8 @@ Use common-debian-service-https-redirect * ftp-master.debian.org
Use common-debian-service-ssl ftp-master.debian.org
Use common-ssl-HSTS
Use http-pkp-ftp-master.debian.org
Redirect permanent /.git https://salsa.debian.org/ftp-team/website.git
Redirect permanent /proposed-updates.html https://release.debian.org/proposed-updates/stable.html
Redirect permanent /oldstable-proposed-updates.html https://release.debian.org/proposed-updates/oldstable.html
Redirect permanent /testing/hints/transitions.yaml https://ftp-master.debian.org/transitions.yaml
......
......@@ -5,4 +5,5 @@ Dinstall::AllowSourceOnlyNewSources {
"firefox-esr";
"linux";
"linux-4.19";
"linux-5.10";
};
......@@ -182,10 +182,10 @@ function _runtasks() {
;;
*)
GO=(
FUNC=${FUNC}
TIME=${TIME}
ARGS=${ARGS}
ERR=${ERR}
FUNC="${FUNC}"
TIME="${TIME}"
ARGS="${ARGS}"
ERR="${ERR}"
)
if [[ ${BACKGROUND} == true ]]; then
stage $GO &
......
......@@ -26,6 +26,12 @@ function wbdump() {
${masterdir}/scripts/nfu/get-w-b-db
}
# Write out sections file
function writesections() {
log "Writing sections.822"
dak write-sections > ${exportdir}/sections.822
}
# Generate stats about the new queue
function newstats() {
log "Generating stats about the new queue"
......
......@@ -9,3 +9,4 @@ newstats none none
contributor none none false false
cleanurgencylog none none false false
update-buildd-admin-keyring none none false false
writesections none none false false
......@@ -102,13 +102,6 @@ Import-LDAP-Fingerprints
LDAPDn "ou=users,dc=debian,dc=org";
LDAPServer "ldap://db.debian.org";
CACertFile "/etc/ssl/ca-debian/ca-certificates.crt";
ExtraKeyrings
{
"/srv/keyring.debian.org/keyrings/removed-keys.pgp";
"/srv/keyring.debian.org/keyrings/removed-keys.gpg";
"/srv/keyring.debian.org/keyrings/extra-keys.pgp";
};
KeyServer "wwwkeys.eu.pgp.net";
};
Clean-Suites
......@@ -123,25 +116,33 @@ Process-New
SuiteMappings
{
"silent-map jessie-security oldoldstable-security";
"silent-map stretch-security oldstable-security";
"silent-map buster-security stable-security";
"silent-map bullseye-security testing-security";
"silent-map jessie-security oldoldoldstable-security";
"silent-map stretch-security oldoldstable-security";
"silent-map buster-security oldstable-security";
"silent-map bullseye-security stable-security";
"silent-map bookworm-security testing-security";
"propup-version stable-security testing testing-proposed-updates unstable";
"propup-version testing-security unstable";
"propup-version testing unstable";
"map jessie oldoldstable";
"map jessie-proposed-updates oldoldstable-proposed-updates";
"map jessie-updates oldoldstable-proposed-updates";
"map stretch oldstable";
"map stretch-proposed-updates oldstable-proposed-updates";
"map stretch-updates oldstable-proposed-updates";
"map buster stable";
"map buster-proposed-updates proposed-updates";
"map buster-updates proposed-updates";
"map bullseye testing";
"map bullseye-proposed-updates testing-proposed-updates";
"map bullseye-updates testing-proposed-updates";
"map jessie oldoldoldstable";
"map jessie-proposed-updates oldoldoldstable-proposed-updates";
"map jessie-updates oldoldoldstable-proposed-updates";
"map stretch oldoldstable";
"map stretch-proposed-updates oldoldstable-proposed-updates";
"map stretch-updates oldoldstable-proposed-updates";
"map buster oldstable";
"map buster-proposed-updates oldstable-proposed-updates";
"map buster-updates oldstable-proposed-updates";
"map buster-backports-sloppy oldstable-backports-sloppy";
"map bullseye stable";
"map bullseye-proposed-updates proposed-updates";
"map bullseye-updates proposed-updates";
"map bullseye-backports-sloppy stable-backports-sloppy";
"map bookworm testing";
"map bookworm-proposed-updates testing-proposed-updates";
"map bookworm-updates testing-proposed-updates";
"map bookworm-backports testing-backports";
"map bookworm-backports-sloppy testing-backports-sloppy";
"map sid unstable";
"map rc-buggy experimental";
"map oldoldstable oldoldstable-proposed-updates";
......@@ -258,11 +259,6 @@ Urgency
};
};
Contents
{
Root "/srv/ftp-master.debian.org/test/";
}
Common
{
// The default number of threads for multithreading parts of dak:
......@@ -275,6 +271,10 @@ ByGroup {
backports "/srv/ftp-master.debian.org/dak/config/debian/dak.conf-backports";
};
ByUser {
dak "/srv/ftp-master.debian.org/dak/config/debian/dak.conf-priv";
};
Command::DM {
ACL "dm";
AdminKeyrings {
......@@ -309,6 +309,11 @@ External-Signature-Requests {
"unstable";
"testing-proposed-updates";
"proposed-updates";
"oldstable-proposed-updates";
"bookworm-backports";
"bullseye-backports-sloppy";
"bullseye-backports";
"buster-backports-sloppy";
"buster-backports";
"stretch-backports-sloppy";
"stretch-backports";
......
Dinstall {
// Mail-Signature-Key "F38AA24EB85F09F9923CA4949BF6A82061CCB921";
};
......@@ -105,7 +105,10 @@ function dep11() {
# Yay, worked, lets copy around
for dir in ${extimportdists}; do
if [[ -d ${dir}/ ]]; then
for comp in main contrib non-free; do
for comp in main contrib non-free non-free-firmware; do
if ! [[ -d ${dir}/${comp} ]]; then
continue
fi
mkdir -p ${ftpdir}/dists/${dir}/${comp}/dep11
cd ${dir}/${comp}
rsync -rtq --delete --delete-after --exclude by-hash --exclude "./*.tmp" . ${ftpdir}/dists/${dir}/${comp}/dep11/.
......@@ -127,7 +130,7 @@ function cruft() {
function dominate() {
log "Removing obsolete source and binary associations"
dak dominate
dak manage-debug-suites unstable-debug experimental-debug stretch-backports-debug buster-backports-debug testing-proposed-updates-debug
dak manage-debug-suites unstable-debug experimental-debug stretch-backports-debug buster-backports-debug buster-backports-sloppy-debug bullseye-backports-debug bullseye-backports-sloppy-debug bookworm-backports-debug testing-proposed-updates-debug
}
function autocruft() {
......@@ -233,7 +236,7 @@ function mkfilesindices() {
cd $base/ftp/indices/files/components
ARCHLIST=$(tempfile)
ARCHLIST=$(mktemp)
log "Querying postgres"
local query="
......@@ -413,12 +416,6 @@ function mirror() {
write_project_trace "${tracepaths[@]}"
}
function expire() {
log "Expiring old database dumps..."
cd ${base}/backup
${scriptsdir}/expire_dumps -d . -p -f "dump_*"
}
function transitionsclean() {
log "Removing out of date transitions..."
cd ${base}
......
......@@ -44,7 +44,6 @@ ddaccess none ddaccessible\ sync fal
LOCK CHANGELOG 300 exclusive false
changelogs none changelogs false true
pg_timestamp postdinstall pg_dump2 true false
expire none expire_dumps false true
transitionsclean none transitionsclean false true
dm none none false true
bts none none false true
......
// New packages also needs to be added in
// https://salsa.debian.org/ftp-team/code-signing/-/blob/master/etc/debian-prod.yaml
External-Signature-Requests {
Sources {
// src:fwupd: secure boot moved to src:fwupd-efi in bookworm.
// This entry can be removed once bullseye is no longer supported.
fwupd {
Packages {
"fwupd-amd64-signed-template";
......@@ -11,6 +15,17 @@ External-Signature-Requests {
"amd64"; "arm64"; "armhf"; "i386";
};
};
fwupd-efi {
Packages {
"fwupd-amd64-signed-template";
"fwupd-arm64-signed-template";
"fwupd-armhf-signed-template";
"fwupd-i386-signed-template";
};
Architectures {
"amd64"; "arm64"; "armhf"; "i386";
};
};
fwupdate {
Packages {
"fwupdate-amd64-signed-template";
......@@ -42,6 +57,16 @@ External-Signature-Requests {
"amd64"; "arm64"; "i386";
};
};
linux-5.10 {
Packages {
"linux-image-5.10-amd64-signed-template";
"linux-image-5.10-arm64-signed-template";
"linux-image-5.10-i386-signed-template";
};
Architectures {
"amd64"; "arm64"; "i386";
};
};
shim {
Packages {
"shim-helpers-amd64-signed-template";
......
name_real="Debian Archive Automatic Signing Key"
name_email="ftpmaster@debian.org"
name_comment="10/buster"
name_comment="12/bookworm"
......@@ -43,7 +43,7 @@ function removalstxt() {
function rss() {
log "NEW RSS feed"
${base}/dak/tools/queue_rss.py -q ${queuedir}/new -o ${webdir}/rss/ -d ${base}/misc -l ${base}/log/
PYTHONHASHSEED=0 ${base}/dak/tools/queue_rss.py -q ${queuedir}/new -o ${webdir}/rss/ -d ${base}/misc -l ${base}/log/
log "Removals RSS feed"
${base}/dak/tools/removals.pl ${configdir}/removalsrss.rc > ${webdir}/rss/removals.rss
}
......
......@@ -195,14 +195,19 @@ log "Cleaning ${pusuite} and ${pusuite}-debug"
dak control-suite --remove ${pusuite} < ${pusuite}.list
dak control-suite --remove ${pusuite}-debug < ${pusuite}-debug.list
log "Cleaning changelogs from proposed-updates"
log "Cleaning changelogs from ${pusuite}"
pumorguedir="${base}/morgue/queues/$(date +%Y/%m)"
mkdir -p "${pumorguedir}"
cd ${ftpdir}/dists/${pusuite}
mv -t "${pumorguedir}" -n -- *.changes
if [[ -n ${skiplist} ]]; then
for pack in ${skiplist}; do
mv -t "${ftpdir}/dists/${pusuite}" ${pumorguedir}/${pack}_*.changes
# In corner cases, we may not have the changes file to move back - don't crash
if compgen -G ${pumorguedir}/${pack}_*.changes >/dev/null; then
mv -t "${ftpdir}/dists/${pusuite}" ${pumorguedir}/${pack}_*.changes
else
echo 'W: No changes files for ${pumorguedir}/${pack}_*.changes - check this is expected'
fi
done
fi
......@@ -226,6 +231,10 @@ propups unstable-debug
propups testing
propups testing-debug
log "Override changes"
echo "Any override changes? If so, process them in another window."
confirm
log "RM time"
hadrms=0
......@@ -328,7 +337,7 @@ done
read -e -p "Does the diff look ok? Enter anything if not, empty if yes (if nonempty, I will open an editor for you)" diffcheck
if [[ -n ${diffcheck} ]]; then
cd ${ftpdir}/dists/${suite}
edit-changelog "" ../README ../../README ../../README.html
edit-changelog "Opening changelog" ../README ../../README ../../README.html
rm -f -- ./*~ ../*~ ../../*~ ./"#"*"#" ../"#"*"#" ../../"#"*"#"
fi
......@@ -354,6 +363,7 @@ while :; do
dak dominate --force -s ${suite}
log "cruft-report"
dak cruft-report -s ${suite}
echo "Remember to keep the linux ABI included in the last release."
echo "Anything to remove? If so, copy/paste commands into another window, have fun"
echo "When done, continue here. Enter anything if you got removals, empty if not (will rerun dominate/cruft-report then)"
read -e -p "Anything removed?" -i "yes" removedstuff
......
......@@ -15,16 +15,6 @@ function purgeempty() {
done
}
function gitcleanup() {
log "Doing git stuff"
cd ${public}/git/dak.git
git gc --prune
git update-server-info
# now workaround a git bug not honoring the setup in logs/*
# (fix in development, but until it reached backports.org.......)
chmod -R g+w logs/
}
function fixsymlinks() {
log "Fixing symlinks"
local archiveroot
......
# FUNC ARGS TIME ERR BG
INCLUDE lock none true false
purgeempty none none false true
gitcleanup none none false true
fixsymlinks none none false true
linkmorgue none none false true
......@@ -44,12 +44,12 @@ if [[ -n ${SCRIPTVARS} ]]; then
fi
function evim() {
export EDITOR=$(which vim)
export EDITOR=vim
}
export PAGER=less
export LESS="-X"
export EDITOR=$(which emacs)
export EDITOR=emacs
export HISTFILESIZE=6000
export CDPATH=".:~:${base}:${public}:${queuedir}"
export PATH="~/bin/:${PATH}"
......
......@@ -16,8 +16,8 @@ Host bugs-sync
IdentityFile /srv/ftp-master.debian.org/s3kr1t/id_debbugs-vt
Host ddtp-sync
Hostname ddtp2.debian.net
User ddtp-dak
Hostname ddtp.debian.org
User ddtp
IdentityFile /srv/ftp-master.debian.org/s3kr1t/ddtp-dak.rsa
Host dep11-sync
......
#! /usr/bin/env python
#! /usr/bin/env python3
#
# Copyright (C) 2012, Ansgar Burchardt <ansgar@debian.org>
#
......@@ -16,15 +16,15 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from __future__ import print_function
import os
import sys
from collections.abc import Iterable
from typing import NoReturn, Optional
from daklib.dbconn import DBConn, Fingerprint, Keyring, Uid, ACL
def usage():
def usage(status: int = 0) -> NoReturn:
print("""Usage:
dak acl set-fingerprints <acl-name>
dak acl export-per-source <acl-name>
......@@ -42,9 +42,10 @@ def usage():
allow, deny:
Grant (revoke) per-source upload rights for ACL <acl-name>.
""")
sys.exit(status)
def get_fingerprint(entry, session):
def get_fingerprint(entry: str, session) -> Optional[Fingerprint]:
"""get fingerprint for given ACL entry
The entry is a string in one of these formats::
......@@ -54,13 +55,9 @@ def get_fingerprint(entry, session):
fpr:<fingerprint>
keyring:<keyring-name>
@type entry: string
@param entry: ACL entry
@param session: database session
@rtype: L{daklib.dbconn.Fingerprint} or C{None}
@return: fingerprint for the entry
:param entry: ACL entry
:param session: database session
:return: fingerprint for the entry
"""
field, value = entry.split(":", 1)
q = session.query(Fingerprint).join(Fingerprint.keyring).filter(Keyring.active == True) # noqa:E712
......@@ -79,7 +76,7 @@ def get_fingerprint(entry, session):
return q.all()
def acl_set_fingerprints(acl_name, entries):
def acl_set_fingerprints(acl_name: str, entries: Iterable[str]) -> None:
session = DBConn().session()
acl = session.query(ACL).filter_by(name=acl_name).one()
......@@ -98,7 +95,7 @@ def acl_set_fingerprints(acl_name, entries):
session.commit()
def acl_export_per_source(acl_name):
def acl_export_per_source(acl_name: str) -> None:
session = DBConn().session()
acl = session.query(ACL).filter_by(name=acl_name).one()
......@@ -131,7 +128,7 @@ def acl_export_per_source(acl_name):
session.close()
def acl_allow(acl_name, fingerprint, sources):
def acl_allow(acl_name: str, fingerprint: str, sources: Iterable[str]) -> None:
tbl = DBConn().tbl_acl_per_source
session = DBConn().session()
......@@ -156,7 +153,7 @@ def acl_allow(acl_name, fingerprint, sources):
session.commit()
def acl_deny(acl_name, fingerprint, sources):
def acl_deny(acl_name: str, fingerprint: str, sources: Iterable[str]) -> None:
tbl = DBConn().tbl_acl_per_source
session = DBConn().session()
......@@ -178,9 +175,11 @@ def main(argv=None):
if argv is None:
argv = sys.argv
if len(argv) > 1 and argv[1] in ('-h', '--help'):
usage(0)
if len(argv) < 3:
usage()
sys.exit(1)
usage(1)
if argv[1] == 'set-fingerprints':
acl_set_fingerprints(argv[2], sys.stdin)
......@@ -191,5 +190,4 @@ def main(argv=None):
elif argv[1] == 'deny':
acl_deny(argv[2], argv[3], argv[4:])
else:
usage()
sys.exit(1)
usage(1)
#!/usr/bin/env python
#! /usr/bin/env python3
"""
Add a user to to the uid/maintainer/fingerprint table and
......@@ -16,11 +16,11 @@ add his key to the GPGKeyring
# You don't want to read this script if you know python.
# I know what I say. I dont know python and I wrote it. So go and read some other stuff.
from __future__ import print_function
import subprocess
import sys
import apt_pkg
from typing import NoReturn
from daklib import utils
from daklib.dbconn import DBConn, get_or_set_uid, get_active_keyring_paths
......@@ -34,7 +34,7 @@ Logger = None
################################################################################
def usage(exit_code=0):
def usage(exit_code: int = 0) -> NoReturn:
print("""Usage: add-user [OPTION]...
Adds a new user to the dak databases and keyrings
......@@ -113,7 +113,7 @@ def main():
print("0x%s -> %s <%s> -> %s -> %s" % (Cnf["Add-User::Options::Key"], name, emails[0], uid, primary_key))
prompt = "Add user %s with above data (y/N) ? " % (uid)
yn = utils.our_raw_input(prompt).lower()
yn = utils.input_or_exit(prompt).lower()
if yn == "y":
# Create an account for the user?
......
#!/usr/bin/env python
#! /usr/bin/env python3
"""Configure dak parameters in the database"""
# Copyright (C) 2009 Mark Hymers <mhy@debian.org>
......@@ -19,12 +19,12 @@
################################################################################
from __future__ import print_function
import collections
import json
import six
import sys
from collections.abc import Callable, Sequence
from dataclasses import dataclass
from typing import Any, NoReturn, Optional
import apt_pkg
......@@ -43,30 +43,32 @@ dryrun = False
################################################################################
def warn(msg):
def warn(msg: str) -> None:
print(msg, file=sys.stderr)
def die(msg, exit_code=1):
def die(msg: str, exit_code: int = 1) -> NoReturn:
print(msg, file=sys.stderr)
sys.exit(exit_code)
def die_arglen(args, args_needed, msg):
def die_arglen(args: Sequence, args_needed: int, msg: str) -> None:
if len(args) < args_needed:
die(msg)
def get_suite_or_die(suite_name, session=None, error_message=None):
def get_suite_or_die(
suite_name: str,
session=None,
error_message="E: Invalid/unknown suite %(suite_name)s",
) -> Suite:
suite = get_suite(suite_name.lower(), session=session)
if suite is None:
if error_message is None:
error_message = "E: Invalid/unknown suite %(suite_name)s"
die(error_message % {'suite_name': suite_name})
return suite
def usage(exit_code=0):
def usage(exit_code: int = 0) -> NoReturn:
"""Perform administrative work on the dak database."""
print("""Usage: dak admin COMMAND
......@@ -193,7 +195,7 @@ Perform administrative work on the dak database.
################################################################################
def __architecture_list(d, args):
def __architecture_list(d, args) -> NoReturn:
q = d.session().query(Architecture).order_by(Architecture.arch_string)
for j in q.all():
# HACK: We should get rid of source from the arch table
......@@ -248,8 +250,7 @@ def __architecture_rm(d, args):
print("Architecture %s removed" % args[2])
def architecture(command):
args = [str(x) for x in command]
def architecture(args):
Cnf = utils.get_conf()
d = DBConn()
......@@ -285,7 +286,7 @@ def component_add(args):
component_name=name,
description=description,
ordering=ordering,
)
)
for option in args[3:]:
(key, value) = option.split('=')
......@@ -294,7 +295,7 @@ def component_add(args):
session = DBConn().session()
component = Component()
for key, value in six.iteritems(attributes):
for key, value in attributes.items():
setattr(component, key, value)
session.add(component)
......@@ -306,7 +307,7 @@ def component_add(args):
session.commit()
def component_rm(name):
def component_rm(name: str) -> None:
session = DBConn().session()
component = get_component(name, session)
session.delete(component)
......@@ -318,7 +319,7 @@ def component_rm(name):
session.commit()
def component_rename(oldname, newname):
def component_rename(oldname: str, newname: str) -> None:
session = DBConn().session()
component = get_component(oldname, session)
component.component_name = newname
......@@ -368,21 +369,15 @@ def __suite_show(d, args):
print(su.details())
def __suite_add(d, args, addallarches=False):
def __suite_add(d, args, addallarches=False) -> None:
die_arglen(args, 4, "E: adding a suite requires at least a name and a version")
suite_name = args[2].lower()
version = args[3]
rest = args[3:]
kvpairs = __suite_config_set_confing_args_as_dict(args[4:])
if len(version) == 0:
version = None
def get_field(field):
for varval in args:
if varval.startswith(field + '='):
return varval.split('=')[1]
return None
print("Adding suite %s" % suite_name)
if not dryrun:
try:
......@@ -391,19 +386,23 @@ def __suite_add(d, args, addallarches=False):
suite.suite_name = suite_name
suite.overridecodename = None
suite.version = version or None
suite.label = get_field('label')
suite.description = get_field('description')
suite.origin = get_field('origin')
suite.codename = get_field('codename')
signingkey = get_field('signingkey')
# Most configurations will be handled by
# __suite_config_internal_set. However, a few are managed
# manually here because __suite_config_internal_set cannot
# handle them. Either because they are create-only or
# because suite-add handled them different (historically)
suite.codename = kvpairs.pop('codename', None)
signingkey = kvpairs.pop('signingkey', None)
if signingkey is not None:
suite.signingkeys = [signingkey.upper()]
archive_name = get_field('archive')
archive_name = kvpairs.pop('archive', None)
if archive_name is not None:
suite.archive = get_archive(archive_name, s)
else:
suite.archive = s.query(Archive).filter(~Archive.archive_name.in_(['build-queues', 'new', 'policy'])).one()
suite.srcformats = s.query(SrcFormat).all()
__suite_config_internal_set(suite, suite_name, kvpairs,
print_config_set=False)
s.add(suite)
s.flush()
except IntegrityError as e:
......@@ -496,8 +495,7 @@ def __suite_add_build_queue(d, args):
session.commit()
def suite(command):
args = [str(x) for x in command]
def suite(args):
Cnf = utils.get_conf()
d = DBConn()
......@@ -604,8 +602,7 @@ def __suite_architecture_rm(d, args):
print("Removed suite-architecture entry for %s, %s" % (args[2].lower(), args[3].lower()))
def suite_architecture(command):
args = [str(x) for x in command]
def suite_architecture(args):
Cnf = utils.get_conf()
d = DBConn()
......@@ -708,8 +705,7 @@ def __suite_component_rm(d, args):
print("Removed suite-component entry for %s, %s" % (args[2].lower(), args[3].lower()))
def suite_component(command):
args = [str(x) for x in command]
def suite_component(args):
Cnf = utils.get_conf()
d = DBConn()
......@@ -742,7 +738,11 @@ SUITE_CONFIG_READ_ONLY = object()
SUITE_CONFIG_WRITABLE_ONLY_VIA_JSON = object()
SuiteConfigSerializer = collections.namedtuple('SuiteConfigSerializer', ['db_name', 'serialize', 'deserialize'])
@dataclass
class SuiteConfigSerializer:
db_name: str
serialize: Callable[[Any], str]
deserialize: Optional[Callable[[str], Any]]
def _serialize_suite(x):
......@@ -811,6 +811,7 @@ ALLOWED_SUITE_CONFIGS = {
'changelog': str,
'changelog_url': str,
'checksums': SUITE_CONFIG_WRITABLE_ONLY_VIA_JSON,
'close_bugs': utils.parse_boolean_from_user,
'codename': SUITE_CONFIG_READ_ONLY,
'debugsuite': str,
'description': str,
......@@ -818,6 +819,7 @@ ALLOWED_SUITE_CONFIGS = {
'indices_compression': SUITE_CONFIG_WRITABLE_ONLY_VIA_JSON,
'label': str,
'mail_whitelist': str,
'merged_pdiffs': utils.parse_boolean_from_user,
'new_queue': str,
'notautomatic': utils.parse_boolean_from_user,
'origin': str,
......@@ -827,6 +829,9 @@ ALLOWED_SUITE_CONFIGS = {
'overridesuite': str,
'policy_queue': str,
'priority': int,
'separate_contents_architecture_all': utils.parse_boolean_from_user,
# We do not support separate Packages-all, so do not let people set it.
'separate_packages_architecture_all': SUITE_CONFIG_READ_ONLY,
'signingkeys': SUITE_CONFIG_WRITABLE_ONLY_VIA_JSON,
'suite_name': SUITE_CONFIG_READ_ONLY,
'untouchable': utils.parse_boolean_from_user,
......@@ -877,18 +882,42 @@ def __suite_config_set(d, args):
session = d.session()
suite_name = args[2]
suite = get_suite_or_die(suite_name, session)
for arg in args[3:]:
args_as_kvpairs = __suite_config_set_confing_args_as_dict(args[3:])
__suite_config_internal_set(suite, suite_name, args_as_kvpairs,
print_config_set=True
)
if dryrun:
session.rollback()
print()
print("This was a dryrun; changes have been rolled back")
else:
session.commit()
def __suite_config_set_confing_args_as_dict(args):
# Use OrderedDict to preserve order (makes "dak admin suite-config set ..."
# less confusing when things are processed in the input order)
kvpairs = collections.OrderedDict()
for arg in args:
if '=' not in arg:
die("Missing value for configuration %s: Use key=value format" % arg)
conf_name, new_value_str = arg.split('=', 1)
kvpairs[conf_name] = new_value_str
return kvpairs
def __suite_config_internal_set(suite, suite_name, kvpairs, print_config_set=True):
for kvpair in kvpairs.items():
conf_name, new_value_str = kvpair
cli_parser = ALLOWED_SUITE_CONFIGS.get(conf_name)
if cli_parser is None:
die("Unknown (or unsupported) suite configuration variable")
if cli_parser in (SUITE_CONFIG_READ_ONLY, SUITE_CONFIG_WRITABLE_ONLY_VIA_JSON):
if cli_parser == SUITE_CONFIG_WRITABLE_ONLY_VIA_JSON:
warn('''Cannot parse value for %s - use echo '{"%s": <...>}' | dak suite-config set-json %s instead''' %
(conf_name, conf_name, suite_name))
die("Cannot change %s from the command line" % arg)
msg = "Cannot parse value for %s" \
''' - set via echo '{"%s": <...>}' | dak suite-config set-json %s instead'''
warn(msg % (conf_name, conf_name, suite_name))
die("Cannot change %s from the command line" % conf_name)
try:
new_value = cli_parser(new_value_str)
except (RuntimeError, ValueError, TypeError) as e:
......@@ -899,13 +928,8 @@ def __suite_config_set(d, args):
except (RuntimeError, ValueError, TypeError) as e:
warn("Could not set new value for %s (given: %s)" % (conf_name, new_value))
raise e
print("%s=%s" % (conf_name, _get_suite_value(suite, conf_name)))
if dryrun:
session.rollback()
print()
print("This was a dryrun; changes have been rolled back")
else:
session.commit()
if print_config_set:
print("%s=%s" % (conf_name, _get_suite_value(suite, conf_name)))
def __suite_config_set_json(d, args):
......@@ -957,7 +981,7 @@ def __suite_config_list(d, args, json_format=False):
else:
if json_format:
die("E: suite-config list-json requires a suite name!")
print("Valid suite-config options managable by this command:")
print("Valid suite-config options manageable by this command:")
print()
values = {}
......@@ -980,8 +1004,7 @@ def __suite_config_list(d, args, json_format=False):
print(json.dumps(values, indent=2, sort_keys=True))
def suite_config(command):
args = [six.ensure_text(x) for x in command]
def suite_config(args):
Cnf = utils.get_conf()
d = DBConn()
......@@ -1032,7 +1055,7 @@ def archive_add(args):
archive_name=name,
path=path,
description=description,
)
)
for option in args[3:]:
(key, value) = option.split('=')
......@@ -1041,7 +1064,7 @@ def archive_add(args):
session = DBConn().session()
archive = Archive()
for key, value in six.iteritems(attributes):
for key, value in attributes.items():
setattr(archive, key, value)
session.add(archive)
......@@ -1138,8 +1161,7 @@ def __version_check_rm(d, suite_name, check, reference_name):
print("W: version-check not found.")
def version_check(command):
args = [str(x) for x in command]
def version_check(args):
Cnf = utils.get_conf()
d = DBConn()
......@@ -1170,8 +1192,7 @@ dispatch['v-c'] = version_check
################################################################################
def show_config(command):
args = [str(x) for x in command]
def show_config(args):
cnf = utils.get_conf()
die_arglen(args, 2, "E: config needs at least a command")
......@@ -1227,8 +1248,7 @@ dispatch['c'] = show_config
################################################################################
def show_keyring(command):
args = [str(x) for x in command]
def show_keyring(args):
cnf = utils.get_conf()
die_arglen(args, 2, "E: keyring needs at least a command")
......@@ -1386,7 +1406,7 @@ def main():
if options["Dry-Run"]:
dryrun = True
subcommand = str(arguments[0])
subcommand = arguments[0]
if subcommand in dispatch:
dispatch[subcommand](arguments)
......
#!/usr/bin/env python
#! /usr/bin/env python3
# vim:set et ts=4 sw=4:
""" De-duplicates files in the pool directory
......@@ -23,8 +23,6 @@
################################################################################
from __future__ import print_function
import apt_pkg
import errno
import os
......
#!/usr/bin/env python
#! /usr/bin/env python3
"""
Check for obsolete binary packages
......@@ -33,14 +33,12 @@ Check for obsolete binary packages
################################################################################
from __future__ import print_function
import sqlalchemy.sql as sql
import six
import sys
import apt_pkg
from itertools import chain, product
from collections import defaultdict
from collections.abc import Iterable
from daklib.config import Config
from daklib.dbconn import *
......@@ -71,14 +69,11 @@ Automatic removal of common kinds of cruft
################################################################################
def compute_sourceless_groups(suite_id, session):
def compute_sourceless_groups(suite_id: int, session):
"""Find binaries without a source
@type suite_id: int
@param suite_id: The id of the suite denoted by suite_name
@type session: SQLA Session
@param session: The database session in use
:param suite_id: The id of the suite denoted by suite_name
:param session: The database session in use
"""""
rows = query_without_source(suite_id, session)
message = '[auto-cruft] no longer built from source, no reverse dependencies'
......@@ -100,17 +95,12 @@ def compute_sourceless_groups(suite_id, session):
yield group_info
def compute_nbs_groups(suite_id, suite_name, session):
def compute_nbs_groups(suite_id: int, suite_name: str, session):
"""Find binaries no longer built
@type suite_id: int
@param suite_id: The id of the suite denoted by suite_name
@type suite_name: string
@param suite_name: The name of the suite to remove from
@type session: SQLA Session
@param session: The database session in use
:param suite_id: The id of the suite denoted by suite_name
:param suite_name: The name of the suite to remove from
:param session: The database session in use
"""""
rows = queryNBS(suite_id, session)
arch2ids = dict((a.arch_string, a.arch_id) for a in get_suite_architectures(suite_name))
......@@ -159,19 +149,14 @@ def dedup(*args):
yield value
def merge_group(groupA, groupB):
def merge_group(groupA: dict, groupB: dict) -> dict:
"""Merges two removal groups into one
Note that some values are taken entirely from groupA (e.g. name and message)
@type groupA: dict
@param groupA: A removal group
@type groupB: dict
@param groupB: Another removal group
@rtype: dict
@returns: A merged group
:param groupA: A removal group
:param groupB: Another removal group
:return: A merged group
"""
pkg_list = sorted(dedup(groupA["packages"], groupB["packages"]))
arch_list = sorted(dedup(groupA["architectures"], groupB["architectures"]))
......@@ -196,23 +181,14 @@ def merge_group(groupA, groupB):
return merged_group
def auto_decruft_suite(suite_name, suite_id, session, dryrun, debug):
def auto_decruft_suite(suite_name: str, suite_id: int, session, dryrun: bool, debug: bool):
"""Run the auto-decrufter on a given suite
@type suite_name: string
@param suite_name: The name of the suite to remove from
@type suite_id: int
@param suite_id: The id of the suite denoted by suite_name
@type session: SQLA Session
@param session: The database session in use
@type dryrun: bool
@param dryrun: If True, just print the actions rather than actually doing them
@type debug: bool
@param debug: If True, print some extra information
:param suite_name: The name of the suite to remove from
:param suite_id: The id of the suite denoted by suite_name
:param session: The database session in use
:param dryrun: If True, just print the actions rather than actually doing them
:param debug: If True, print some extra information
"""
all_architectures = [a.arch_string for a in get_suite_architectures(suite_name)]
pkg_arch2groups = defaultdict(set)
......@@ -244,7 +220,7 @@ def auto_decruft_suite(suite_name, suite_id, session, dryrun, debug):
for group_name in group_order:
removal_request = groups[group_name]["removal_request"]
full_removal_request.extend(six.iteritems(removal_request))
full_removal_request.extend(removal_request.items())
if not groups:
if debug:
......@@ -311,13 +287,13 @@ def auto_decruft_suite(suite_name, suite_id, session, dryrun, debug):
return
if debug:
print("N: Now considering to remove: %s" % str(", ".join(sorted(six.iterkeys(groups)))))
print("N: Now considering to remove: %s" % str(", ".join(sorted(groups.keys()))))
# Rebuild the removal request with the remaining groups and off
# we go to (not) break the world once more time
full_removal_request = []
for group_info in six.itervalues(groups):
full_removal_request.extend(six.iteritems(group_info["removal_request"]))
for group_info in groups.values():
full_removal_request.extend(group_info["removal_request"].items())
breakage = rdc.check_reverse_depends(full_removal_request)
if debug:
......@@ -343,23 +319,16 @@ def auto_decruft_suite(suite_name, suite_id, session, dryrun, debug):
print("Note: The removals may be interdependent. A non-breaking result may require the execution of all")
print("of the removals")
else:
remove_groups(six.itervalues(groups), suite_id, suite_name, session)
remove_groups(groups.values(), suite_id, suite_name, session)
def sources2removals(source_list, suite_id, session):
def sources2removals(source_list: Iterable[str], suite_id: int, session) -> list:
"""Compute removals items given a list of names of source packages
@type source_list: list
@param source_list: A list of names of source packages
@type suite_id: int
@param suite_id: The id of the suite from which these sources should be removed
@type session: SQLA Session
@param session: The database session in use
@rtype: list
@return: A list of items to be removed to remove all sources and their binaries from the given suite
:param source_list: A list of names of source packages
:param suite_id: The id of the suite from which these sources should be removed
:param session: The database session in use
:return: A list of items to be removed to remove all sources and their binaries from the given suite
"""
to_remove = []
params = {"suite_id": suite_id, "sources": tuple(source_list)}
......@@ -380,29 +349,16 @@ def sources2removals(source_list, suite_id, session):
return to_remove
def decruft_newer_version_in(othersuite, suite_name, suite_id, rm_msg, session, dryrun, decruft_equal_versions):
def decruft_newer_version_in(othersuite: str, suite_name: str, suite_id: int, rm_msg: str, session, dryrun: bool, decruft_equal_versions: bool) -> None:
"""Compute removals items given a list of names of source packages
@type othersuite: str
@param othersuite: The name of the suite to compare with (e.g. "unstable" for "NVIU")
@type suite: str
@param suite: The name of the suite from which to do removals (e.g. "experimental" for "NVIU")
@type suite_id: int
@param suite_id: The id of the suite from which these sources should be removed
@type rm_msg: str
@param rm_msg: The removal message (or tag, e.g. "NVIU")
@type session: SQLA Session
@param session: The database session in use
@type dryrun: bool
@param dryrun: If True, just print the actions rather than actually doing them
@type decruft_equal_versions: bool
@param decruft_equal_versions: If True, use >= instead of > for finding decruftable packages.
:param othersuite: The name of the suite to compare with (e.g. "unstable" for "NVIU")
:param suite: The name of the suite from which to do removals (e.g. "experimental" for "NVIU")
:param suite_id: The id of the suite from which these sources should be removed
:param rm_msg: The removal message (or tag, e.g. "NVIU")
:param session: The database session in use
:param dryrun: If True, just print the actions rather than actually doing them
:param decruft_equal_versions: If True, use >= instead of > for finding decruftable packages.
"""
nvi_list = [x[0] for x in newer_version(othersuite, suite_name, session, include_equal=decruft_equal_versions)]
if nvi_list:
......
#!/usr/bin/python
#! /usr/bin/env python3
"""
bts -- manage bugs filed against ftp.debian.org
......@@ -27,8 +27,6 @@ bts -- manage bugs filed against ftp.debian.org
################################################################################
################################################################################
from __future__ import print_function
import sys
import re
import logging
......@@ -67,10 +65,11 @@ OPTIONS
arguments = [('s', 'simulate', 'BtsCategorize::Options::Simulate'),
('v', 'verbose', 'BtsCategorize::Options::Verbose'),
('q', 'quiet', 'BtsCategorize::Options::Quiet'),
('h', 'help', 'BtsCategorize::Options::Help')]
('h', 'help', 'BtsCategorize::Options::Help'),
('o', 'option', '', 'ArbItem')]
class BugClassifier(object):
class BugClassifier:
"""
classify bugs using usertags based on the bug subject lines
......@@ -102,7 +101,7 @@ class BugClassifier(object):
for tags in tagged_bugs.keys():
tagged_bugs_ftp += tagged_bugs[tags]
return [bug for bug in bts.get_status(bts.get_bugs("package", "ftp.debian.org"))
return [bug for bug in bts.get_status(bts.get_bugs(package="ftp.debian.org"))
if bug.pending == 'pending' and bug.bug_num not in tagged_bugs_ftp]
def classify_bug(self, bug):
......
#!/usr/bin/env python
#! /usr/bin/env python3
""" Various different sanity checks
......@@ -30,8 +30,7 @@
################################################################################
from __future__ import print_function
import errno
import os
import stat
import sys
......@@ -81,16 +80,13 @@ The following MODEs are available:
################################################################################
def process_dir(unused, dirname, filenames):
def process_dir(unused, dirname: str, filenames: dict) -> None:
"""
Process a directory and output every files name which is not listed already
in the C{filenames} or global C{excluded} dictionaries.
@type dirname: string
@param dirname: the directory to look at
in the `filenames` or global :data:`excluded` dictionaries.
@type filenames: dict
@param filenames: Known filenames to ignore
:param dirname: the directory to look at
:param filenames: Known filenames to ignore
"""
global waste, db_files, excluded
......@@ -182,14 +178,14 @@ def check_dscs():
for src in DBConn().session().query(DBSource).order_by(DBSource.source, DBSource.version):
f = src.poolfile.fullpath
try:
utils.parse_changes(f, signing_rules=1, dsc_file=1)
utils.parse_changes(f, signing_rules=1, dsc_file=True)
except InvalidDscError:
utils.warn("syntax error in .dsc file %s" % f)
count += 1
except UnicodeDecodeError:
utils.warn("found invalid dsc file (%s), not properly utf-8 encoded" % f)
count += 1
except IOError as e:
except OSError as e:
if e.errno == errno.ENOENT:
utils.warn("missing dsc file (%s)" % f)
count += 1
......@@ -375,7 +371,7 @@ def check_files_in_dsc():
try:
# NB: don't enforce .dsc syntax
dsc = utils.parse_changes(filename, dsc_file=1)
dsc = utils.parse_changes(filename, dsc_file=True)
except:
utils.fubar("error parsing .dsc file '%s'." % (filename))
......@@ -421,7 +417,6 @@ def validate_sources(suite, component):
filename = os.path.normpath(filename)
src = utils.clean_symlink(pool_filename, filename, Cnf["Dir::Root"])
print("Symlinking: %s -> %s" % (filename, src))
#os.symlink(src, filename)
########################################
......@@ -480,12 +475,12 @@ def check_files_not_symlinks():
################################################################################
def chk_bd_process_dir(unused, dirname, filenames):
def chk_bd_process_dir(dirname, filenames):
for name in filenames:
if not name.endswith(".dsc"):
continue
filename = os.path.abspath(dirname + '/' + name)
dsc = utils.parse_changes(filename, dsc_file=1)
dsc = utils.parse_changes(filename, dsc_file=True)
for field_name in ["build-depends", "build-depends-indep"]:
field = dsc.get(field_name)
if field:
......@@ -501,7 +496,8 @@ def chk_bd_process_dir(unused, dirname, filenames):
def check_build_depends():
""" Validate build-dependencies of .dsc files in the archive """
cnf = Config()
os.path.walk(cnf["Dir::Root"], chk_bd_process_dir, None)
for dirpath, dirnames, filenames in os.walk(cnf["Dir::Root"]):
chk_bd_process_dir(dirpath, filenames)
################################################################################
......
#!/usr/bin/env python
#! /usr/bin/env python3
""" Cruft checker and hole filler for overrides
......@@ -46,7 +46,7 @@
# some degree
# * consistency checks like:
# - section=debian-installer only for udeb and # dsc
# - priority=source iff dsc
# - priority=optional if dsc
# - (suite, package, 'dsc') is unique,
# - just as (suite, package, (u)deb) (yes, across components!)
# - sections match their component (each component has an own set of sections,
......@@ -54,8 +54,6 @@
################################################################################
from __future__ import print_function
import sys
import apt_pkg
......@@ -113,7 +111,7 @@ def process(osuite, affected_suites, originosuite, component, otype, session):
type_id = ot.overridetype_id
dsc_type_id = get_override_type("dsc", session).overridetype_id
source_priority_id = get_priority("source", session).priority_id
source_priority_id = get_priority("optional", session).priority_id
if otype == "deb" or otype == "udeb":
packages = {}
......@@ -124,8 +122,8 @@ SELECT b.package
JOIN bin_associations ba ON b.id = ba.bin
JOIN suite ON ba.suite = suite.id
JOIN files_archive_map af ON b.file = af.file_id AND suite.archive_id = af.archive_id
WHERE b.type = :otype AND ba.suite IN (%s) AND af.component_id = :component_id
""" % (",".join([str(i) for i in affected_suites])), {'otype': otype, 'component_id': component_id})
WHERE b.type = :otype AND ba.suite IN :affected_suites AND af.component_id = :component_id
""", {'otype': otype, 'affected_suites': tuple(affected_suites), 'component_id': component_id})
for i in q.fetchall():
packages[i[0]] = 0
......@@ -135,8 +133,8 @@ SELECT s.source FROM source s
JOIN src_associations sa ON s.id = sa.source
JOIN suite ON sa.suite = suite.id
JOIN files_archive_map af ON s.file = af.file_id AND suite.archive_id = af.archive_id
WHERE sa.suite IN (%s) AND af.component_id = :component_id
""" % (",".join([str(i) for i in affected_suites])), {'component_id': component_id})
WHERE sa.suite IN :affected_suites AND af.component_id = :component_id
""", {'affected_suites': tuple(affected_suites), 'component_id': component_id})
for i in q.fetchall():
src_packages[i[0]] = 0
......
#!/usr/bin/env python
#! /usr/bin/env python3
""" Clean incoming of old unused files """
# Copyright (C) 2000, 2001, 2002, 2006 James Troup <james@nocrew.org>
......@@ -33,8 +33,6 @@
################################################################################
from __future__ import print_function
import os
import os.path
import stat
......@@ -176,8 +174,8 @@ def flush_orphans():
for f in files.keys():
if f.endswith(".dsc"):
try:
dsc = utils.parse_changes(f, dsc_file=1)
dsc_files = utils.build_file_list(dsc, is_a_dsc=1)
dsc = utils.parse_changes(f, dsc_file=True)
dsc_files = utils.build_file_list(dsc, is_a_dsc=True)
except:
utils.warn("error processing '%s'; skipping it. [Got %s]" % (f, sys.exc_info()[0]))
continue
......
#!/usr/bin/env python
#! /usr/bin/env python3
""" Cleans up unassociated binary and source packages
......@@ -34,8 +34,6 @@
################################################################################
from __future__ import print_function
import errno
import os
import sqlalchemy.sql as sql
......@@ -288,37 +286,36 @@ def clean(now_date, archives, max_delete, session):
for af in old_files:
filename = af.path
if not os.path.exists(filename):
Logger.log(["database referred to non-existing file", af.path])
try:
st = os.lstat(filename)
except FileNotFoundError:
Logger.log(["database referred to non-existing file", filename])
session.delete(af)
continue
Logger.log(["delete archive file", filename])
if os.path.isfile(filename):
if os.path.islink(filename):
count += 1
Logger.log(["delete symlink", filename])
if not Options["No-Action"]:
os.unlink(filename)
else:
size += os.stat(filename)[stat.ST_SIZE]
count += 1
dest_filename = dest + '/' + os.path.basename(filename)
# If the destination file exists; try to find another filename to use
if os.path.lexists(dest_filename):
dest_filename = utils.find_next_free(dest_filename)
if stat.S_ISLNK(st.st_mode):
count += 1
Logger.log(["delete symlink", filename])
if not Options["No-Action"]:
os.unlink(filename)
session.delete(af)
elif stat.S_ISREG(st.st_mode):
size += st.st_size
count += 1
if not Options["No-Action"]:
if af.archive.use_morgue:
Logger.log(["move to morgue", filename, dest_filename])
utils.move(filename, dest_filename)
else:
Logger.log(["removed file", filename])
os.unlink(filename)
dest_filename = dest + '/' + os.path.basename(filename)
# If the destination file exists; try to find another filename to use
if os.path.lexists(dest_filename):
dest_filename = utils.find_next_free(dest_filename)
if not Options["No-Action"]:
if af.archive.use_morgue:
Logger.log(["move to morgue", filename, dest_filename])
utils.move(filename, dest_filename)
else:
Logger.log(["removed file", filename])
os.unlink(filename)
session.delete(af)
session.commit()
else:
utils.fubar("%s is neither symlink nor file?!" % (filename))
......
#!/usr/bin/env python
#! /usr/bin/env python3
"""
Create all the contents files
......@@ -35,8 +35,6 @@ Create all the contents files
################################################################################
from __future__ import print_function
import sys
import apt_pkg
......
#!/usr/bin/env python
#! /usr/bin/env python3
""" Bulk manipulation of the overrides """
# Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup <james@nocrew.org>
......@@ -49,8 +49,6 @@
################################################################################
from __future__ import print_function
import sys
import time
import apt_pkg
......@@ -154,7 +152,7 @@ def process_file(file, suite, component, otype, mode, action, session):
utils.warn("'%s' does not break into 'package section [maintainer-override]'." % (line))
c_error += 1
continue
priority = "extra"
priority = "optional"
else: # binary or udeb
split_line = line.split(None, 3)
if len(split_line) == 3:
......
#!/usr/bin/env python
#! /usr/bin/env python3
""" Manipulate suite tags """
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org>
......@@ -41,13 +41,10 @@
#######################################################################################
from __future__ import print_function
import sys
import apt_pkg
import functools
import os
import six
from daklib.archive import ArchiveTransaction
from daklib.config import Config
......@@ -131,16 +128,19 @@ def britney_changelog(packages, suite, session):
if apt_pkg.version_compare(current[p], old[p]) > 0:
new[p] = [current[p], old[p]]
else:
new[p] = [current[p], 0]
new[p] = [current[p], None]
params = {}
query = "SELECT source, changelog FROM changelogs WHERE"
for p in new.keys():
query += " source = '%s' AND version > '%s' AND version <= '%s'" \
% (p, new[p][1], new[p][0])
for n, p in enumerate(new.keys()):
query += f" source = :source_{n} AND (:version1_{n} IS NULL OR version > :version1_{n}) AND version <= :version2_{n}"
query += " AND architecture LIKE '%source%' AND distribution in \
('unstable', 'experimental', 'testing-proposed-updates') OR"
params[f'source_{n}'] = p
params[f'version1_{n}'] = new[p][1]
params[f'version2_{n}'] = new[p][0]
query += " False ORDER BY source, version DESC"
q = session.execute(query)
q = session.execute(query, params)
pu = None
with open(brit_file, 'w') as brit:
......@@ -162,36 +162,42 @@ def britney_changelog(packages, suite, session):
#######################################################################################
def version_checks(package, architecture, target_suite, new_version, session, force=False):
if architecture == "source":
suite_version_list = get_suite_version_by_source(package, session)
else:
suite_version_list = get_suite_version_by_package(package, architecture, session)
must_be_newer_than = [vc.reference.suite_name for vc in get_version_checks(target_suite, "MustBeNewerThan")]
must_be_older_than = [vc.reference.suite_name for vc in get_version_checks(target_suite, "MustBeOlderThan")]
# Must be newer than an existing version in target_suite
if target_suite not in must_be_newer_than:
must_be_newer_than.append(target_suite)
violations = False
for suite, version in suite_version_list:
cmp = apt_pkg.version_compare(new_version, version)
# for control-suite we allow equal version (for uploads, we don't)
if suite in must_be_newer_than and cmp < 0:
utils.warn("%s (%s): version check violated: %s targeted at %s is *not* newer than %s in %s" % (package, architecture, new_version, target_suite, version, suite))
violations = True
if suite in must_be_older_than and cmp > 0:
utils.warn("%s (%s): version check violated: %s targeted at %s is *not* older than %s in %s" % (package, architecture, new_version, target_suite, version, suite))
violations = True
if violations:
if force:
utils.warn("Continuing anyway (forced)...")
class VersionCheck:
def __init__(self, target_suite: str, force: bool, session):
self.target_suite = target_suite
self.force = force
self.session = session
self.must_be_newer_than = [vc.reference.suite_name for vc in get_version_checks(target_suite, "MustBeNewerThan", session)]
self.must_be_older_than = [vc.reference.suite_name for vc in get_version_checks(target_suite, "MustBeOlderThan", session)]
# Must be newer than an existing version in target_suite
if target_suite not in self.must_be_newer_than:
self.must_be_newer_than.append(target_suite)
def __call__(self, package: str, architecture: str, new_version: str):
if architecture == "source":
suite_version_list = get_suite_version_by_source(package, self.session)
else:
utils.fubar("Aborting. Version checks violated and not forced.")
suite_version_list = get_suite_version_by_package(package, architecture, self.session)
violations = False
for suite, version in suite_version_list:
cmp = apt_pkg.version_compare(new_version, version)
# for control-suite we allow equal version (for uploads, we don't)
if suite in self.must_be_newer_than and cmp < 0:
utils.warn("%s (%s): version check violated: %s targeted at %s is *not* newer than %s in %s" % (package, architecture, new_version, self.target_suite, version, suite))
violations = True
if suite in self.must_be_older_than and cmp > 0:
utils.warn("%s (%s): version check violated: %s targeted at %s is *not* older than %s in %s" % (package, architecture, new_version, self.target_suite, version, suite))
violations = True
if violations:
if self.force:
utils.warn("Continuing anyway (forced)...")
else:
utils.fubar("Aborting. Version checks violated and not forced.")
#######################################################################################
......@@ -308,11 +314,13 @@ def set_suite(file, suite, transaction, britney=False, force=False):
continue
desired.add(tuple(split_line))
version_check = VersionCheck(suite.suite_name, force, session)
# Check to see which packages need added and add them
for key in sorted(desired, key=functools.cmp_to_key(cmp_package_version)):
if key not in current:
(package, version, architecture) = key
version_checks(package, architecture, suite.suite_name, version, session, force)
version_check(package, architecture, version)
pkg = get_pkg(package, version, architecture, session)
if pkg is None:
continue
......@@ -323,7 +331,7 @@ def set_suite(file, suite, transaction, britney=False, force=False):
check_propups(pkg, psuites_current, propups_needed)
# Check to see which packages need removed and remove them
for key, pkid in six.iteritems(current):
for key, pkid in current.items():
if key not in desired:
(package, version, architecture) = key
if architecture == "source":
......@@ -369,6 +377,8 @@ def process_file(file, suite, action, transaction, britney=False, force=False):
request.sort(key=functools.cmp_to_key(cmp_package_version))
version_check = VersionCheck(suite.suite_name, force, session)
for package, version, architecture in request:
pkg = get_pkg(package, version, architecture, session)
if pkg is None:
......@@ -382,7 +392,7 @@ def process_file(file, suite, action, transaction, britney=False, force=False):
# Do version checks when adding packages
if action == "add":
version_checks(package, architecture, suite.suite_name, version, session, force)
version_check(package, architecture, version)
if architecture == "source":
# Find the existing association ID, if any
......@@ -517,14 +527,14 @@ def main():
if action == "list":
session = DBConn().session()
suite = session.query(Suite).filter_by(suite_name=suite_name).one()
suite = get_suite(suite_name, session)
get_list(suite, session)
else:
Logger = daklog.Logger("control-suite")
with ArchiveTransaction() as transaction:
session = transaction.session
suite = session.query(Suite).filter_by(suite_name=suite_name).one()
suite = get_suite(suite_name, session)
if action == "set" and not suite.allowcsset:
if force:
......
#!/usr/bin/env python
#! /usr/bin/env python3
""" Copies the installer from one suite to another """
# Copyright (C) 2011 Torsten Werner <twerner@debian.org>
......@@ -19,15 +19,13 @@
################################################################################
from __future__ import print_function
from daklib.config import Config
import daklib.daksubprocess
import apt_pkg
import glob
import os.path
import re
import subprocess
import sys
......@@ -49,7 +47,7 @@ def main():
('s', "source", "Copy-Installer::Options::Source", "HasArg"),
('d', "destination", "Copy-Installer::Options::Destination", "HasArg"),
('n', "no-action", "Copy-Installer::Options::No-Action"),
]
]
for option in ["help", "source", "destination", "no-action"]:
key = "Copy-Installer::Options::%s" % option
if key not in cnf:
......@@ -105,7 +103,7 @@ class InstallerCopier:
def check_dir(self, dir, message):
if not os.path.isdir(dir):
raise IOError("%s (%s)" % (message, dir))
raise Exception("%s (%s)" % (message, dir))
def check_architecture(self, arch_dir):
architecture = re.sub('.*?/installer-(.*?)/.*', r'\1', arch_dir)
......@@ -138,7 +136,7 @@ Architectures to skip: %(skip_arch_list)s""" % {
if not os.path.exists(dest):
os.makedirs(dest)
for source, dest in self.trees_to_copy:
daklib.daksubprocess.check_call(['cp', '-al', source, dest])
subprocess.check_call(['cp', '-al', source, dest])
for source, dest in self.symlinks_to_create:
if os.path.lexists(dest):
os.unlink(dest)
......
此差异已折叠。
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Wrapper to launch dak functionality
......@@ -33,8 +33,6 @@ G{importgraph}
################################################################################
from __future__ import print_function
import importlib
import os
import sys
......@@ -162,7 +160,9 @@ def init():
"Copies the installer from one suite to another"),
("external-overrides",
"Modify external overrides"),
]
("write-sections",
"Write out section descriptions"),
]
return functionality
################################################################################
......@@ -187,7 +187,7 @@ def main():
try:
logger = Logger('dak top-level', print_starting=False)
except IOError:
except OSError:
logger = None
functionality = init()
......
"""
Database update scripts for usage with B{dak update-db}
Database update scripts for usage with ``dak update-db``
@contact: Debian FTP Master <ftpmaster@debian.org>
@copyright: 2008 Michael Casadevall <mcasadevall@debian.org>
@license: GNU General Public License version 2 or later
Update scripts have to C{import psycopg2} and
C{from daklib.dak_exceptions import DBUpdateError}.
Update scripts have to ``import psycopg2`` and
``from daklib.dak_exceptions import DBUpdateError``.
There has to be B{at least} the function C{do_update(self)} to be
There has to be **at least** the function ``do_update(self)`` to be
defined. It should take all neccessary steps to update the
database. If the update fails the changes have to be rolled back and the
C{DBUpdateError} exception raised to properly halt the execution of any
other update.
:exc:`~daklib.dak_exceptions.DBUpdateError` exception raised to properly
halt the execution of any other update.
Example::
def do_update(self):
print "Doing something"
print("Doing something")
try:
c = self.db.cursor()
c.execute("SOME SQL STATEMENT")
self.db.commit()
except psycopg2.ProgrammingError, msg:
except psycopg2.ProgrammingError as msg:
self.db.rollback()
raise DBUpdateError, "Unable to do whatever, rollback issued. Error message : %s" % (str(msg))
raise DBUpdateError(f"Unable to do whatever, rollback issued. Error message: {msg}")
This function can do whatever it wants and use everything from dak and
daklib.
......
#!/usr/bin/env python
# coding=utf8
"""
Add a component - suite mapping to only expose certain components in certain suites
......@@ -26,8 +23,6 @@ Add a component - suite mapping to only expose certain components in certain sui
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Add column to store compression type of indices
......@@ -25,8 +22,6 @@ Add column to store compression type of indices
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
......
#!/usr/bin/env python
# coding=utf8
"""
src_associations_full view, now also including sources for all binaries
......@@ -25,8 +22,6 @@ src_associations_full view, now also including sources for all binaries
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Drop unique .changes name requirement and allow ftpteam to forget seen files
......@@ -25,8 +22,6 @@ Drop unique .changes name requirement and allow ftpteam to forget seen files
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Drop created and modified columns from bin_contents and src_contents
......@@ -25,8 +22,6 @@ Drop created and modified columns from bin_contents and src_contents
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Add a new release_suite name which we use in generate_releases
......@@ -25,8 +22,6 @@ Add a new release_suite name which we use in generate_releases
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
new views binary_component, source_component and package_list
......@@ -25,8 +22,6 @@ new views binary_component, source_component and package_list
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Do not include long description in Packages index by default
......@@ -25,8 +22,6 @@ Do not include long description in Packages index by default
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Add codename to package_list view
......@@ -25,8 +22,6 @@ Add codename to package_list view
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Change indices for {src,bin}_contents
......@@ -25,8 +22,6 @@ Change indices for {src,bin}_contents
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Add a debug suite field to the suite table
......@@ -25,8 +22,6 @@ Add a debug suite field to the suite table
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Make install_date in source consistant with binaries
......@@ -25,8 +22,6 @@ Make install_date in source consistant with binaries
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Add Changelogs field
......@@ -25,8 +22,6 @@ Add Changelogs field
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Add accept_{source,binary}_uploads to suite
......@@ -25,8 +22,6 @@ Add accept_{source,binary}_uploads to suite
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Add column to store checksums we want per suite (Packages/Release files)
......@@ -25,8 +22,6 @@ Add column to store checksums we want per suite (Packages/Release files)
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
......
#!/usr/bin/env python
# coding=utf8
"""
Add last_changed to suite
......@@ -25,8 +22,6 @@ Add last_changed to suite
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
......@@ -6,8 +6,6 @@ Add support for by-hash with a new table and per-suite boolean
@license: GNU General Public License version 2 or later
"""
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
......
#!/usr/bin/env python
# coding=utf8
"""list of external signature requests
@contact: Debian FTP Master <ftpmaster@debian.org>
......@@ -24,8 +21,6 @@
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""set owner tables for sequences
@contact: Debian FTP Master <ftpmaster@debian.org>
......@@ -24,8 +21,6 @@
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""remove unused database objects
@contact: Debian FTP Master <ftpmaster@debian.org>
......@@ -24,8 +21,6 @@
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""remove duplicate constraint
@contact: Debian FTP Master <ftpmaster@debian.org>
......@@ -24,8 +21,6 @@
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Update changes table to not require a value for the Binary column
......@@ -25,8 +22,6 @@ Update changes table to not require a value for the Binary column
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
......
# coding=utf8
"""
Update default settings for suites
......@@ -23,8 +22,6 @@ Update default settings for suites
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
......
"""
Add separate Contents-all support settings for suites
@contact: Debian FTP Master <ftpmaster@debian.org>
@copyright: 2020, Niels Thykier <niels@thykier.net>
@license: GNU General Public License version 2 or later
"""
# 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; either version 2 of the License, or
# (at your option) any later version.
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
################################################################################
import psycopg2
from daklib.dak_exceptions import DBUpdateError
################################################################################
def do_update(self):
"""
Update default settings for suites
"""
print(__doc__)
try:
c = self.db.cursor()
c.execute("""
ALTER TABLE suite
ADD COLUMN separate_contents_architecture_all boolean NOT NULL DEFAULT FALSE,
ADD COLUMN separate_packages_architecture_all boolean NOT NULL DEFAULT FALSE
""")
# We do not support separate Packages-all at the moment, so ensure it is
# never set at all. We still add it to the database because we can use
# it for adding basic support as well as setup some basic control
# checks for now. When we are ready to support
# separate_packages_architecture_all, then we should replace this
# check with:
#
# CHECK (NOT separate_packages_architecture_all OR separate_contents_architecture_all)
#
# This is because clients are not required to support separate Packages-all without
# Contents-all according to:
# https://wiki.debian.org/DebianRepository/Format#No-Support-for-Architecture-all
#
c.execute("""
ALTER TABLE suite
ADD CHECK (NOT separate_packages_architecture_all)
""")
c.execute("UPDATE config SET value = '123' WHERE name = 'db_revision'")
self.db.commit()
except psycopg2.ProgrammingError as msg:
self.db.rollback()
raise DBUpdateError('Unable to apply sick update 123, rollback issued. Error message : %s' % (str(msg)))
"""
Put descriptions into sections table
@contact: Debian FTP Master <ftpmaster@debian.org>
@copyright: 2020, Joerg Jaspert <joerg@debian.org>
@license: GNU General Public License version 2 or later
"""
# 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; either version 2 of the License, or
# (at your option) any later version.
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
################################################################################
import psycopg2
from daklib.dak_exceptions import DBUpdateError
################################################################################
sections = {
'admin': {'desc': 'Administration Utilities"', 'longdesc': 'Utilities to administer system resources, manage user accounts, etc.'},
'cli-mono': {'desc': 'Mono/CLI', 'longdesc': 'Everything about Mono and the Common Language Infrastructure.'},
'comm': {'desc': 'Communication Programs', 'longdesc': 'Software to use your modem in the old fashioned style.'},
'database': {'desc': 'Databases', 'longdesc': 'Database Servers and Clients.'},
'debian-installer': {'desc': 'debian-installer udeb packages', 'longdesc': 'Special packages for building customized debian-installer variants. Do not install them on a normal system!'},
'debug': {'desc': 'Debug packages', 'longdesc': 'Packages providing debugging information for executables and shared libraries.'},
'devel': {'desc': 'Development', 'longdesc': 'Development utilities, compilers, development environments, libraries, etc.'},
'doc': {'desc': 'Documentation', 'longdesc': 'FAQs, HOWTOs and other documents trying to explain everything related to Debian, and software needed to browse documentation (man, info, etc).'},
'editors': {'desc': 'Editors', 'longdesc': 'Software to edit files. Programming environments.'},
'education': {'desc': 'Education', 'longdesc': 'Software for learning and teaching'},
'electronics': {'desc': 'Electronics', 'longdesc': 'Electronics utilities.'},
'embedded': {'desc': 'Embedded software', 'longdesc': 'Software suitable for use in embedded applications.'},
'fonts': {'desc': 'Fonts', 'longdesc': 'Font packages.'},
'games': {'desc': 'Games', 'longdesc': 'Programs to spend a nice time with after all this setting up.'},
'gnome': {'desc': 'GNOME', 'longdesc': 'The GNOME desktop environment, a powerful, easy to use set of integrated applications.'},
'gnu-r': {'desc': 'GNU R', 'longdesc': 'Everything about GNU R, a statistical computation and graphics system.'},
'gnustep': {'desc': 'GNUstep', 'longdesc': 'The GNUstep environment.'},
'golang': {'desc': 'Go', 'longdesc': 'Go programming language, libraries, and development tools.'},
'graphics': {'desc': 'Graphics', 'longdesc': 'Editors, viewers, converters... Everything to become/be an artist.'},
'hamradio': {'desc': 'Ham Radio', 'longdesc': 'Software for ham radio.'},
'haskell': {'desc': 'Haskell', 'longdesc': 'Everything about Haskell.'},
'httpd': {'desc': 'Web Servers', 'longdesc': 'Web servers and their modules.'},
'interpreters': {'desc': 'Interpreters', 'longdesc': 'All kind of interpreters for interpreted languages. Macro processors.'},
'introspection': {'desc': 'Introspection', 'longdesc': 'Machine readable introspection data for use by development tools.'},
'java': {'desc': 'Java', 'longdesc': 'Everything about Java.'},
'javascript': {'desc': 'JavaScript', 'longdesc': 'JavaScript programming language, libraries, and development tools.'},
'kde': {'desc': 'KDE', 'longdesc': 'The K Desktop Environment, a powerful, easy to use set of integrated applications.'},
'kernel': {'desc': 'Kernels', 'longdesc': 'Operating System Kernels and related modules.'},
'libdevel': {'desc': 'Library development', 'longdesc': 'Libraries necessary for developers to write programs that use them.'},
'libs': {'desc': 'Libraries', 'longdesc': 'Libraries to make other programs work. They provide special features to developers.'},
'lisp': {'desc': 'Lisp', 'longdesc': 'Everything about Lisp.'},
'localization': {'desc': 'Language packs', 'longdesc': 'Localization support for big software packages.'},
'mail': {'desc': 'Mail', 'longdesc': 'Programs to route, read, and compose E-mail messages.'},
'math': {'desc': 'Mathematics', 'longdesc': 'Math software.'},
'metapackages': {'desc': 'Meta Packages', 'longdesc': 'Packages that mainly provide dependencies on other packages.'},
'misc': {'desc': 'Miscellaneous', 'longdesc': "Miscellaneous utilities that didn't fit well anywhere else."},
'net': {'desc': 'Network', 'longdesc': 'Daemons and clients to connect your system to the world.'},
'news': {'desc': 'Newsgroups', 'longdesc': 'Software to access Usenet, to set up news servers, etc.'},
'ocaml': {'desc': 'OCaml', 'longdesc': 'Everything about OCaml, an ML language implementation.'},
'oldlibs': {'desc': 'Old Libraries', 'longdesc': 'Old versions of libraries, kept for backward compatibility with old applications.'},
'otherosfs': {'desc': "Other OS's and file systems", 'longdesc': 'Software to run programs compiled for other operating systems, and to use their filesystems.'},
'perl': {'desc': 'Perl', 'longdesc': 'Everything about Perl, an interpreted scripting language.'},
'php': {'desc': 'PHP', 'longdesc': 'Everything about PHP.'},
'python': {'desc': 'Python', 'longdesc': 'Everything about Python, an interpreted, interactive object oriented language.'},
'raku': {'desc': 'Raku', 'longdesc': 'Everything about Raku, an interpreted scripting language.'},
'ruby': {'desc': 'Ruby', 'longdesc': 'Everything about Ruby, an interpreted object oriented language.'},
'rust': {'desc': 'Rust', 'longdesc': 'Rust programming language, library crates, and development tools.'},
'science': {'desc': 'Science', 'longdesc': 'Basic tools for scientific work'},
'shells': {'desc': 'Shells', 'longdesc': 'Command shells. Friendly user interfaces for beginners.'},
'sound': {'desc': 'Sound', 'longdesc': 'Utilities to deal with sound: mixers, players, recorders, CD players, etc.'},
'tasks': {'desc': 'Tasks', 'longdesc': "Packages that are used by 'tasksel', a simple interface for users who want to configure their system to perform a specific task."},
'tex': {'desc': 'TeX', 'longdesc': 'The famous typesetting software and related programs.'},
'text': {'desc': 'Text Processing', 'longdesc': 'Utilities to format and print text documents.'},
'utils': {'desc': 'Utilities', 'longdesc': 'Utilities for file/disk manipulation, backup and archive tools, system monitoring, input systems, etc.'},
'vcs': {'desc': 'Version Control Systems', 'longdesc': 'Version control systems and related utilities.'},
'video': {'desc': 'Video', 'longdesc': 'Video viewers, editors, recording, streaming.'},
'web': {'desc': 'Web Software', 'longdesc': 'Web servers, browsers, proxies, download tools etc.'},
'x11': {'desc': 'X Window System software', 'longdesc': 'X servers, libraries, window managers, terminal emulators and many related applications.'},
'xfce': {'desc': 'Xfce', 'longdesc': 'Xfce, a fast and lightweight Desktop Environment.'},
'zope': {'desc': 'Zope/Plone Framework', 'longdesc': 'Zope Application Server and Plone Content Managment System.'},
}
def do_update(self):
"""
Update default settings for suites
"""
print(__doc__)
try:
c = self.db.cursor()
c.execute("""
ALTER TABLE section
ADD COLUMN description TEXT NOT NULL DEFAULT 'Missing shortdesc',
ADD COLUMN longdesc TEXT NOT NULL DEFAULT 'Missing longdesc'
""")
for section in sections:
c.execute("UPDATE section SET description=%s, longdesc=%s WHERE section=%s", (section, sections[section]["desc"], sections[section]["longdesc"]))
c.execute("UPDATE section SET description=%s, longdesc=%s WHERE section=CONCAT('contrib/', %s)", (section, sections[section]["desc"], sections[section]["longdesc"]))
c.execute("UPDATE section SET description=%s, longdesc=%s WHERE section=CONCAT('non-free-firmware/', %s)", (section, sections[section]["desc"], sections[section]["longdesc"]))
c.execute("UPDATE section SET description=%s, longdesc=%s WHERE section=CONCAT('non-free/', %s)", (section, sections[section]["desc"], sections[section]["longdesc"]))
c.execute("UPDATE config SET value = '124' WHERE name = 'db_revision'")
self.db.commit()
except psycopg2.ProgrammingError as msg:
self.db.rollback()
raise DBUpdateError('Unable to apply sick update 124, rollback issued. Error message : %s' % (str(msg)))
"""
Add separate merged pdiff support settings for suites
@contact: Debian FTP Master <ftpmaster@debian.org>
@copyright: 2020, Niels Thykier <niels@thykier.net>
@license: GNU General Public License version 2 or later
"""
# 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; either version 2 of the License, or
# (at your option) any later version.
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
################################################################################
import psycopg2
from daklib.dak_exceptions import DBUpdateError
################################################################################
def do_update(self):
"""
Provide support for per-suite merged pdiff support
"""
print(__doc__)
try:
c = self.db.cursor()
c.execute("""
ALTER TABLE suite
ADD COLUMN merged_pdiffs boolean NOT NULL DEFAULT FALSE
""")
c.execute("UPDATE config SET value = '125' WHERE name = 'db_revision'")
self.db.commit()
except psycopg2.ProgrammingError as msg:
self.db.rollback()
raise DBUpdateError('Unable to apply sick update 123, rollback issued. Error message : %s' % (str(msg)))
#!/usr/bin/env python
# coding=utf8
"""
Add support for Description-md5
......@@ -25,8 +22,6 @@ Add support for Description-md5
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Add suite options for overrides and control-suite to DB
......@@ -25,8 +22,6 @@ Add suite options for overrides and control-suite to DB
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Make lastused in queuefiles/policyqueuefiles default now()
......@@ -25,8 +22,6 @@ Make lastused in queuefiles/policyqueuefiles default now()
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Remove redundant indices
......@@ -25,8 +22,6 @@ Remove redundant indices
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Reference archive table from suite and add path to archive root
......@@ -25,8 +22,6 @@ Reference archive table from suite and add path to archive root
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Drop origin_server column from archive table
......@@ -25,8 +22,6 @@ Drop origin_server column from archive table
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Multi-archive support; convert policy and build queues to regular suites
......@@ -25,8 +22,6 @@ Multi-archive support; convert policy and build queues to regular suites
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......@@ -64,7 +59,7 @@ def _track_files_per_archive(cnf, c):
# NOTE: The location table would need these changes, but we drop it later
# anyway.
#c.execute("""UPDATE location l SET path = path || c.name || '/'
# c.execute("""UPDATE location l SET path = path || c.name || '/'
# FROM component c
# WHERE l.component = c.id
# AND l.path NOT LIKE '%/' || c.name || '/'""")
......
#!/usr/bin/env python
# coding=utf8
"""
Add list of closed bugs to changes table
......@@ -25,8 +22,6 @@ Add list of closed bugs to changes table
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Move stayofexecution to the database
......@@ -25,8 +22,6 @@ Move stayofexecution to the database
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Alter permissions for new tables and set default permissions
......@@ -25,8 +22,6 @@ Alter permissions for new tables and set default permissions
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
add world schema and new stable views
......@@ -25,8 +22,6 @@ add world schema and new stable views
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
rename policy queues
......@@ -25,8 +22,6 @@ rename policy queues
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......@@ -46,9 +41,9 @@ def do_update(self):
c.execute("UPDATE suite set suite_name='stable-new' where suite_name='proposedupdates'")
c.execute("UPDATE suite set suite_name='oldstable-new' where suite_name='oldproposedupdates'")
c.execute("UPDATE config SET value = '79' WHERE name = 'db_revision'")
c.execute("UPDATE config SET value = '80' WHERE name = 'db_revision'")
self.db.commit()
except psycopg2.ProgrammingError as msg:
self.db.rollback()
raise DBUpdateError('Unable to apply sick update 79, rollback issued. Error message: {0}'.format(msg))
raise DBUpdateError('Unable to apply sick update 80, rollback issued. Error message: {0}'.format(msg))
#!/usr/bin/env python
# coding=utf8
"""
Correct permissions of policy_queue_byhand_file_id_seq
......@@ -25,8 +22,6 @@ Correct permissions of policy_queue_byhand_file_id_seq
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Correct permissions of policy_queue_upload_id_seq
......@@ -25,8 +22,6 @@ Correct permissions of policy_queue_upload_id_seq
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
switch to new ACL implementation and add pre-suite NEW
......@@ -25,8 +22,6 @@ switch to new ACL implementation and add pre-suite NEW
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
add per-suite database permissions
......@@ -25,8 +22,6 @@ add per-suite database permissions
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
add per-suite close_bugs option
......@@ -25,8 +22,6 @@ add per-suite close_bugs option
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Unprivileged group into the database config table
......@@ -25,8 +22,6 @@ Unprivileged group into the database config table
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
add external_files table for security
......@@ -25,8 +22,6 @@ add external_files table for security
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
add per-suite mail whitelists
......@@ -25,8 +22,6 @@ add per-suite mail whitelists
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
add table to keep track of seen signatures
......@@ -25,8 +22,6 @@ add table to keep track of seen signatures
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
add created_by_id and created columns to acl_per_source table
......@@ -25,8 +22,6 @@ add created_by_id and created columns to acl_per_source table
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
per-queue NEW comments and permissions
......@@ -25,8 +22,6 @@ per-queue NEW comments and permissions
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
remove per-fingerprint ACLs that are identical to keyring ACL
......@@ -25,8 +22,6 @@ remove per-fingerprint ACLs that are identical to keyring ACL
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
update world.files-1 view to handle backports archive on ftp-master
......@@ -25,8 +22,6 @@ update world.files-1 view to handle backports archive on ftp-master
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
src_associations_full view
......@@ -25,8 +22,6 @@ src_associations_full view
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Require SHA-1 and SHA-256 checksums in "files" table.
......@@ -25,8 +22,6 @@ Require SHA-1 and SHA-256 checksums in "files" table.
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Add world.suite_summary view.
......@@ -25,8 +22,6 @@ Add world.suite_summary view.
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
#!/usr/bin/env python
# coding=utf8
"""
Create path entries for changelog exporting
......@@ -25,8 +22,6 @@ Create path entries for changelog exporting
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
......
#!/usr/bin/env python
# coding=utf8
"""
Remove obsolete functions
......@@ -25,8 +22,6 @@ Remove obsolete functions
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。