Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,157 @@ jobs:
pywebdriver_win64_installer.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-bionic:
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build Ubuntu 18.04 package
run: |
docker run --rm -i \
--user root \
-v "$PWD:/workspace" \
-w /workspace \
ubuntu:18.04 \
bash -euxo pipefail -s <<'DOCKER_SCRIPT'

echo "========================================="
echo "Ubuntu version"
echo "========================================="

cat /etc/os-release

echo "========================================="
echo "Configure Bionic repositories"
echo "========================================="

cat > /etc/apt/sources.list <<'SOURCES_EOF'
deb http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
SOURCES_EOF

echo "========================================="
echo "APT update"
echo "========================================="

apt-get update

echo "========================================="
echo "Install dependencies"
echo "========================================="

DEBIAN_FRONTEND=noninteractive apt-get install -y \
ca-certificates \
libnss3-tools \
libcups2-dev \
cups \
devscripts \
debhelper \
dh-python \
dh-virtualenv \
python3-wheel \
python3-setuptools \
python3-venv \
libmtp-dev \
libffi-dev \
fakeroot \
python3-distutils \
python3-pip \
python3-simplejson \
python3-flask-babel \
python3-usb \
python3-serial \
python3-netifaces \
python3-cups \
python3-pillow \
dh-systemd \
perl

echo "========================================="
echo "Python"
echo "========================================="

python3 -m pip install \
--no-cache-dir \
"setuptools>45,<82"

python3 -m pip install flask-cors

echo "========================================="
echo "Build flags"
echo "========================================="

export DEB_CFLAGS_SET="-march=x86-64 -mtune=generic"
export DEB_CXXFLAGS_SET="-march=x86-64 -mtune=generic"
export CFLAGS="-march=x86-64 -mtune=generic"
export CXXFLAGS="-march=x86-64 -mtune=generic"

echo "DEB_CFLAGS_SET=$DEB_CFLAGS_SET"
echo "DEB_CXXFLAGS_SET=$DEB_CXXFLAGS_SET"
echo "CFLAGS=$CFLAGS"
echo "CXXFLAGS=$CXXFLAGS"

# 18.04 build uses Python 3.6, whose default text encoding in this environment is ASCII.
# In postelium package, there are some unicode characters in the description.
# Set LANG and LC_ALL to C.UTF-8 to avoid "UnicodeEncodeError: 'ascii' codec can't encode characters in position ... errors
export LANG=C.UTF-8
export LC_ALL=C.UTF-8

echo "========================================="
echo "Build package"
echo "========================================="

mkdir -p build

VERSION=$(date +%Y%m%d)
DEBIAN_FRONTEND=noninteractive apt-get install -y devscripts
/usr/bin/dch \
--package pywebdriver \
--newversion "$VERSION" \
--create \
-m "Created by CI"

debuild

echo "========================================="
echo "Build result"
echo "========================================="

