From 3aaebdb964ecb228bfc161e822905013e8dacc27 Mon Sep 17 00:00:00 2001 From: Stefan Kreutz Date: Sun, 12 May 2024 21:49:47 +0200 Subject: Port to FreeBSD --- Makefile | 2 +- README.md | 20 +++++++++++++++----- configure | 5 +++++ jotpass.ksh | 10 ++++++++-- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 8f06eeb..2032192 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Portable makefile supporting OpenBSD and GNU/Linux. +# Portable makefile supporting OpenBSD, FreeBSD, and GNU/Linux. PREFIX = /usr/local INSTALL = install diff --git a/README.md b/README.md index 0eb149c..98950b2 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ The `jotpass` utility facilitates generating random passwords suitable for handwriting. See [this][intro] blog post for an introduction. -Jotpass' original source code is hosted [here][repo]. +The original source code is hosted [here][repo]. [intro]: https://www.skreutz.com/posts/readable-random-passwords-with-jot/ [repo]: https://git.skreutz.com/jotpass.git/ @@ -19,13 +19,23 @@ See the manual page for details. ## Dependencies -The `jotpass` utility depends on `ksh(1)`, `jot(1)`, and some base utilities -like `sed(1)`. +The `jotpass` utility depends on -On OpenBSD these are included in the default base installation. +* [OpenBSD][]'s public domain Korn shell, specifically, the portable version + [oksh][] +* `jot(1)` + +and several standard utilities such as `sed(1)`. + +On OpenBSD these are included in the default base installation: + + $ doas ln -s /bin/ksh /usr/local/bin/oksh + +On FreeBSD you can install the dependencies using `pkg-install(8)`: + + $ sudo pkg install oksh On Void Linux you can install the dependencies using `xbps-install(1)`: -follows: $ sudo xbps-install -S oksh outils coreutils bc sed diff --git a/configure b/configure index 9a1e936..c9b0f50 100755 --- a/configure +++ b/configure @@ -10,6 +10,11 @@ case "$( uname )" in echo 'BINGRP = bin' 1>&3 echo 'MANGRP = bin' 1>&3 ;; + FreeBSD) + echo 'BINGRP = wheel' 1>&3 + echo 'MANDIR = share/man/man' 1>&3 + echo 'MANGRP = wheel' 1>&3 + ;; Linux) echo 'BINMODE = 755' 1>&3 echo 'MANMODE = 644' 1>&3 diff --git a/jotpass.ksh b/jotpass.ksh index c1b14aa..4f3efe4 100755 --- a/jotpass.ksh +++ b/jotpass.ksh @@ -1,6 +1,7 @@ -#! /bin/ksh +#! /usr/bin/env oksh +# shellcheck shell=ksh -# Copyright (c) 2021 Stefan Kreutz +# Copyright (c) 2021, 2024 Stefan Kreutz # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -49,6 +50,11 @@ jot -r $((groups*width)) 0 $((symbols-1)) | fold -w "$width" | paste -s -d "$separator" - +if [ "$( uname )" == "FreeBSD" ] ; then + # FreeBSD's paste(1) swallows the final newline. + printf '\n' +fi + if [ $verbosity -gt 0 ]; then entropy="$( printf 'e = (%d * %d * l(%d))/l(2); scale = 0; e/1\n' "$groups" "$width" "$symbols" | bc -l )" print -u2 -- "The generated password has an entropy of ${entropy} bits." -- cgit v1.2.3