FROM ubuntu:18.04

# This has to be done within `ubuntu` Docker image. Otherwise (when running on a default Travis Ubuntu Xenial VM), Travis fails with the following:

# python setup.py install --force --root=debian/python-git-machete --no-compile -O0 --install-layout=deb --prefix=/usr
# usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
#   or: setup.py --help [cmd1 cmd2 ...]
#   or: setup.py --help-commands
#   or: setup.py cmd --help
# error: option --install-layout not recognized

RUN apt-get -qq update && apt-get install -y -qq python-all python-pip python3-pip python3-stdeb dh-python git lintian

COPY . git-machete/
WORKDIR git-machete/
RUN pip install pbr
RUN pip3 install pbr
# Hacks necessary to enforce a reasonable description in the generated Debian package (instead of one autogenerated from the existing summary and README.md)
RUN sed -i 's/summary =.*/summary = Git repository organizer \& rebase workflow automation tool/' setup.cfg
RUN cp ci/README-deb.md README.md
RUN python3 setup.py --command-packages=stdeb.command sdist_dsc --with-python2=True --with-python3=True --copyright-file=LICENSE bdist_deb

WORKDIR deb_dist/
RUN ls -l
RUN dpkg-deb --info python3-git-machete_*.deb
RUN dpkg-deb --contents python3-git-machete_*.deb
RUN lintian python3-git-machete_*.deb
