From be855ccebe64dbb8c112cd196fd162aa183fb454 Mon Sep 17 00:00:00 2001 From: deeaitch Date: Fri, 28 Aug 2026 01:46:43 -0400 Subject: [PATCH] Add Debian package build --- .gitignore | 2 +- CMakeLists.txt | 42 ++++++++++++++++++++++++----------------- README.md | 17 +++++++++++++++++ debian/.gitignore | 3 +++ debian/changelog | 5 +++++ debian/control | 16 ++++++++++++++++ debian/copyright | 40 +++++++++++++++++++++++++++++++++++++++ debian/rules | 44 +++++++++++++++++++++++++++++++++++++++++++ debian/source/format | 1 + debian/source/options | 2 ++ 10 files changed, 154 insertions(+), 18 deletions(-) create mode 100644 debian/.gitignore create mode 100644 debian/changelog create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100644 debian/source/options diff --git a/.gitignore b/.gitignore index 4a0b530..4abcc12 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ tags .directory *.debug Makefile* +/build-debian/ *.prl *.app moc_*.cpp @@ -71,4 +72,3 @@ CMakeLists.txt.user* # -------- *.dll *.exe - diff --git a/CMakeLists.txt b/CMakeLists.txt index f6f7b58..26a74cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,28 +1,31 @@ cmake_minimum_required(VERSION 3.16) -project(kindle2notes VERSION 1.0 LANGUAGES CXX) +project(kindle2notes VERSION 1.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -set(KINDLE2NOTES_VERSION "${PROJECT_VERSION}") -find_package(Git QUIET) -if(Git_FOUND) - execute_process( - COMMAND ${GIT_EXECUTABLE} describe --tags --long --dirty --always - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE KINDLE2NOTES_GIT_RESULT - OUTPUT_VARIABLE KINDLE2NOTES_GIT_DESCRIBE - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - ) +set(KINDLE2NOTES_VERSION "" CACHE STRING "Override the version reported by kindle2notes") +if(KINDLE2NOTES_VERSION STREQUAL "") + set(KINDLE2NOTES_VERSION "${PROJECT_VERSION}") + find_package(Git QUIET) + if(Git_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --tags --long --dirty --always + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE KINDLE2NOTES_GIT_RESULT + OUTPUT_VARIABLE KINDLE2NOTES_GIT_DESCRIBE + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) - if(KINDLE2NOTES_GIT_RESULT EQUAL 0 AND NOT KINDLE2NOTES_GIT_DESCRIBE STREQUAL "") - if(KINDLE2NOTES_GIT_DESCRIBE MATCHES "^(.+)-0-g[0-9a-f]+$") - set(KINDLE2NOTES_VERSION "${CMAKE_MATCH_1}") - else() - set(KINDLE2NOTES_VERSION "${KINDLE2NOTES_GIT_DESCRIBE}") + if(KINDLE2NOTES_GIT_RESULT EQUAL 0 AND NOT KINDLE2NOTES_GIT_DESCRIBE STREQUAL "") + if(KINDLE2NOTES_GIT_DESCRIBE MATCHES "^(.+)-0-g[0-9a-f]+$") + set(KINDLE2NOTES_VERSION "${CMAKE_MATCH_1}") + else() + set(KINDLE2NOTES_VERSION "${KINDLE2NOTES_GIT_DESCRIBE}") + endif() endif() endif() endif() @@ -55,3 +58,8 @@ kindle2notes_enable_warnings(kindle2notes) target_compile_definitions(kindle2notes PRIVATE KINDLE2NOTES_VERSION="${KINDLE2NOTES_VERSION}" ) + +include(GNUInstallDirs) +install(TARGETS kindle2notes + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/README.md b/README.md index dc9abec..b206856 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,23 @@ The resulting executable is: build/kindle2notes ``` +### Debian package + +On Debian or a Debian-based distribution, install the package build tools and +build the binary package with: + +```bash +sudo apt install build-essential cmake dpkg-dev +dpkg-buildpackage --build=binary --no-sign +``` + +The `.deb`, `.changes`, and `.buildinfo` files are written to the parent +directory. To create a Debian source package instead, run: + +```bash +dpkg-buildpackage --build=source --no-sign +``` + When the source is built from Git, CMake obtains the version from `git describe`. A build made exactly from a release tag reports only that tag (for example, `1.0`). Later commits include their distance from the tag and diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 0000000..502e8bc --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1,3 @@ +/files +/*.substvars +/kindle2notes/ diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..ebca558 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +kindle2notes (1.1) unstable; urgency=medium + + * Initial Debian package. + + -- deeaitch Fri, 28 Aug 2026 01:46:16 -0400 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..e530950 --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: kindle2notes +Section: utils +Priority: optional +Maintainer: deeaitch +Build-Depends: cmake (>= 3.16), g++, dpkg-dev +Standards-Version: 4.6.2 +Rules-Requires-Root: no +Homepage: https://git.himro.ca/deeaitch/kindle2notes + +Package: kindle2notes +Architecture: any +Depends: ${shlibs:Depends} +Description: convert Kindle clippings into structured notes + kindle2notes converts Amazon Kindle My Clippings text exports into + human-editable LaTeX, Markdown, Org mode, or AsciiDoc documents. Highlights + are grouped by book title and include dedicated sections for personal notes. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..e5aef32 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,40 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: kindle2notes +Source: https://git.himro.ca/deeaitch/kindle2notes + +Files: * +Copyright: 2026 deeaitch +License: GPL-3+ + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + . + This program 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 General Public License for more details. + . + On Debian systems, the complete text of the GNU General Public License + version 3 can be found in "/usr/share/common-licenses/GPL-3". + +Files: typefactory/typefactory.h +Copyright: 2026 Dim Himro +License: MIT + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..d1bc32e --- /dev/null +++ b/debian/rules @@ -0,0 +1,44 @@ +#!/usr/bin/make -f + +include /usr/share/dpkg/architecture.mk +include /usr/share/dpkg/buildflags.mk + +PACKAGE := kindle2notes +BUILD_DIR := build-debian +PACKAGE_DIR := $(CURDIR)/debian/$(PACKAGE) +PACKAGE_VERSION := $(shell dpkg-parsechangelog -S Version) + +.PHONY: clean build build-arch build-indep binary binary-arch binary-indep + +clean: + rm -rf $(BUILD_DIR) $(PACKAGE_DIR) + rm -f debian/files debian/*.substvars + +build: build-arch build-indep + +build-arch: + cmake -S . -B $(BUILD_DIR) \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DKINDLE2NOTES_VERSION=$(PACKAGE_VERSION) \ + -DCMAKE_CXX_FLAGS="$(CXXFLAGS) $(CPPFLAGS)" \ + -DCMAKE_EXE_LINKER_FLAGS="$(LDFLAGS)" + cmake --build $(BUILD_DIR) --parallel + +build-indep: + +binary: binary-arch binary-indep + +binary-arch: build-arch + DESTDIR=$(PACKAGE_DIR) cmake --install $(BUILD_DIR) + strip --strip-unneeded $(PACKAGE_DIR)/usr/bin/$(PACKAGE) + install -d $(PACKAGE_DIR)/usr/share/doc/$(PACKAGE) + install -m 0644 debian/copyright $(PACKAGE_DIR)/usr/share/doc/$(PACKAGE)/copyright + install -m 0644 README.md $(PACKAGE_DIR)/usr/share/doc/$(PACKAGE)/README.md + gzip -n -9 -c debian/changelog > $(PACKAGE_DIR)/usr/share/doc/$(PACKAGE)/changelog.Debian.gz + install -d $(PACKAGE_DIR)/DEBIAN + dpkg-shlibdeps -Tdebian/$(PACKAGE).substvars debian/$(PACKAGE)/usr/bin/$(PACKAGE) + dpkg-gencontrol -p$(PACKAGE) -P$(PACKAGE_DIR) -Tdebian/$(PACKAGE).substvars + dpkg-deb --build --root-owner-group $(PACKAGE_DIR) .. + +binary-indep: diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/debian/source/options b/debian/source/options new file mode 100644 index 0000000..0528768 --- /dev/null +++ b/debian/source/options @@ -0,0 +1,2 @@ +tar-ignore = .git +tar-ignore = *.pro.user