Skip to content

Commit

Permalink
fix Issue #44
Browse files Browse the repository at this point in the history
The build script is not being replaced because stdeb does not support custom changelogs
  • Loading branch information
Deric-W committed Jul 2, 2021
1 parent a5c6f6d commit 21b70f7
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 69 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ A script is called either by the configuration of the web server or a shebang an
- Optional: set the `PYHPCONFIG` environ variable or copy *pyhp.toml* to one of the config file locations to use the CLI commands

### Debian package
1. build the *pyhp-core* python package with `python3 setup.py bdist_wheel`
2. go to the *debian* directory and execute `./build_deb.sh`
3. enter a package version, the path of the *pyhp-core* wheel and the pip command you wish to use
4. Done! You can now install the debian package with `sudo dpkg -i pyhp_<package version>_all.deb`
1. execute `debian/build_deb.sh` in the root directory of the project.
2. Done! You can now install the debian package with `sudo dpkg -i python3-pyhp-core_{version}-1_all.deb`

- Optional: check if the recommended packages `python3-toml` and `python3-werkzeug` are installed to use the CLI commands

### Manually
1. install the *pyhp-core* python package
Expand Down
81 changes: 41 additions & 40 deletions debian/build_deb.sh
Original file line number Diff line number Diff line change
@@ -1,61 +1,62 @@
#!/bin/sh -e
# script for building the pyhp debian package
# it is recommended to run this script as root or to set the owner and group of the files to root
# you need to build the pyhp-core wheel first

if [ "$1" = "" ]
then read -p "Version: " version
else version=$1
fi

if [ "$2" = "" ]
then read -p "pyhp-core Wheel: " wheel
else wheel=$2
fi

if [ "$3" = "" ]
then read -p "pip executeable: " pip
else pip=$3
fi

package="pyhp_${version}_all"
version=$(python3 setup.py --version)
maintainer=$(python3 setup.py --maintainer)
email=$(python3 setup.py --maintainer-email)
homepage=$(python3 setup.py --url)
description=$(python3 setup.py --description)
licence=$(python3 setup.py --licence)

package="python3-pyhp-core_${version}-1_all"
mkdir "$package"

# place pyhp-core files
mkdir -p "${package}/usr/lib/python3/dist-packages"
$pip install --target "${package}/usr/lib/python3/dist-packages" --ignore-installed --no-compile "$wheel"
python3 setup.py install --install-layout=deb --no-compile --single-version-externally-managed --root="$package"

# place config file and "executable"
mkdir "${package}/etc"
cp ../pyhp.toml "${package}/etc"
# strip python version from .egg-info directory
mv $package/usr/lib/python3/dist-packages/pyhp_core-${version}-*.egg-info "$package/usr/lib/python3/dist-packages/pyhp_core-${version}.egg-info"

mkdir -p "${package}/usr/bin"
mv "${package}/usr/lib/python3/dist-packages/bin/pyhp" "${package}/usr/bin"
rmdir "${package}/usr/lib/python3/dist-packages/bin"
chmod +x "${package}/usr/bin/pyhp"
# place config file
mkdir "${package}/etc"
cp pyhp.toml "${package}/etc"

# place metadata files
mkdir "$package/DEBIAN"
# calculate installed size
cat control | python3 format.py "${version}" $(du -sk --apparent-size --exclude "DEBIAN" "${package}" 2>/dev/null | cut -f1) > "${package}/DEBIAN/control"
cp conffiles "$package/DEBIAN"

mkdir -p "${package}/usr/share/doc/pyhp"
cp copyright "${package}/usr/share/doc/pyhp"
cp changelog "${package}/usr/share/doc/pyhp/changelog.Debian"
gzip -n --best "${package}/usr/share/doc/pyhp/changelog.Debian"

# generate md5sums file
chdir "$package"
md5sum $(find . -type d -name "DEBIAN" -prune -o -type f -print) > DEBIAN/md5sums # ignore metadata files
sha256sum $(find . -type d -name "DEBIAN" -prune -o -type f -print) > DEBIAN/sha256sums
chdir ../
# place control
cat debian/control | python3 debian/format.py \
"$version" \
"$maintainer" "$email" \
$(du -sk --apparent-size --exclude "DEBIAN" "${package}" 2>/dev/null | cut -f1) \
"$homepage" \
"$description" \
> "${package}/DEBIAN/control"

# place conffiles
cp debian/conffiles "$package/DEBIAN"

# place copyright and changelog
mkdir -p "${package}/usr/share/doc/python3-pyhp-core"
cat debian/copyright | python3 debian/format.py \
"$maintainer" "$email" \
"$homepage" \
"$licence" \
> "${package}/usr/share/doc/python3-pyhp-core/copyright"
cp debian/changelog "${package}/usr/share/doc/python3-pyhp-core/changelog.Debian"
gzip -n --best "${package}/usr/share/doc/python3-pyhp-core/changelog.Debian"

# generate md5sums and sha256sums file
cd "$package"
md5sum $(find . -type d -name "DEBIAN" -prune -o -type f -print) > "DEBIAN/md5sums" # ignore metadata files
sha256sum $(find . -type d -name "DEBIAN" -prune -o -type f -print) > "DEBIAN/sha256sums"
cd ..

# if root set file permissions, else warn
if [ $(id -u) = 0 ]
then chown root:root -R "$package"
else echo "not running as root, permissions in package may be wrong"
else echo "Warning: not running as root, permissions in package may be wrong"
fi

# build debian package
Expand Down
19 changes: 10 additions & 9 deletions debian/control
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
Package: pyhp
Version: {0}
Package: python3-pyhp-core
Source: pyhp-core
Version: {0}-1
Architecture: all
Maintainer: Eric Wolf <[email protected]>
Installed-Size: {1}
Maintainer: {1} <{2}>
Installed-Size: {3}
Depends: python3:any (>= 3.7)
Suggests: apache2
Section: web
Recommends: python3-toml (>= 0.10.0), python3-werkzeug (>= 0.14.0)
Section: python
Priority: optional
Homepage: https://github.com/Deric-W/PyHP
Description: Application for embedding and using python code like php
PyHP is a application/python package for embedding python code in text files like HTML,
Homepage: {4}
Description: {5}
PyHP is a application/python package for embedding python code in text files like HTML,
with several PHP functions available.
10 changes: 5 additions & 5 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: pyhp
Upstream-Contact: Eric Wolf <[email protected]>
Source: https://github.com/Deric-W/PyHP
Upstream-Name: python3-pyhp-core
Upstream-Contact: {0} <{1}>
Source: {2}
Copyright: 2021 Eric Wolf
License: GPLv3
License: {3}

Files: *
Copyright: 2021 Eric Wolf
License: GPLv3
License: {3}
11 changes: 7 additions & 4 deletions debian/format.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/python3
# format stdin with cli arguments

"""format stdin with cli arguments"""

import sys

data = sys.stdin.read()
data = data.format(*sys.argv[1:])
sys.stdout.write(data)

sys.stdout.write(
sys.stdin.read().format(*sys.argv[1:])
)
7 changes: 0 additions & 7 deletions pyhp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,3 @@ enable = true

# how many files can be uploaded at once
max_files = 20







0 comments on commit 21b70f7

Please sign in to comment.