ls -lah ../*.deb

# debuild/dpkg-buildpackage always drops the .deb one level
# above the source dir (i.e. outside /workspace, which is the
# only path bind-mounted back to the host). Copy it into the
# bind-mounted build/ dir so it survives past --rm.
cp ../*.deb build/
# build/ was created (mkdir -p above) and the .deb copied as
# root inside the container; open up permissions so the
# unprivileged host runner user can mv/read it afterward.
chmod -R a+rwX build
DOCKER_SCRIPT

- name: Rename package
run: |
mv build/pywebdriver_$(date +%Y%m%d)_amd64.deb \
../pywebdriver_bionic.deb

ls -lah ../pywebdriver_bionic.deb

- name: Verify package
run: |
dpkg-deb --info ../pywebdriver_bionic.deb

- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
../pywebdriver_bionic.deb
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-jammy:
runs-on: ubuntu-22.04
steps:
Expand Down
69 changes: 69 additions & 0 deletions build_ubuntu_18_04.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash
set -e

# ONLY use this to test builds. Actual build should be done by github actions

BUILD_DIR=$(pwd)/build
MESSAGE="automatic build"
PACKAGE="pywebdriver"
BASE_IMAGE=ubuntu:18.04
KEY=

mkdir -p $BUILD_DIR

cat <<DEBUILD > debuild.sh
# 18.04 build uses Python 3.6, whose default text encoding in this environment is ASCII.
# In postelium package, there are some unicode characters in the description.
# Set LANG and LC_ALL to C.UTF-8 to avoid "UnicodeEncodeError: 'ascii' codec can't encode characters in position ..." errors
export LANG=C.UTF-8
export LC_ALL=C.UTF-8

mkdir -p build
rm -f debian/changelog

# For weak/old CPUs which don't support AVX (e.g. Celeron J4125)
export DEB_CFLAGS_SET="-march=x86-64 -mtune=generic"
export DEB_CXXFLAGS_SET="-march=x86-64 -mtune=generic"
export CFLAGS="-march=x86-64 -mtune=generic"
export CXXFLAGS="-march=x86-64 -mtune=generic"

/pywebdriver/debian/pywebdriver/opt/venvs/pywebdriver/bin/pip install \
"pip==21.3.1" \
"setuptools==59.6.0" \
"wheel==0.37.1"

/pywebdriver/debian/pywebdriver/opt/venvs/pywebdriver/bin/pip --version
/pywebdriver/debian/pywebdriver/opt/venvs/pywebdriver/bin/python -m pip show setuptools

dch --package $PACKAGE --newversion $(date +%Y%m%d) --create -m "$MESSAGE"
debuild
cp ../${PACKAGE}_* /build
DEBUILD
chmod +x debuild.sh

cat <<DOCKERFILE > Dockerfile
FROM $BASE_IMAGE
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y gnupg ca-certificates
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B249F40128AF28E09310254A4A8F432547238F7E
RUN echo "deb https://ppa.launchpadcontent.net/jyrki-pulliainen/dh-virtualenv/ubuntu bionic main" > /etc/apt/sources.list.d/dh-virtualenv.list
RUN apt-get update && apt-get install -y debhelper dh-python dh-virtualenv dh-systemd devscripts python3-wheel libcups2-dev python3-setuptools libmtp-dev python3-pip libffi-dev python3-venv python3-distutils python3-pip python3-simplejson python3-flask-babel python3-usb python3-serial python3-netifaces python3-cups python3-pillow
RUN python3 -m pip install flask-cors
#COPY . /$PACKAGE
WORKDIR /$PACKAGE
DOCKERFILE

read -p "Build Docker image? (y/n) " REPLY
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
docker pull $BASE_IMAGE
docker build -t ${PACKAGE}_build .
fi

read -p "Buid $PACKAGE package? (y/n) " REPLY
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
docker run -v $(pwd):/$PACKAGE -v $BUILD_DIR:/build -it ${PACKAGE}_build bash -c "./debuild.sh"
fi
7 changes: 5 additions & 2 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ SNAKE=/usr/bin/python3
override_dh_virtualenv:
# the prebuilt pycups wheel needs AVX; force it to build from source so
# the packaged venv also works on weak/old CPUs (e.g. Celeron J4125)
dh_virtualenv --python=$(SNAKE) --builtin-venv --extra-pip-arg="--no-binary=pycups"

dh_virtualenv --python=/usr/bin/python3 --builtin-venv --extra-pip-arg="--no-binary=pycups" || { \
echo "===== PIP LOGS ====="; \
find /tmp -maxdepth 1 -type f -name 'tmp*' -exec sh -c 'echo "===== $$1 ====="; cat "$$1"' _ {} \; ; \
exit 1; \
}
# https://dh-virtualenv.readthedocs.io/en/latest/howtos.html#handling-binary-wheels
override_dh_strip:
dh_strip --exclude=/site-packages/
Expand Down
Loading