Skip to content

Commit

Permalink
replace gbp docker image with tools docker image
Browse files Browse the repository at this point in the history
Co-Authored-By: Łukasz Langa <[email protected]>
  • Loading branch information
asottile and ambv committed Jan 21, 2024
1 parent 20dd403 commit 2ad4e9f
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 39 deletions.
12 changes: 0 additions & 12 deletions dockerfiles/Dockerfile.gbp

This file was deleted.

1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.tools
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# we use the oldest supported distribution for pristine-tar
FROM ubuntu:focal
RUN : \
&& apt-get update -qq \
Expand Down
12 changes: 6 additions & 6 deletions import-dsc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import os.path
import subprocess
import tempfile

HERE = os.path.abspath(os.path.dirname(__file__))
TOOLS = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'tools')


def _quiet(*cmd: str) -> None:
Expand All @@ -26,19 +26,19 @@ def main() -> int:
dsc, = (f for f in os.listdir(td) if f.endswith('.dsc'))

subprocess.check_call((
os.path.join(HERE, 'gbp'), '--volume', f'{td}:{td}:ro',
'import-dsc', os.path.join(td, dsc),
TOOLS, '--volume', f'{td}:{td}:ro',
'gbp', 'import-dsc', os.path.join(td, dsc),
'--create-missing-branches',
'--upstream-branch', 'upstream',
'--pristine-tar', '--debian-branch', args.branch_name,
))

_quiet('git', 'checkout', '-q', args.branch_name)
_quiet('gbp', 'pq', 'import')
_quiet(TOOLS, 'gbp', 'pq', 'import')
_quiet('git', 'checkout', '-q', args.branch_name)
_quiet('git', 'merge', '--no-edit', 'upstream')
_quiet('gbp', 'pq', 'rebase')
_quiet('gbp', 'pq', 'export')
_quiet(TOOLS, 'gbp', 'pq', 'rebase')
_quiet(TOOLS, 'gbp', 'pq', 'export')
if subprocess.call(('git', 'diff', '--quiet')):
_quiet('git', 'add', 'debian/patches')
_quiet('git', 'commit', '-m', 'Refresh patches.')
Expand Down
6 changes: 3 additions & 3 deletions import-upstream
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import subprocess
import tempfile
from typing import NamedTuple

HERE = os.path.abspath(os.path.dirname(__file__))
TOOLS = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'tools')
VERSION_RE = re.compile(r'^(\d+\.\d+\.\d+)((?:a|b|rc)\d+)?$')


Expand Down Expand Up @@ -78,9 +78,9 @@ def main() -> int:
))

subprocess.check_call((
os.path.join(HERE, 'gbp'),
TOOLS,
'--volume', f'{dest}:{dest}:ro',
'import-orig', dest, '--pristine-tar', '--no-interactive',
'gbp', 'import-orig', dest, '--pristine-tar', '--no-interactive',
'--no-symlink-orig', '--no-merge',
))

Expand Down
11 changes: 6 additions & 5 deletions nightly-update-branch
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ from __future__ import annotations

import argparse
import datetime
import os
import os.path
import re
import subprocess

TOOLS = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'tools')
VERSION_RE = re.compile(r'^v(\d+\.\d+\.\d+)((?:a|b|rc)\d+)?(.*)$')


Expand Down Expand Up @@ -47,16 +48,16 @@ def main() -> int:
deadsnakes_tag = f'deadsnakes/v{v_match[1]}{v_match[3]}'

