Add first version of build script
This commit is contained in:
parent
70cd01cd11
commit
7adafd98bf
8
.env.sample
Normal file
8
.env.sample
Normal file
@ -0,0 +1,8 @@
|
||||
# Variables
|
||||
PYTHON_VERSION="3.13.1"
|
||||
DEB_PACKAGE_MANTAINER="My Name <mail@binary-kitchen.de>"
|
||||
GITEA_URL="https://git.binary-kitchen.de"
|
||||
GITEA_USER="xxxxxxxx"
|
||||
GITEA_TOKEN="xxxxxxxx"
|
||||
GITEA_REPO_NAME="homeautomation"
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
*.deb
|
||||
.env
|
||||
|
66
create_package.sh
Executable file
66
create_package.sh
Executable file
@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
# Variables
|
||||
PYTHON_VERSION="3.13.1"
|
||||
PYTHON_VERSION_BUILD="1"
|
||||
DEB_PACKAGE_NAME="python3.13"
|
||||
DEB_PACKAGE_VERSION="$PYTHON_VERSION-$PYTHON_VERSION_BUILD"
|
||||
DEB_PACKAGE_MANTAINER=""
|
||||
GITEA_URL=""
|
||||
GITEA_USER=""
|
||||
GITEA_TOKEN=""
|
||||
GITEA_REPO_NAME=""
|
||||
ARCH="amd64"
|
||||
DISTRIBUTION="bookworm-backports"
|
||||
COMPONENT="main"
|
||||
INSTALL_PATH="/opt/python3.13"
|
||||
|
||||
set -a && source .env && set +a
|
||||
|
||||
# Create control file for Debian packaging
|
||||
mkdir -p DEBIAN
|
||||
cat <<EOF > DEBIAN/control
|
||||
Package: $DEB_PACKAGE_NAME
|
||||
Version: $DEB_PACKAGE_VERSION
|
||||
Architecture: $ARCH
|
||||
Maintainer: $DEB_PACKAGE_MANTAINER
|
||||
Description: Custom built Python 3.13 package
|
||||
EOF
|
||||
|
||||
# Create a Dockerfile
|
||||
cat <<EOF > Dockerfile
|
||||
FROM debian:stable
|
||||
RUN apt update && apt install -y build-essential wget libssl-dev zlib1g-dev \
|
||||
libncurses5-dev libgdbm-dev libnss3-dev libreadline-dev libffi-dev \
|
||||
libsqlite3-dev dpkg-dev
|
||||
WORKDIR /usr/src
|
||||
RUN wget https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz \
|
||||
&& tar xzf Python-$PYTHON_VERSION.tgz && cd Python-$PYTHON_VERSION \
|
||||
&& ./configure --prefix=$INSTALL_PATH --enable-optimizations && make -j$(nproc) && make altinstall
|
||||
RUN mkdir -p $INSTALL_PATH/DEBIAN
|
||||
RUN mkdir -p /pkg
|
||||
COPY DEBIAN/control $INSTALL_PATH/DEBIAN/control
|
||||
RUN dpkg-deb --build $INSTALL_PATH /pkg/$DEB_PACKAGE_NAME-$DEB_PACKAGE_VERSION-$ARCH.deb
|
||||
EOF
|
||||
|
||||
|
||||
# Build the Docker image
|
||||
docker build --progress=plain -t python-deb-builder .
|
||||
|
||||
# Extract the .deb file
|
||||
docker run --rm --name python-deb-container -v $(pwd):/output python-deb-builder cp /pkg/$DEB_PACKAGE_NAME-$DEB_PACKAGE_VERSION-$ARCH.deb /output/
|
||||
|
||||
# CleanUp
|
||||
rm -R DEBIAN
|
||||
rm Dockerfile
|
||||
|
||||
# Upload to Gitea
|
||||
curl --user $GITEA_USER:$GITEA_TOKEN \
|
||||
-X DELETE \
|
||||
"$GITEA_URL/api/packages/$GITEA_REPO_NAME/debian/pool/$DISTRIBUTION/$COMPONENT/$DEB_PACKAGE_NAME/$DEB_PACKAGE_VERSION/$ARCH"
|
||||
|
||||
curl --user $GITEA_USER:$GITEA_TOKEN \
|
||||
--upload-file "$DEB_PACKAGE_NAME-$DEB_PACKAGE_VERSION-$ARCH.deb" \
|
||||
"$GITEA_URL/api/packages/$GITEA_REPO_NAME/debian/pool/$DISTRIBUTION/$COMPONENT/upload"
|
Loading…
x
Reference in New Issue
Block a user