Skip to content

Commit

Permalink
Merge branch 'autotoolize'
Browse files Browse the repository at this point in the history
  • Loading branch information
xxc3nsoredxx committed Jun 22, 2021
2 parents 2f7f8c7 + 657d709 commit a674eca
Show file tree
Hide file tree
Showing 7 changed files with 622 additions and 6 deletions.
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
# Include directories
!*/

# Include Makefiles
!Makefile
!makefile

# Include LICENSE
!LICENSE

# Begin actual ignores
# Autotools
Makefile.in
aclocal.m4
autom4te.cache/
config.*
*.tar.*
misc-utils-*/

*.o
*.ko
*.so
Expand Down
7 changes: 7 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if WANT_SNAPSHOTS
SNAPSHOTS = snapshots
endif

SUBDIRS = $(SNAPSHOTS)

EXTRA_DIST = README.md LICENSE
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
# misc-utils
A collection of miscellaneous little utils that I don't feel deserve a full repo.

### Autotoolization in progress
This repo is slowly being packaged by Autotools.

**Note:** All of the following utils present in the repo or tarball in their final form are configured to use the `/usr/local` prefix with the exception of `--sysconfdir=/etc`.
If installing using Autotools, make sure to specify the system config directory.

Currently autotoolized:
* snapshots

### Installing
Run:
```bash
./configure --sysconfdir=PATH_TO_SYSTEM_CONFIG_DIR
make
make install
```

By default all utils are enabled and will be built/installed.
To selectively leave out `util` run:
```bash
./configure --disable-util
```

The relevant option for each util is listed in its description below.
Alternatively, to see a full list of configure options run:
```bash
./configure --help
```

### ebuild in progress
The whole reason for autotoolizing the repo is that I can write a nice ebuild for it.

## cross\_arm
Creates an ARM cross-compiler toolchain.
Originally created for a class that dealt with ARM binaries in some assignments.
Expand Down Expand Up @@ -89,11 +121,15 @@ This one is retained in order to maintain a common base between the source and d
* `sys-fs/btrfs-progs`

### Requirements (transfer mode)
* An implementation of `udev`
* `sys-fs/cryptsetup`
* A drive set up with BTRFS in a LUKS2 container
* Encrypted using a key-file instead of password input
* `SS_CRYPT` as the label given in the LUKS2 header

### Configure options
* `--enable-snapshots`

## userscripts
A collection of scripts loaded into [Greasemonkey](https://www.greasespot.net).

Expand Down
36 changes: 36 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- autoconf -*-
# Process this file with autoconf to produce a configure script.

# TODO: Autotoolize the udev rule to specify configurable crypt name

m4_define([misc-utils-VERSION], [0.1])
AC_PREREQ([2.69])
AC_INIT([xxc3nsoredxx Miscellaneous Utilities],
m4_defn([misc-utils-VERSION]),
[https://github.com/xxc3nsoredxx/misc-utils/issues],
[misc-utils])
AC_CONFIG_SRCDIR([snapshots/snapshots.sh.in])

# use --program-transform-name='<sed program>'
# eg. --program-transform-name='s/.sh$//' to remove .sh suffix
AC_ARG_PROGRAM

AC_ARG_ENABLE([snapshots],
[AS_HELP_STRING([--enable-snapshots],
[Enables the BTRFS snapshot management scripts])],
[want_snapshots="$enableval"],
[want_snapshots="yes"])

AM_CONDITIONAL([WANT_SNAPSHOTS],
[test "x$want_snapshots" = "xyes"])

AM_INIT_AUTOMAKE([foreign subdir-objects -Wall -Werror])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([snapshots/Makefile])

# Warn if nothing is enabled
AS_CASE(["x$want_snapshots"],
[x*yes*], [],
[AC_MSG_WARN([nothing selected for build/install])])

AC_OUTPUT
21 changes: 21 additions & 0 deletions snapshots/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
configdir = $(sysconfdir)/misc-utils
udevdir = $(sysconfdir)/udev/rules.d

dist_bin_SCRIPTS = snapshots.sh
dist_config_DATA = snapshots.conf
dist_udev_DATA = 99-ss_crypt.rules

CLEANFILES = $(dist_bin_SCRIPTS)
EXTRA_DIST = snapshots.sh.in 99-ss_crypt.rules

edit = sed \
-e 's|@configdir[@]|$(configdir)|g'

snapshots.sh: $(srcdir)/snapshots.sh.in Makefile
rm -f $@ $@.tmp
srcdir=''; \
test -f ./$@.in || srcdir=$(srcdir)/; \
$(edit) $${srcdir}$@.in > $@.tmp
chmod +x $@.tmp
chmod a-w $@.tmp
mv $@.tmp $@
10 changes: 8 additions & 2 deletions snapshots/snapshots.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /bin/bash
# Final script generated by automake from snapshots/snapshots.sh.in

# BTRFS snapshot management script
# Copyright (C) 2020-2021 xxc3nsoredxx
Expand Down Expand Up @@ -28,7 +29,12 @@ declare -A TAKE_SUBVOLUMES
declare -A XFER_SUBVOLUMES

# Import config file
. snapshots.conf
CONFIG_FILE='/etc/misc-utils/snapshots.conf'
if [ ! -f "$CONFIG_FILE" ]; then
echo "!!! Config file not found: '$CONFIG_FILE'"
exit 1
fi
. /etc/misc-utils/snapshots.conf

################################################################################
# Common variables
Expand Down Expand Up @@ -310,7 +316,7 @@ while getopts ':hlnpst' args; do
usage
;;
l)
sed -nEe '3,+14 {s/^# *//; p}' "$0"
sed -nEe '4,+14 {s/^# *//; p}' "$0"
exit 1
;;
n)
Expand Down
Loading

0 comments on commit a674eca

Please sign in to comment.