subprocess.check_call(('git', 'tag', deadsnakes_tag, 'origin/upstream'))
subprocess.check_call(('gbp', 'pq', 'import'))
subprocess.check_call((TOOLS, 'gbp', 'pq', 'import'))
subprocess.check_call(('git', 'checkout', args.branch))
subprocess.check_call(('git', 'merge', 'origin/upstream', '--no-edit'))
subprocess.check_call(('gbp', 'pq', 'rebase'))
subprocess.check_call(('gbp', 'pq', 'export'))
subprocess.check_call((TOOLS, 'gbp', 'pq', 'rebase'))
subprocess.check_call((TOOLS, 'gbp', 'pq', 'export'))
subprocess.check_call(('git', 'add', 'debian/patches'))
if subprocess.call(('git', 'diff', '--staged', '--quiet')):
subprocess.check_call(('git', 'commit', '-m', 'Refresh patches'))
subprocess.check_call((
'dch', '--newversion', debian_version, '--distribution', dist,
TOOLS, 'dch', '--newversion', debian_version, '--distribution', dist,
f'Update to {current_tag} ({datetime.date.today()}).',
))
subprocess.check_call((
Expand Down
16 changes: 9 additions & 7 deletions refresh-patches
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
from __future__ import annotations

import argparse
import os
import os.path
import subprocess

TOOLS = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'tools')


def _release_message(version: str) -> str:
version, _, prerelease = version.partition('~')
Expand Down Expand Up @@ -34,10 +36,10 @@ def main() -> int:
_quiet('git', 'checkout', '-q', 'upstream')

_quiet('git', 'checkout', '-q', args.branch_name)
_quiet('gbp', 'pq', 'import')
_quiet(TOOLS, 'gbp', 'pq', 'import')
_quiet('git', 'checkout', '-q', args.branch_name)
_quiet('git', 'merge', '--no-edit', 'upstream')
if subprocess.call(('gbp', 'pq', 'rebase')):
if subprocess.call((TOOLS, 'gbp', 'pq', 'rebase')):
print('*' * 79)
print('Did not rebase cleanly!')
print('- to cancel: `git rebase --abort` and `exit 1`')
Expand All @@ -46,24 +48,24 @@ def main() -> int:
ret = subprocess.call(os.environ.get('SHELL', 'bash'))
if ret:
return ret
_quiet('gbp', 'pq', 'export')
_quiet(TOOLS, 'gbp', 'pq', 'export')
_quiet('git', 'add', 'debian/patches')
if subprocess.call(('git', 'diff', '--staged', '--quiet')):
_quiet('git', 'commit', '-m', 'Refresh patches.')
print('- patches refreshed')

cmd = ('git', 'log', '-1', '--format=%s', 'upstream')
version = subprocess.check_output(cmd).decode().split()[-1]
_quiet('sed', '-i', f's/^SVER=.*$/SVER={version}/g', 'debian/rules')
_quiet(TOOLS, 'sed', '-i', f's/^SVER=.*$/SVER={version}/g', 'debian/rules')
_quiet('git', 'commit', '-am', f'Update SVER to {version}')
print(f'- SVER updated to {version}')

dist = subprocess.check_output((
'dpkg-parsechangelog', '--show-field=distribution',
TOOLS, 'dpkg-parsechangelog', '--show-field=distribution',
)).decode().strip()
debian_version = f'{version}-1+{dist}1'
_quiet(
'dch', '--newversion', debian_version, '--distribution', dist,
TOOLS, 'dch', '--newversion', debian_version, '--distribution', dist,
_release_message(version),
)
_quiet('git', 'commit', '-am', f'Finish changelog for {debian_version}')
Expand Down
28 changes: 22 additions & 6 deletions gbp → tools
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,41 @@ import sys
from typing import NoReturn

HERE = os.path.abspath(os.path.dirname(__file__))
IMG = 'ghcr.io/deadsnakes/gbp'
IMG = 'ghcr.io/deadsnakes/tools'


def _git_cfg(s: str) -> str:
cmd = ('git', 'config', s)
return subprocess.check_output(cmd).decode().strip()


def main() -> NoReturn:
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--volume', dest='volumes', action='append')
parser.add_argument(
'-v', '--volume',
dest='volumes',
action='append',
default=[],
)
args, rest = parser.parse_known_args()

# we use the oldest supported distribution for pristine-tar
name = _git_cfg('user.name')
email = _git_cfg('user.email')

subprocess.check_call((os.path.join(HERE, 'pull-image'), IMG))

gitconfig = os.path.expanduser('~/.gitconfig')
interactive = '-ti' if sys.stdin.isatty() else '-i'
cmd = (
'docker', 'run', '--rm', interactive,
'--volume', f'{gitconfig}:/homedir/.gitconfig:ro',
'--volume', f'{os.getcwd()}:/tmp/src:rw',
'--env', f'GIT_AUTHOR_NAME={name}',
'--env', f'GIT_AUTHOR_EMAIL={email}',
'--env', f'GIT_COMMITTER_NAME={name}',
'--env', f'GIT_COMMITTER_EMAIL={email}',
'--env', f'DEBFULLNAME={name}',
'--env', f'DEBEMAIL={email}',
*(f'--volume={volume}' for volume in args.volumes),
IMG, 'gbp', *rest,
IMG, *rest,
)
os.execvp(cmd[0], cmd)

Expand Down

0 comments on commit 2ad4e9f

Please sign in to comment.