Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Packaging with tarball #18

Closed
wants to merge 6 commits into from
Closed
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
12 changes: 0 additions & 12 deletions Debian/OpenTabletDriver/DEBIAN/control

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions Debian/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
13 changes: 13 additions & 0 deletions Debian/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Source: opentabletdriver
Priority: optional
Build-Depends: dotnet-sdk-6.0
Maintainer: InfinityGhost <[email protected]>, hwsnemo <[email protected]>

Package: opentabletdriver
Version: 0.0.0
Section: base
Architecture: amd64
Depends: libevdev2, libgtk-3-0, dotnet-runtime-6.0
Recommends: libx11-dev, libxrandr-dev
Description: OpenTabletDriver
A cross-platform open source tablet driver.
29 changes: 29 additions & 0 deletions Debian/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: OpenTabletDriver
Source: https://github.com/InfinityGhost/OpenTabletDriver

Files: *
Copyright: Copyright 2019-2020 InfinityGhost <[email protected]>
License: LGPL-3+

Files: debian/*
Copyright: Copyright 2019-2020 InfinityGhost <[email protected]>
License: LGPL-3+

License: LGPL-3+
This package is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.

This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this package; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

On Debian systems, the complete text of the GNU Lesser General
Public License can be found in `/usr/share/common-licenses/LGPL-3'.
11 changes: 11 additions & 0 deletions Debian/debian/opentabletdriver.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
usr/share/OpenTabletDriver
usr/share/doc/OpenTabletDriver
usr/share/man/man8/opentabletdriver.8*
usr/share/pixmaps/otd.ico
usr/share/pixmaps/otd.png
usr/share/applications/OpenTabletDriver.desktop
usr/bin/opentabletdriver
usr/bin/otd
usr/lib/systemd/user/opentabletdriver.service
usr/lib/udev/rules.d/99-opentabletdriver.rules
usr/lib/modprobe.d/99-opentabletdriver.conf
2 changes: 1 addition & 1 deletion Debian/OpenTabletDriver/DEBIAN/postinst → Debian/debian/opentabletdriver.postinst
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ fi

if lsmod | grep wacom > /dev/null ; then
rmmod wacom || true
fi
fi
30 changes: 30 additions & 0 deletions Debian/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/make -f
SHELL=/usr/bin/env bash
PREFIX = debian/tmp/usr
PKG_VERSION = $(shell [[ $$(cat Directory.Build.props) =~ \<VersionBase\>(.+?)\<\/VersionBase\> ]] && echo $${BASH_REMATCH[1]})
VERSION_REGEX = ^Version=.\+$$
VERSION_REPLACE_REGEX = Version=$(PKG_VERSION)

%:
dh $@

override_dh_auto_build:
./build.sh
find ./bin -name "*.pdb" -type f -exec rm {} ';'

override_dh_auto_install:
mkdir -p $(PREFIX)/share/OpenTabletDriver
cp -r bin/* $(PREFIX)/share/OpenTabletDriver

cp -r Common/Linux/* $(PREFIX)

mkdir -p $(PREFIX)/share/man/man8
gzip -c docs/manpages/opentabletdriver.8 > $(PREFIX)/share/man/man8/opentabletdriver.8.gz

mkdir -p $(PREFIX)/share/pixmaps
cp -v OpenTabletDriver.UX/Assets/* $(PREFIX)/share/pixmaps

mkdir -p $(PREFIX)/lib/udev/rules.d
./generate-rules.sh -v OpenTabletDriver.Configurations/Configurations $(PREFIX)/lib/udev/rules.d/99-opentabletdriver.rules

sed -i "s/$(VERSION_REGEX)/$(VERSION_REPLACE_REGEX)/g" "$(PREFIX)/share/applications/OpenTabletDriver.desktop"
1 change: 1 addition & 0 deletions Debian/debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
121 changes: 48 additions & 73 deletions Debian/package
Original file line number Diff line number Diff line change
Expand Up @@ -4,98 +4,73 @@ SCRIPT_DIR=$(realpath $(dirname ${BASH_SOURCE[0]}))

source "${SCRIPT_DIR}/../base"

# Build arguments
FRAMEWORK="net6.0"
RUNTIME="linux-x64"
PROJECTS=("OpenTabletDriver.Daemon" "OpenTabletDriver.Console" "OpenTabletDriver.UX.Gtk")

# Directories
PKG_DIR="${SCRIPT_DIR}/OpenTabletDriver"
OUT_DIR="${PKG_DIR}/usr/share/OpenTabletDriver"
OUT_DIR_PIXMAPS="${PKG_DIR}/usr/share/pixmaps"

# Package
PKG_DEB_FILE="${SCRIPT_DIR}/OpenTabletDriver.deb"
DEBIAN_DIR="${PKG_DIR}/DEBIAN"

# Files
PKG_DESKTOP_FILE="${PKG_DIR}/usr/share/applications/OpenTabletDriver.desktop"
OUT_UDEV_FILE="${PKG_DIR}/usr/lib/udev/rules.d/99-opentabletdriver.rules"
PKG_DEB_DSC="${SCRIPT_DIR}/opentabletdriver.dsc"

# Output

clean() {
clean_target "${PKG_DEB_FILE}" "Cleaning up existing builds..."
clean_target "${OUT_DIR}" "Cleaning up build directory..."
clean_target "${OUT_UDEV_FILE}" "Cleaning existing udev rules..."

print "Cleaning 'DEBIAN/control'..."
regex_edit "^Installed-Size:.\+$" "Installed-Size: 0" "${DEBIAN_DIR}/control"
regex_edit "^Version: .\+$" "Version: 0.0.0" "${DEBIAN_DIR}/control"

print "Cleaning desktop file..."
regex_edit "^Version=.\+$" "Version=0.0.0" "${PKG_DESKTOP_FILE}"
clean_target "${PKG_DEB_DSC}" "Cleaning up an existing debian control file..."
clean_target "${SCRIPT_DIR}/debian/changelog" "Cleaning up an existing changelog file..."
print "Cleaning up an opentabletdriver build folder..."
find ${SCRIPT_DIR} -maxdepth 1 -name "opentabletdriver-*" -type d -exec rm -rf '{}' \;
print "Removing other build results..."
rm -f ${SCRIPT_DIR}/opentabletdriver_*
}

build() {
print "Building OpenTabletDriver..."
for project in ${PROJECTS[@]}; do
dotnet publish "${SRC_DIR}/${project}" \
--runtime ${RUNTIME} \
--configuration Release \
--self-contained false \
--framework ${FRAMEWORK} \
--output ${OUT_DIR} \
/p:VersionSuffix="${VERSION_SUFFIX}"
done
prepare() {
pushd ${SCRIPT_DIR}
cat <<EOF > debian/changelog
opentabletdriver (${PKG_VERSION}) UNRELEASED; urgency=low

* New version: ${PKG_VERSION}

-- InfinityGhost <[email protected]> `LANG=C date +"%a, %d %b %Y %X %z"`

EOF

make_debian_tarball "${SCRIPT_DIR}/opentabletdriver_${PKG_VERSION}.debian.tar.gz"
make_source_tarball_with_linux_files "${SCRIPT_DIR}/opentabletdriver_${PKG_VERSION}.orig.tar.gz"

cat <<EOF > ${PKG_DEB_DSC}
Format: 3.0 (quilt)
Source: opentabletdriver
Version: ${PKG_VERSION}
Binary: opentabletdriver
Build-Depends: dotnet-sdk-6.0
Maintainer: InfinityGhost <[email protected]>, hwsnemo <[email protected]>
Architecture: amd64
Standards-Version: 3.7.1
Files:
`md5sum opentabletdriver_${PKG_VERSION}.orig.tar.gz | cut -d ' ' -f 1` `wc -c opentabletdriver_${PKG_VERSION}.orig.tar.gz`
`md5sum opentabletdriver_${PKG_VERSION}.debian.tar.gz | cut -d ' ' -f 1` `wc -c opentabletdriver_${PKG_VERSION}.debian.tar.gz`
EOF
popd
}

package() {
generate_rules "${SRC_DIR_CONFIGURATIONS}" "${OUT_UDEV_FILE}"

copy_assets "${OUT_DIR_PIXMAPS}"

clean_debug "${OUT_DIR}"

update_size
update_version

create_debpkg "${PKG_DIR}" "${PKG_DEB_FILE}"

create_debpkg "${PKG_DEB_FILE}"
print "Packaging complete."
}

copy_assets() {
[ "$#" -ne 1 ] && exit 102

local ASSET_DIR="${SRC_DIR}/OpenTabletDriver.UX/Assets"
[ ! -d "${ASSET_DIR}" ] && exit 103

print "Copying assets to '${1}'..."
mkdir -p "${1}"
for file in "${SRC_DIR}/OpenTabletDriver.UX/Assets/*"; do
[ -f "${file}" ] && cp -v "${file}" "${1}/$(basename ${file})"
done
}

update_size() {
print "Updating size in DEBIAN/control"
regex_edit "Installed-Size:.\+$" "Installed-Size: $(du -s "${PKG_DIR}" | cut -f1)" "${DEBIAN_DIR}/control"
}

update_version() {
print "Updating version in DEBIAN/control"
regex_edit "Version: .\+$" "Version: ${PKG_VERSION}" "${DEBIAN_DIR}/control"

print "Updating version in desktop file"
regex_edit "Version=.\+$" "Version=${PKG_VERSION}" "${PKG_DESKTOP_FILE}"
make_debian_tarball() {
print "Making ${1} from debian tarball..."
pushd "${SCRIPT_DIR}"
tar -zcvf "${1}" "debian"
popd
}

create_debpkg () {
[ "$#" -ne 2 ] && exit 104

print "Packaging 'OpenTabletDriver.deb'..."
dpkg-deb --build "${1}" "${2}"
pushd "${SCRIPT_DIR}"
dpkg-source -x ${PKG_DEB_DSC}
cd opentabletdriver-${PKG_VERSION}
dpkg-buildpackage -rfakeroot -b
cd ..
mv "opentabletdriver_${PKG_VERSION}_amd64.deb" "${1}"
popd
}

case $1 in
Expand Down
Loading