Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add make deb target for debian package #116

Merged
merged 2 commits into from
Jan 2, 2025
Merged
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
4 changes: 4 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ if ENABLE_TESTS
endif

EXTRA_DIST = diod.spec

export DEB_BUILD_OPTIONS ?= nocheck terse
deb: debian scripts/debbuild.sh
+@$(top_srcdir)/scripts/debbuild.sh $(abs_top_srcdir)
Empty file added debian/README.Debian
Empty file.
Empty file added debian/README.source
Empty file.
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
17 changes: 17 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Source: diod
Section: devel
Priority: optional
Maintainer: Jim Garlick <[email protected]>
Standards-Version: 4.1.2
Build-Depends:
debhelper (>= 10),
libncurses-dev,
libpopt-dev,
lua5.1,
liblua5.1-dev

Homepage: https://github.com/chaos/diod
Package: diod
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: 9P server
27 changes: 27 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Files: *
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: diod
Source: <https://github.com/chaos/diod>

Files: *
Copyright: 2010 Lawrence Livermore National Security, LLC
License: GPL-2+

Files: debian/*
Copyright: 2024 Jim Garlick <[email protected]>
License: GPL-3+
This package 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 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 General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
1 change: 1 addition & 0 deletions debian/diod-docs.docs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.Debian
28 changes: 28 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

%:
dh $@

override_dh_auto_configure:
dh_auto_configure -- --with-systemdsystemunitdir=/lib/systemd/system

override_dh_autoreconf:
@echo not running autogen.sh on dist product

override_dh_auto_install:
dh_auto_install
mkdir -p debian/diod/sbin
ln -s /usr/sbin/diodmount debian/diod/sbin/mount.diod
ln -s diodmount.8.gz debian/diod/usr/share/man/man8/mount.diod.8.gz
1 change: 1 addition & 0 deletions debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
41 changes: 41 additions & 0 deletions scripts/debbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh
PACKAGE=diod
USER=$(git config --get user.name)
DEBFULLNAME=$USER
EMAIL=$(git config --get user.email)
DEBEMAIL=$EMAIL

SRCDIR=${1:-$(pwd)}

die() { echo "debbuild: $@" >&2; exit 1; }
log() { echo "debbuild: $@"; }

test -z "$USER" && die "User name not set in git-config"
test -z "$EMAIL" && die "User email not set in git-config"

log "Running make dist"
make dist >/dev/null || exit 1

log "Building package from latest dist tarball"
tarball=$(ls -tr *.tar.gz | tail -1)
version=$(echo $tarball | sed "s/${PACKAGE}-\(.*\)\.tar\.gz/\1/")

rm -rf debbuild
mkdir -p debbuild && cd debbuild

mv ../$tarball .

log "Unpacking $tarball"
tar xvfz $tarball >/dev/null

log "Creating debian directory and files"
cd ${PACKAGE}-${version}
cp -a ${SRCDIR}/debian . || die "failed to copy debian dir"

export DEBEMAIL DEBFULLNAME
log "Creating debian/changelog"
dch --create --package=$PACKAGE --newversion $version build tree release

log "Running debian-buildpackage -b"
dpkg-buildpackage -b
log "Check debbuild directory for results"
15 changes: 15 additions & 0 deletions scripts/install-deps-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

apt install \
autoconf \
automake \
make \
pkg-config \
libc6-dev \
libpopt-dev \
libncurses-dev \
lua5.1 \
liblua5.1-dev \
valgrind

# to build test DEBs you need devscripts and debhelper too
11 changes: 4 additions & 7 deletions src/libnpfs/np.c
Original file line number Diff line number Diff line change
Expand Up @@ -1704,14 +1704,11 @@ np_deserialize_p9dirent(Npqid *qid, u64 *offset, u8 *type,
*type = buf_get_int8(bufp);
buf_get_str(bufp, &s9);

if (s9.len > 0)
snprintf (name, namelen, "%.*s", s9.len, s9.str);
else
name[0] = '\0';


if (buf_check_overflow (bufp))
if (buf_check_overflow (bufp) || s9.len >= namelen)
return 0;

memcpy (name, s9.str, s9.len);
name[s9.len] = '\0';

return bufp->p - bufp->sp;
}
Loading