diff --git a/debian/README.md b/debian/README.md new file mode 100644 index 00000000..c27458bf --- /dev/null +++ b/debian/README.md @@ -0,0 +1,143 @@ +Building the dkms package: + +``` +user@plug:/home/user/$ git clone https://github.com/fgbreel/mars.git && cd mars + +user@plug:/home/user/mars$ git checkout debian/sid + +user@plug:/home/user/mars$ gbp buildpackage --git-pristine-tar --git-pristine-tar-commit --git-upstream-tag='mars%(version)s' --git-debian-branch=debian/sid -us -uc +gbp:info: Creating /home/user/mars_0.1astable114.orig.tar.gz +gbp:info: Performing the build + dpkg-buildpackage -us -uc -ui -i -I +dpkg-buildpackage: info: source package mars +dpkg-buildpackage: info: source version 0.1astable114-1 +dpkg-buildpackage: info: source distribution unstable +dpkg-buildpackage: info: source changed by Gabriel Francisco + dpkg-source -i -I --before-build . +dpkg-buildpackage: info: host architecture amd64 + fakeroot debian/rules clean +dh clean --with dkms + debian/rules override_dh_auto_clean +make[1]: Entering directory '/home/user/mars' +make[1]: Leaving directory '/home/user/mars' + dh_clean + dpkg-source -i -I -b . +dpkg-source: info: using source format '3.0 (quilt)' +dpkg-source: info: building mars using existing ./mars_0.1astable114.orig.tar.gz +dpkg-source: info: building mars in mars_0.1astable114-1.debian.tar.xz +dpkg-source: info: building mars in mars_0.1astable114-1.dsc + debian/rules build +dh build --with dkms + dh_update_autotools_config + dh_autoreconf + create-stamp debian/debhelper-build-stamp + fakeroot debian/rules binary +dh binary --with dkms + dh_testroot + dh_prep + debian/rules override_dh_install +make[1]: Entering directory '/home/user/mars' +cp debian/mars-Makefile kernel/Makefile +cp debian/mars-Kbuild kernel/Kbuild +dh_install scripts/gen_config.pl usr/src/mars-0.1astable114/ +dh_install kernel/* usr/src/mars-0.1astable114/ +make[1]: Leaving directory '/home/user/mars' + dh_installdocs + dh_installchangelogs + dh_installman + dh_installcron + debian/rules override_dh_dkms +make[1]: Entering directory '/home/user/mars' +dh_dkms -V 0.1astable114 +make[1]: Leaving directory '/home/user/mars' + dh_perl + dh_link + dh_strip_nondeterminism + dh_compress + dh_fixperms + dh_missing + dh_strip + dh_makeshlibs + dh_shlibdeps + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb +dpkg-deb: building package 'mars-dkms' in '../mars-dkms_0.1astable114-1_amd64.deb'. +dpkg-deb: building package 'mars-tools' in '../mars-tools_0.1astable114-1_amd64.deb'. + dpkg-genbuildinfo + dpkg-genchanges >../mars_0.1astable114-1_amd64.changes +dpkg-genchanges: info: including full source code in upload + dpkg-source -i -I --after-build . +dpkg-buildpackage: info: full upload (original source is included) +``` + +Installing on target computer: + +``` +root@plug:/home/user# apt install ./mars-dkms_0.1astable114-1_amd64.deb +Reading package lists... Done +Building dependency tree +Reading state information... Done +Note, selecting 'mars-dkms' instead of './mars-dkms_0.1astable114-1_amd64.deb' +The following NEW packages will be installed: + mars-dkms +0 upgraded, 1 newly installed, 0 to remove and 100 not upgraded. +Need to get 0 B/223 kB of archives. +After this operation, 1144 kB of additional disk space will be used. +Get:1 /home/user/mars-dkms_0.1astable114-1_amd64.deb mars-dkms amd64 0.1astable114-1 [223 kB] +Selecting previously unselected package mars-dkms. +(Reading database ... 222033 files and directories currently installed.) +Preparing to unpack .../mars-dkms_0.1astable114-1_amd64.deb ... +Unpacking mars-dkms (0.1astable114-1) ... +Setting up mars-dkms (0.1astable114-1) ... +Loading new mars-0.1astable114 DKMS files... +Building for 4.9.0-13-amd64 +Building initial module for 4.9.0-13-amd64 +Done. + +mars.ko: +Running module version sanity check. + - Original module + - No original module exists within this kernel + - Installation + - Installing to /lib/modules/4.9.0-13-amd64/updates/dkms/ + +depmod... + +DKMS: install completed. + +root@plug:/home/user# stat /lib/modules/4.9.0-13-amd64/updates/dkms/mars.ko + File: /lib/modules/4.9.0-13-amd64/updates/dkms/mars.ko + Size: 861440 Blocks: 1688 IO Block: 4096 regular file +Device: fe01h/65025d Inode: 525826 Links: 1 +Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) +Access: 2020-11-19 18:20:55.082662798 +0100 +Modify: 2020-11-19 18:20:54.862664958 +0100 +Change: 2020-11-19 18:20:54.862664958 +0100 + Birth: - +``` + +Return from `dmesg` from target computer: + +``` +root@plug:/home/user# fallocate -l 10G foo +root@plug:/home/user# losetup -f foo +root@plug:/home/user# vgcreate mars /dev/loop0 +root@plug:/home/user# lvcreate -n mars -L 9G mars +root@plug:/home/user# mkfs -t ext4 /dev/mapper/mars-mars +root@plug:/home/user# mount /dev/mapper/mars-mars /mars/ +root@plug:/home/user# modprobe mars + +root@plug:/home/user# dmesg | tail +[44413.535164] Cluster UUID is missing. Mount /mars/, and/or say {create,join}-cluster afterwwards. +[44413.535172] loading MARS, BUILDTAG=no-buildtag-available BUILDHOST=user@plug BUILDDATE=2020-11-20 03:31:33 +[44413.590445] crc32c digest duration = 56001256 ns +[44413.633954] crc32 digest duration = 44000989 ns +[44413.929130] sha1 digest duration = 296006661 ns +[44414.185517] md5old digest duration = 256005761 ns +[44414.449394] md5 digest duration = 264005939 ns +[44414.484375] lzo compress duration = 36000810 ns +[44414.526621] lz4 compress duration = 40000900 ns +[44415.499954] zlib compress duration = 976021964 ns +``` diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..cedc6f94 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +mars (0.1astable114-1) unstable; urgency=medium + + * Initial release (Closes: #nnnn) + + -- Gabriel Francisco Thu, 19 Nov 2020 01:02:34 +0000 diff --git a/debian/compat b/debian/compat new file mode 100644 index 00000000..b4de3947 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +11 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..baa593fa --- /dev/null +++ b/debian/control @@ -0,0 +1,31 @@ +Source: mars +Section: misc +Priority: optional +Maintainer: Gabriel Francisco +Build-Depends: debhelper (>= 11), dkms +Standards-Version: 4.1.3 +Homepage: http://schoebel.github.io/mars/ +#Vcs-Browser: https://salsa.debian.org/debian/sample +#Vcs-Git: https://salsa.debian.org/debian/sample.git + +Package: mars-dkms +Architecture: any +Depends: ${misc:Depends}, ${perl:Depends} +Description: mars kernel module. + MARS Light is a block-level storage replication solution implemented + in the form of a Linux kernel module. + . + It's almost a drop-in replacement for DRBD but it works + asynchronously and over arbitrary distances using a technology + similar to transaction logging of database systems. + +Package: mars-tools +Architecture: any +Depends: ${misc:Depends}, ${perl:Depends} +Description: mars userspace tools. + MARS Light is a block-level storage replication solution implemented + in the form of a Linux kernel module. + . + It's almost a drop-in replacement for DRBD but it works + asynchronously and over arbitrary distances using a technology + similar to transaction logging of database systems. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..43f73b2a --- /dev/null +++ b/debian/copyright @@ -0,0 +1,31 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: mars +Source: https://github.com/schoebel/mars + +Files: * +Copyright: 2010-2014 Thomas Schoebel-Theuer + 2011-2014 1&1 Internet AG +License: GPL-2+ + 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 2 of the License, or + (at your option) any later version. + +Files: debian/* +Copyright: 2020 Gabriel Francisco +License: GPL-2+ + 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 2 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 + . + On Debian systems, the complete text of the GNU General + Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". diff --git a/debian/mars-Kbuild b/debian/mars-Kbuild new file mode 100644 index 00000000..e5d0ae20 --- /dev/null +++ b/debian/mars-Kbuild @@ -0,0 +1,77 @@ +# +# Makefile for MARS +# + +KBUILD_CFLAGS += -fdelete-null-pointer-checks + +obj-$(if $(KBUILD_EXTMOD),m,$(CONFIG_MARS)) := mars.o + +mars-y := \ + lamport.o \ + brick_say.o \ + brick_mem.o \ + brick.o \ + mars_generic.o \ + lib_log.o \ + lib_rank.o \ + lib_limiter.o \ + lib_timing.o \ + lib_mapfree.o \ + mars_net.o \ + mars_server.o \ + mars_client.o \ + mars_aio.o \ + mars_sio.o \ + mars_bio.o \ + mars_if.o \ + mars_copy.o \ + mars_trans_logger.o \ + sy_old/sy_generic.o \ + sy_old/sy_net.o \ + sy_old/mars_proc.o \ + sy_old/mars_main.o + +ifdef CONFIG_DEBUG_KERNEL + +KBUILD_CFLAGS += -fno-inline-functions -fno-inline-small-functions -fno-inline-functions-called-once + +# This is currently not really used. +# We urge people to maintain it by including it in debug versions +# (so the compiler may throw any complaints) + +mars-y += \ + mars_dummy.o \ + mars_check.o \ + mars_buf.o \ + mars_usebuf.o \ + +endif + +extra-y := mars_config.h buildtag.h + +$(obj)/buildtag.h: + exec > $@;\ + /bin/echo -e "/* Automatically generated -- DO NOT EDIT! */";\ + if [ "$$MARSVERSION" != "" ]; then \ + BUILDTAG="$$MARSVERSION"; \ + elif git describe --tags >/dev/null 2>&1; then \ + BUILDTAG="$$(git describe --tags)"; \ + elif [ -e DISTVERSION ]; then \ + BUILDTAG=$$(cat DISTVERSION); \ + else \ + BUILDTAG="no-buildtag-available"; \ + fi; \ + /bin/echo -e "#define BUILDTAG \"$$BUILDTAG\"";\ + /bin/echo -e "#define BUILDHOST \"$$USER@`hostname`\"";\ + /bin/echo -e "#define BUILDDATE \"$$(date '+%F %T')\"" + cat $@; + +GEN_CONFIG_SCRIPT := $(obj)/gen_config.pl +$(obj)/mars_config.h: + $(kecho) "building $@ ..." + if [ ! -x $(GEN_CONFIG_SCRIPT) ]; then \ + $(kecho) "MARS: cannot execute script $(GEN_CONFIG_SCRIPT)"; \ + /bin/false; \ + fi; \ + cat $(src)/Kconfig | $(GEN_CONFIG_SCRIPT) 2>/dev/null > $@; + cat $@ diff --git a/debian/mars-Makefile b/debian/mars-Makefile new file mode 100644 index 00000000..a4acbe0a --- /dev/null +++ b/debian/mars-Makefile @@ -0,0 +1,97 @@ +# +# Makefile for out-of-tree build of MARS module +# +# +# By Benjamin Kübler +# +# usage make [ KDIR =/path/to/kernel/source ] +# +obj-$(CONFIG_MARS) += mars.o + +mars-objs := \ + lamport.o \ + brick_say.o \ + brick_mem.o \ + brick.o \ + mars_generic.o \ + lib_log.o \ + lib_rank.o \ + lib_limiter.o \ + lib_timing.o \ + lib_mapfree.o \ + mars_net.o \ + mars_server.o \ + mars_client.o \ + mars_aio.o \ + mars_sio.o \ + mars_bio.o \ + mars_if.o \ + mars_copy.o \ + mars_trans_logger.o \ + sy_old/sy_generic.o \ + sy_old/sy_net.o \ + sy_old/mars_proc.o \ + sy_old/mars_main.o + +ifneq ($(KERNELRELEASE),) + +# in-tree-build process +include Kbuild + +else +# out-of-tree-build process + +MARSSRC := $(shell pwd) +DESTDIR ?= / +KDIR ?= /lib/modules/$(shell uname -r)/build + +.PHONY: greeting install default clean config + +default: mars_config.h + $(MAKE) -C $(KDIR) M=$(PWD) modules + +greeting: + @echo "Building MARS Module again: KDIR=$(KDIR)" ; + @if ! test -e $(KDIR)/Makefile ; then \ + echo -e "Sorry, kernel makefile not found. You need to tell me a correct KDIR!\n" ; \ + false; \ + fi + +clean: + $(MAKE) -C $(KDIR) M=$(PWD) clean + +config: + $(MAKE) -C $(KDIR) M=$(PWD) config + +install: + $(MAKE) -C $(KDIR) M=$(PWD) modules_install + +extra-y := buildtag.h +buildtag.h: + exec > $@;\ + /bin/echo -e "/* Automatically generated -- DO NOT EDIT! */";\ + if [ "$$MARSVERSION" != "" ]; then \ + BUILDTAG="$$MARSVERSION"; \ + elif git describe --tags >/dev/null 2>&1; then \ + BUILDTAG="$$(git describe --tags)"; \ + elif [ -e DISTVERSION ]; then \ + BUILDTAG=$$(cat DISTVERSION); \ + else \ + BUILDTAG="no-buildtag-available"; \ + fi; \ + /bin/echo -e "#define BUILDTAG \"$$BUILDTAG\"";\ + /bin/echo -e "#define BUILDHOST \"$$USER@`hostname`\"";\ + /bin/echo -e "#define BUILDDATE \"$$(date '+%F %T')\"" + cat $@; + +extra-y += mars_config.h +GEN_CONFIG_SCRIPT := $(MARSSRC)/gen_config.pl +mars_config.h: buildtag.h + if [ ! -x $(GEN_CONFIG_SCRIPT) ]; then \ + $(kecho) "MARS: cannot execute script $(GEN_CONFIG_SCRIPT)"; \ + /bin/false; \ + fi; \ + cat $(MARSSRC)/Kconfig | $(GEN_CONFIG_SCRIPT) 2>/dev/null > $@; + cat $@; + +endif diff --git a/debian/mars-dkms.dkms b/debian/mars-dkms.dkms new file mode 100644 index 00000000..8b70e529 --- /dev/null +++ b/debian/mars-dkms.dkms @@ -0,0 +1,5 @@ +PACKAGE_NAME="mars" +PACKAGE_VERSION="0.1astable144" +BUILT_MODULE_NAME[0]="$PACKAGE_NAME" +DEST_MODULE_LOCATION[0]="/kernel/drivers/block" +AUTOINSTALL="yes" diff --git a/debian/mars-dkms.postinst b/debian/mars-dkms.postinst new file mode 100644 index 00000000..ee661d25 --- /dev/null +++ b/debian/mars-dkms.postinst @@ -0,0 +1,26 @@ +#!/bin/sh +set -e + +#DEBHELPER# + +case "$1" in + install) + ;; + + configure|reconfigure) + # Get the version of the current loaded module: + old_version="$(cat /sys/module/mars/version 2>/dev/null)" || exit 0 + # Get the version of the latest available module: + new_version="$(modinfo -F version mars 2>/dev/null)" || exit 0 + # See if the new one is actually newer: + dpkg --compare-versions "$old_version" lt "$new_version" || exit 0 + # Trigger an update notification that recommends a reboot: + touch /run/reboot-required || true + grep -Fqsx mars-dkms /run/reboot-required.pkgs || \ + echo mars-dkms >> /run/reboot-required.pkgs || true + ;; + *) + ;; +esac + +exit 0 diff --git a/debian/mars-tools.cron.d b/debian/mars-tools.cron.d new file mode 100644 index 00000000..31c0f5c7 --- /dev/null +++ b/debian/mars-tools.cron.d @@ -0,0 +1,10 @@ +# Regular cron jobs for MARS +# + +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +# MARS transaction logfile rotation + deletion every x minutes + +*/10 * * * * root if [ -L /mars/uuid ] ; then marsadm cron ; fi > /dev/null 2>&1 +*/5,15,25,35,45,55 * * * * root if [ -L /mars/uuid ] ; then marsadm log-delete-all all ; fi > /dev/null 2>&1 + diff --git a/debian/mars-tools.install b/debian/mars-tools.install new file mode 100644 index 00000000..d676017c --- /dev/null +++ b/debian/mars-tools.install @@ -0,0 +1 @@ +userspace/marsadm usr/sbin diff --git a/debian/mars-tools.manpages b/debian/mars-tools.manpages new file mode 100644 index 00000000..ab2e42b9 --- /dev/null +++ b/debian/mars-tools.manpages @@ -0,0 +1 @@ +userspace/marsadm.8 diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..737636a9 --- /dev/null +++ b/debian/rules @@ -0,0 +1,35 @@ +#!/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 + +include /usr/share/dpkg/default.mk + +%: + dh $@ --with dkms + +override_dh_install: + cp debian/mars-Makefile kernel/Makefile + cp debian/mars-Kbuild kernel/Kbuild + dh_install scripts/gen_config.pl usr/src/mars-$(DEB_VERSION_UPSTREAM)/ + dh_install kernel/* usr/src/mars-$(DEB_VERSION_UPSTREAM)/ + +override_dh_dkms: + dh_dkms -V $(DEB_VERSION_UPSTREAM) + +override_dh_auto_configure: +override_dh_auto_build: +override_dh_auto_test: +override_dh_auto_install: +override_dh_auto_clean: + @git checkout -- kernel + diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 00000000..163aaf8d --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt)