From fdfbf5262f74d081abd061315dacb885e6ea30d3 Mon Sep 17 00:00:00 2001 From: NanamiAdmin Date: Sun, 30 Aug 2026 10:24:35 +0800 Subject: [PATCH] initial commit: make basic debian .deb package compile structure --- .gitignore | 18 ++++++++++++ CMakeLists.txt | 14 +++++++++ README.md | 69 ++++++++++++++++++++++++++++++++++++++++++++ build-deb.sh | 42 +++++++++++++++++++++++++++ debian/changelog | 5 ++++ debian/compat | 1 + debian/control | 16 ++++++++++ debian/copyright | 28 ++++++++++++++++++ debian/install | 1 + debian/rules | 7 +++++ debian/source/format | 1 + main.cpp | 13 +++++++++ pack-deb.sh | 56 +++++++++++++++++++++++++++++++++++ 13 files changed, 271 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 100644 build-deb.sh create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/install create mode 100644 debian/rules create mode 100644 debian/source/format create mode 100644 main.cpp create mode 100644 pack-deb.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..92ef18b --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +# Build output +build/ +staging/ +dist/ + +# Generated Debian artifacts +*.deb +*.dsc +*.changes +*.buildinfo + +# Visual Studio +.vs/ + +# CMake +CMakeCache.txt +CMakeFiles/ +cmake_install.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8dd2009 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.16) + +project(hatsune-miku-shoshitsu + VERSION 0.1.0 + LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(hatsune-miku-shoshitsu main.cpp) + +# Installed to /usr/bin — the Debian packaging relies on this rule. +install(TARGETS hatsune-miku-shoshitsu + RUNTIME DESTINATION bin) diff --git a/README.md b/README.md new file mode 100644 index 0000000..f60a286 --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +# Hatsune Miku's Shoshitsu in Terminal + +A C++ program that runs in the terminal, packaged for Debian-based Linux +distributions (Debian, Ubuntu, Linux Mint, Pop!_OS, ...). + +## Project layout + +``` +main.cpp the program (placeholder — replace with your code) +CMakeLists.txt CMake build (used by both Windows and Linux builds) +debian/ Debian source-package structure + control package metadata (name, version, deps, description) + changelog version history for the package + copyright license/copyright info + rules debhelper build rules (runs CMake, installs files) + compat debhelper compatibility level (13) + source/format 3.0 (quilt) + install which built files go into the package +build-deb.sh full .deb build via debhelper (recommended) +pack-deb.sh minimal .deb build via dpkg-deb (no debhelper) +``` + +## Building the .deb + +The package must be built **on Debian-family Linux** (or in WSL2 / a Docker +container). Build it with debhelper (recommended): + +```sh +sudo apt install build-essential cmake debhelper +./build-deb.sh +``` + +or, if you don't want debhelper, with the minimal script: + +```sh +sudo apt install build-essential cmake +./pack-deb.sh +``` + +Both drop a `.deb` file into `./dist/`. + +## Installing the package + +```sh +sudo apt install ./dist/hatsune-miku-shoshitsu_*.deb +# or +sudo dpkg -i ./dist/hatsune-miku-shoshitsu_*.deb +``` + +The binary is installed to `/usr/bin/hatsune-miku-shoshitsu`, so run it with: + +```sh +hatsune-miku-shoshitsu +``` + +To uninstall: + +```sh +sudo apt remove hatsune-miku-shoshitsu +``` + +## Customizing before release + +- `debian/control` — set a real `Maintainer` and a real `Description`. +- `debian/changelog` — bump the version and add your own entry. +- `debian/copyright` — pick the license this project is actually under. +- `main.cpp` — replace the placeholder with the real program. +- `CMakeLists.txt` — if you add more `.cpp` files, list them in + `add_executable(...)`. diff --git a/build-deb.sh b/build-deb.sh new file mode 100644 index 0000000..5587f42 --- /dev/null +++ b/build-deb.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# +# Build the project and pack it into a .deb using the standard Debian +# toolchain (debhelper). Run this on a Debian-family system, e.g. Debian, +# Ubuntu, or in WSL2 / a Docker container: +# +# sudo apt install build-essential cmake debhelper +# ./build-deb.sh +# +# The resulting package lands in ./dist/ and can be installed with: +# sudo apt install ./dist/hatsune-miku-shoshitsu_*.deb +# +set -euo pipefail +cd "$(dirname "$0")" + +# --- sanity checks --------------------------------------------------------- +for tool in dpkg-buildpackage dpkg-deb cmake; do + command -v "$tool" >/dev/null 2>&1 || { + echo "error: '$tool' not found." >&2 + echo " Install the build tools first:" >&2 + echo " sudo apt install build-essential cmake debhelper" >&2 + exit 1 + } +done + +# --- build the binary .deb ------------------------------------------------- +# -us don't sign the source +# -uc don't sign the .changes file +# -b build a binary package only (no upstream source tarball needed) +# -d don't verify Build-Depends (we check the tools ourselves) +# +# dpkg-buildpackage writes the .deb into the PARENT directory. +dpkg-buildpackage -us -uc -b -d + +# --- collect the artifacts into ./dist -------------------------------------- +mkdir -p dist +mv -f ../hatsune-miku-shoshitsu_*.deb dist/ 2>/dev/null || true +mv -f ../hatsune-miku-shoshitsu_*.changes dist/ 2>/dev/null || true + +echo +echo "Done. Debian package built:" +ls -lh dist/*.deb diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..467d79a --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +hatsune-miku-shoshitsu (0.1.0-1) unstable; urgency=medium + + * Initial packaging for Debian-based distributions. + + -- Your Name Sun, 30 Aug 2026 10:00:00 +0000 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..b1bd38b --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +13 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..784cd40 --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: hatsune-miku-shoshitsu +Section: utils +Priority: optional +Maintainer: Your Name +Build-Depends: debhelper (>= 13), cmake (>= 3.16), g++ (>= 8) +Standards-Version: 4.6.2 +Homepage: https://example.com/hatsune-miku-shoshitsu + +Package: hatsune-miku-shoshitsu +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Hatsune Miku's Shoshitsu in Terminal + A terminal-based program about Hatsune Miku's Shoshitsu (loss). + . + This is a placeholder description. Replace it with a real one before + releasing the package. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..5ec113f --- /dev/null +++ b/debian/copyright @@ -0,0 +1,28 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: hatsune-miku-shoshitsu +Upstream-Contact: Your Name +Source: https://example.com/hatsune-miku-shoshitsu + +Files: * +Copyright: 2026 Your Name +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. + +# Adjust the license above (or remove it) to match the license you actually +# want to distribute this project under. diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..93f6721 --- /dev/null +++ b/debian/install @@ -0,0 +1 @@ +usr/bin/hatsune-miku-shoshitsu diff --git a/debian/rules b/debian/rules new file mode 100644 index 0000000..393af14 --- /dev/null +++ b/debian/rules @@ -0,0 +1,7 @@ +#!/usr/bin/make -f + +%: + dh $@ + +override_dh_auto_configure: + dh_auto_configure -- -DCMAKE_BUILD_TYPE=Release diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..f60d287 --- /dev/null +++ b/main.cpp @@ -0,0 +1,13 @@ +// Hatsune Miku's Shoshitsu in Terminal +// +// Placeholder program so the project compiles and can be packaged as a .deb. +// Replace the body with the real application. + +#include + +int main() +{ + std::cout << "Hatsune Miku's Shoshitsu in Terminal\n"; + std::cout << "This is a placeholder. Build the real thing here!\n"; + return 0; +} diff --git a/pack-deb.sh b/pack-deb.sh new file mode 100644 index 0000000..5471585 --- /dev/null +++ b/pack-deb.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# +# Minimal fallback: assemble a .deb directly with dpkg-deb, WITHOUT debhelper. +# Handy for quick builds on a bare Debian/Ubuntu system: +# +# sudo apt install build-essential cmake +# ./pack-deb.sh +# +# Produces ./dist/hatsune-miku-shoshitsu_0.1.0-1_amd64.deb +# +set -euo pipefail +cd "$(dirname "$0")" + +PKG="hatsune-miku-shoshitsu" +VERSION="0.1.0" +ARCH="amd64" # adjust to your target architecture (e.g. arm64) + +for tool in cmake dpkg-deb; do + command -v "$tool" >/dev/null 2>&1 || { + echo "error: '$tool' not found. Install build tools first." >&2 + exit 1 + } +done + +rm -rf build staging dist +mkdir -p dist + +# 1) configure + build +cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr +cmake --build build -j + +# 2) install into a staging tree (simulates /usr on the target system) +DESTDIR="$(pwd)/staging" cmake --install build + +# 3) write the binary-package control file +mkdir -p "staging/DEBIAN" +cat > "staging/DEBIAN/control" < +Depends: libc6 +Description: Hatsune Miku's Shoshitsu in Terminal + A terminal-based program about Hatsune Miku's Shoshitsu (loss). + Replace this placeholder description before releasing. +EOF + +# 4) pack it (--root-owner-group makes every file owned by root:root, +# as Debian packages require; available since dpkg 1.19 / Debian 10) +dpkg-deb --build --root-owner-group "staging" "dist/${PKG}_${VERSION}-1_${ARCH}.deb" + +echo +echo "Done. Debian package built:" +ls -lh "dist/${PKG}_${VERSION}-1_${ARCH}.deb"