Skip to content

Commit

Permalink
Build debian package
Browse files Browse the repository at this point in the history
  • Loading branch information
rafael-santiago committed Aug 2, 2023
1 parent 04066f6 commit 29a5829
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
**/lib/*
**/bin/*
**/deb/*
**/debian/.debhelper
**/debian/debhelper-build-stamp
**/debian/macgonuts
**/debian/macgonuts.substvars
**/debian/files
*.Forgefile-*
*.o/
coverage.info
21 changes: 21 additions & 0 deletions doc/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fresh ``macgonuts`` binary to get your stuff done, you can give ``the low-cost b
- [Extracting code coverage](#extracting-code-coverage)
- [List of all build options](#list-of-all-build-options)
- [Installing the command line tool](#installing-the-command-line-tool)
- [Building the debian package](#building-the-debian-package)

## Getting newest macgonuts source code revision

Expand Down Expand Up @@ -204,6 +205,7 @@ Take a look at **Table 1** to know all build options supported by the ``Hefesto`
| ``--coverage`` | flag | Runs coverage build task |
|``--genhtml-outpath``| value | Specifies a file path for the ``LCOV`` coverage report |
| ``--toolset`` | value | Specifies the name of wanted compiler, can being ``gcc`` or ``clang`` |
| ``--debian-pkg`` | flag | Runs the debian packaging build task |

[``Back``](#topics)

Expand All @@ -222,3 +224,22 @@ you@somewhere-over-the-rainbow:~/macgonuts/src# hefesto --uninstall
```

[``Back``](#topics)

## Building the debian package

The ``debian`` package can be built through the ``developer's`` build or through the ``low-cost`` build.
The ``package`` is created in the toplevel ``deb`` sub-directory.

By using the ``developer's`` build and being into ``src`` sub-directory, you need to invoke ``Hefesto`` as follows:

```
you@somewhere-over-the-rainbow:~/macgonuts/src# hefesto --debian-pkg
```

By using the ``low-cost`` build and being into ``src`` sub-directory, you need to run ``make`` as follows:

```
you@somewhere-over-the-rainbow:~/macgonuts/src# make deb
```

[``Back``](#topics)
3 changes: 2 additions & 1 deletion src/Forgefile.hsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ macgonuts-static-lib.preloading() {
}

macgonuts-static-lib.prologue() {
installer();
set_rootdir(".");
installer();
debian_packer();
if (build("accacia") != 0) {
hefesto.project.abort(1);
}
Expand Down
8 changes: 7 additions & 1 deletion src/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,20 @@ $(OBJDIR)/%.o: %.c

clean:
@rm -rf .o
@rm $(LIBDIR)/$(BINARY)
@rm -f $(LIBDIR)/$(BINARY)

install:
@mkdir -p /usr/local/bin && cp ../bin/macgonuts /usr/local/bin &&\
mkdir -p /usr/local/man/man1 && cp ../doc/man1/macgonuts.1 /usr/local/man/man1/macgonuts.1 &&\
mkdir -p $(MACGONUTS_SHARE_DIR)/etc && cp ../etc/hoax $(MACGONUTS_SHARE_DIR)/etc/hoax &&\
cp ../etc/oui $(MACGONUTS_SHARE_DIR)/etc/oui
@echo installed.

uninstall:
@rm /usr/local/bin/macgonuts && rm /usr/local/man/man1/macgonuts.1 && rm -rf $(MACGONUTS_SHARE_DIR)
@echo uninstalled.

deb:
@mkdir -p ../deb
@dpkg-buildpackage -uc -us --pre-clean -j1
@mv ../macgonuts*.* ../deb
13 changes: 13 additions & 0 deletions src/build/toolsets.hsl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ function installer() : result type none {
}
}

function debian_packer() : result type none {
var option type list;
$option = hefesto.sys.get_option("debian-pkg");
if ($option.count() > 0) {
hefesto.project.abort(build("debian_pkg"));
}
}

function build_projects(projects type list) : result type int {
if ($projects.count() == 0) {
hefesto.sys.echo("ERROR: No projects to build.\n");
Expand Down Expand Up @@ -477,3 +485,8 @@ local function build_uninstall() : result type int {

result 0;
}

local function build_debian_pkg() : result type int {
mktree(hefesto.sys.make_path(get_rootdir(), "../deb"));
result hefesto.sys.run("dpkg-buildpackage -uc -us --pre-clean -j1 && mv ../macgonuts*.* ../deb");
}
4 changes: 4 additions & 0 deletions src/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
macgonuts (1) stable; urgency=low
* Initial build
First package based on `macgonuts-v1`.
-- Rafael Santiago <voidbrainvoid@tutanota.com> Mon, 31 Jul 2023 10:54:36 +0000
1 change: 1 addition & 0 deletions src/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
20 changes: 20 additions & 0 deletions src/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Source: macgonuts
Section: hacking-tools
Priority: extra
Maintainer: Rafael Santiago <voidbrainvoid@tutanota.com>
Build-Depends: debhelper (>= 10.0.0)
Standards-Version: 3.9.3
Vcs-Git: git@github.com:rafael-santiago/macgonuts.git
Vcs-Browser: http://github.com/rafael-santiago/macgonuts

Package: macgonuts
Section: hacking-tools
Priority: extra
Architecture: any
Depends: ${shlibs:Depends}
Description: An ARP/NDP swiss army knife to make MAC going nuts
Macgonuts is an ARP/NDP swiss army knife to make MAC addresses going nuts on networks around!
It supports IPv4/ARP and IPv6/NDP. It intends to bring you all in a shell. Anything related to
spoof layer-2 addresses can be done elegantly with a single f_cking nice non-scripted tool, a
badass executable without clumsy zillions of dependencies. Suckless is the key here, but simple
in a non-hollow-claimed-simple is what we try to deliver here.
32 changes: 32 additions & 0 deletions src/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Files: *
Copyright:
License: BSD-4
Copyright (c) 2022, Rafael Santiago
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the Rafael Santiago and
contributors.
4. Neither the name of the Rafael Santiago nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4 changes: 4 additions & 0 deletions src/debian/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
../bin/macgonuts usr/local/bin
../doc/man1/macgonuts.1 usr/share/man/man1
../etc/hoax usr/share/macgonuts/etc
../etc/oui usr/share/macgonuts/etc
13 changes: 13 additions & 0 deletions src/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/make -f
%:
@dh $@

override_dh_auto_make:
make -j1

#override_dh_auto_clean:
# @make clean

override_dh_usrlocal:
rm /usr/local/bin/macgonuts
rm /usr/local/man/man1/macgonuts.1

0 comments on commit 29a5829

Please sign in to comment.