From 4fe253da0fda8da7c4d28260aa33f82673a6de33 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sat, 11 May 2024 20:19:45 -0300 Subject: [PATCH] Rename project (srczap -> sourcezap) --- Makefile | 24 +++++----- README.md | 46 +++++++++---------- bin/setup-sourcezap | 37 +++++++++++++++ bin/setup-srczap | 37 --------------- bin/{srczap => sourcezap} | 24 +++++----- .../{srczap => sourcezap}/git-changed-files | 2 +- .../{srczap => sourcezap}/git-removed-files | 2 +- libexec/{srczap => sourcezap}/git-rev | 2 +- .../issourcezap-member} | 2 +- .../sourcezap-clone} | 8 ++-- .../sourcezap-erase} | 0 .../sourcezap-install} | 2 +- .../srczap-pull => sourcezap/sourcezap-pull} | 8 ++-- man/man8/{srczap.8 => sourcezap.8} | 44 +++++++++--------- share/{srczap => sourcezap}/VERSION | 0 share/sourcezap/doas.conf | 4 ++ share/srczap/doas.conf | 4 -- 17 files changed, 123 insertions(+), 123 deletions(-) create mode 100755 bin/setup-sourcezap delete mode 100755 bin/setup-srczap rename bin/{srczap => sourcezap} (63%) rename libexec/{srczap => sourcezap}/git-changed-files (93%) rename libexec/{srczap => sourcezap}/git-removed-files (91%) rename libexec/{srczap => sourcezap}/git-rev (88%) rename libexec/{srczap/issrczap-member => sourcezap/issourcezap-member} (87%) rename libexec/{srczap/srczap-clone => sourcezap/sourcezap-clone} (73%) rename libexec/{srczap/srczap-erase => sourcezap/sourcezap-erase} (100%) rename libexec/{srczap/srczap-install => sourcezap/sourcezap-install} (96%) rename libexec/{srczap/srczap-pull => sourcezap/sourcezap-pull} (84%) rename man/man8/{srczap.8 => sourcezap.8} (56%) rename share/{srczap => sourcezap}/VERSION (100%) create mode 100644 share/sourcezap/doas.conf delete mode 100644 share/srczap/doas.conf diff --git a/Makefile b/Makefile index 8712562..be92d27 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,24 @@ PREFIX = /usr/local BINDIR = $(PREFIX)/bin MANDIR = $(PREFIX)/man/man8 -LIBEXECDIR = $(PREFIX)/libexec/srczap -SHAREDIR = $(PREFIX)/share/srczap +LIBEXECDIR = $(PREFIX)/libexec/sourcezap +SHAREDIR = $(PREFIX)/share/sourcezap install: install -d $(BINDIR) $(LIBEXECDIR) $(SHAREDIR) $(MANDIR) - install -m 0755 bin/srczap $(BINDIR) - install -m 0755 bin/setup-srczap $(BINDIR) - install -m 0755 libexec/srczap/* $(LIBEXECDIR) - install -m 0644 share/srczap/* $(SHAREDIR) - install -m 0644 man/man8/srczap.8 $(MANDIR) + install -m 0755 bin/sourcezap $(BINDIR) + install -m 0755 bin/setup-sourcezap $(BINDIR) + install -m 0755 libexec/sourcezap/* $(LIBEXECDIR) + install -m 0644 share/sourcezap/* $(SHAREDIR) + install -m 0644 man/man8/sourcezap.8 $(MANDIR) deinstall: - rm $(BINDIR)/srczap - rm $(BINDIR)/setup-srczap - rm $(MANDIR)/srczap.8 + rm $(BINDIR)/sourcezap + rm $(BINDIR)/setup-sourcezap + rm $(MANDIR)/sourcezap.8 rm -rf $(LIBEXECDIR) rm -rf $(SHAREDIR) shellcheck: - shellcheck bin/srczap - shellcheck libexec/srczap/* + shellcheck bin/sourcezap + shellcheck libexec/sourcezap/* diff --git a/README.md b/README.md index 854f3d1..1188d84 100644 --- a/README.md +++ b/README.md @@ -15,38 +15,38 @@ the first time: # Add the '_srczap' user, group and home directory # This command requires root privileges - # setup-srczap + # setup-sourcezap -### CLI: srczap +### CLI: sourcezap - # Clone the HardenedBSD source tree into /home/_srczap/src/ - # This command is delegated to the '_srczap' user - $ srczap clone + # Clone the HardenedBSD source tree into /home/_sourcezap/src/ + # This command is delegated to the '_sourcezap' user + $ sourcezap clone - # Pull updates into /home/_srczap/src/ - # This command is delegated to the '_srczap' user - $ srczap pull + # Pull updates into /home/_sourcezap/src/ + # This command is delegated to the '_sourcezap' user + $ sourcezap pull - # Install /home/_srczap/src/ into /usr/src/ + # Install /home/_sourcezap/src/ into /usr/src/ # This command requires root privileges - # srczap install + # sourcezap install - # Start over: erase /usr/src/ and /home/_srczap/src/ + # Start over: erase /usr/src/ and /home/_sourcezap/src/ # This command requires root privileges - $ srczap erase + $ sourcezap erase ### ENVIRONMENT -* __$SRCZAP\_GITURL__
+* __$SOURCEZAP\_GITURL__
The URL to a git repository.
Default: https://git.HardenedBSD.org/HardenedBSD/HardenedBSD.git. -* __$SRCZAP\_BRANCH__
+* __$SOURCEZAP\_BRANCH__
The git branch to clone and pull updates from.
Default: hardened/14-stable/master. -* __$SRCZAP\_INSTALLDIR__
+* __$SOURCEZAP\_INSTALLDIR__
The directory where the source tree will be installed.
Default: /usr/src/. @@ -54,14 +54,14 @@ the first time: **Source** -The most recent version of srczap can be installed directly +The most recent version of sourcezap can be installed directly via git: - $ git clone https://github.com/0x1eef/srczap.git - $ cd srczap + $ git clone https://github.com/0x1eef/sourcezap.git + $ cd sourcezap # make install - # setup-srczap - # pw groupmod -n _srczap -m + # setup-sourcezap + # pw groupmod -n _sourcezap -m ## Requirements @@ -70,9 +70,9 @@ via git: ## Sources -* [GitHub](https://github.com/0x1eef/srczap) -* [GitLab](https://gitlab.com/0x1eef/srczap) -* [git.HardenedBSD.org](https://git.HardenedBSD.org/0x1eef/srczap) +* [GitHub](https://github.com/0x1eef/sourcezap) +* [GitLab](https://gitlab.com/0x1eef/sourcezap) +* [git.HardenedBSD.org](https://git.HardenedBSD.org/0x1eef/sourcezap) ## License diff --git a/bin/setup-sourcezap b/bin/setup-sourcezap new file mode 100755 index 0000000..999da5d --- /dev/null +++ b/bin/setup-sourcezap @@ -0,0 +1,37 @@ +#!/bin/sh +set -e + +## +# variables +localbase="${LOCALBASE:-/usr/local}" +conf=$(cat "${localbase}"/share/sourcezap/doas.conf) +doas="${localbase}"/etc/doas.conf + +## +# main +if [ "$(id -u)" != "0" ]; then + echo "[x] This command must be run by root" + exit 1 +fi + +if id -u _sourcezap > /dev/null 2>&1; then + echo "[-] The _sourcezap user exists" + echo "[-] Add user(s) to the _sourcezap group:" + echo "root# pw groupmod -n _sourcezap -m user1,user2" +else + pw useradd -n _sourcezap \ + -c "sourcezap user" \ + -m \ + -s /sbin/nologin + chmod u=rwX,g=rX,o= /home/_sourcezap/ + echo "[-] The _sourcezap user, group and home directory have been created." + echo "[-] Add user(s) to the _sourcezap group:" + echo "root# pw groupmod -n _sourcezap -m user1,user2" +fi + +if grep -F "^${conf}$" "${doas}" > /dev/null 2>&1; then + echo "[-] No changes made to ${doas}" +else + echo "$conf" >> "$doas" + echo "[-] ${doas} has been changed. Please review the changes" +fi diff --git a/bin/setup-srczap b/bin/setup-srczap deleted file mode 100755 index f876b13..0000000 --- a/bin/setup-srczap +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -set -e - -## -# variables -localbase="${LOCALBASE:-/usr/local}" -conf=$(cat "${localbase}"/share/srczap/doas.conf) -doas="${localbase}"/etc/doas.conf - -## -# main -if [ "$(id -u)" != "0" ]; then - echo "[x] This command must be run by root" - exit 1 -fi - -if id -u _srczap > /dev/null 2>&1; then - echo "[-] The _srczap user exists" - echo "[-] Add user(s) to the _srczap group:" - echo "root# pw groupmod -n _srczap -m user1,user2" -else - pw useradd -n _srczap \ - -c "srczap user" \ - -m \ - -s /sbin/nologin - chmod u=rwX,g=rX,o= /home/_srczap/ - echo "[-] The _srczap user, group and home directory have been created." - echo "[-] Add user(s) to the _srczap group:" - echo "root# pw groupmod -n _srczap -m user1,user2" -fi - -if grep -F "^${conf}$" "${doas}" > /dev/null 2>&1; then - echo "[-] No changes made to ${doas}" -else - echo "$conf" >> "$doas" - echo "[-] ${doas} has been changed. Please review the changes" -fi diff --git a/bin/srczap b/bin/sourcezap similarity index 63% rename from bin/srczap rename to bin/sourcezap index 1d60ba5..bc52285 100755 --- a/bin/srczap +++ b/bin/sourcezap @@ -4,12 +4,12 @@ set -e ## # variables localbase="${LOCALBASE:-/usr/local}" -gitdir="/home/_srczap/src" +gitdir="/home/_sourcezap/src" giturl="${SRCZAP_GITURL:-https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git}" branch="${SRCZAP_BRANCH:-hardened/14-stable/master}" installdir="${SRCZAP_INSTALLDIR:-/usr/src}" -revision="${installdir}"/.srczap -libexec="${localbase}"/libexec/srczap +revision="${installdir}"/.sourcezap +libexec="${localbase}"/libexec/sourcezap ## # functions @@ -27,10 +27,10 @@ require_dependency() { # main i=1 while [ "${i}" -le "$#" ]; do - eval "_srczap_option=\$${i}" + eval "_sourcezap_option=\$${i}" # shellcheck disable=SC2154 - if [ "${_srczap_option}" = "-v" ]; then - cat "${localbase}"/share/srczap/VERSION + if [ "${_sourcezap_option}" = "-v" ]; then + cat "${localbase}"/share/sourcezap/VERSION exit 0 fi # shellcheck disable=SC2003 @@ -40,26 +40,26 @@ done case $1 in "clone") require_dependency "git doas" - "${libexec}"/srczap-clone "${giturl}" "${gitdir}" "${branch}" + "${libexec}"/sourcezap-clone "${giturl}" "${gitdir}" "${branch}" ;; "pull") require_dependency "git doas" - "${libexec}"/srczap-pull "${gitdir}" "${branch}" + "${libexec}"/sourcezap-pull "${gitdir}" "${branch}" ;; "erase") - "${libexec}"/srczap-erase "${gitdir}" "${installdir}" + "${libexec}"/sourcezap-erase "${gitdir}" "${installdir}" ;; "install") require_dependency "git doas" - "${libexec}"/srczap-install "${gitdir}" "${installdir}" "${revision}" + "${libexec}"/sourcezap-install "${gitdir}" "${installdir}" "${revision}" ;; *) - printf "Usage: srczap COMMAND [OPTIONS]\n" + printf "Usage: sourcezap COMMAND [OPTIONS]\n" printf "\n" printf "Commands:\n" printf " clone Clone the HardenedBSD source tree\n" printf " pull Pull source tree updates\n" - printf " erase Erase /usr/src/ and /home/_srczap/src/\n" + printf " erase Erase /usr/src/ and /home/_sourcezap/src/\n" printf " install Install the source tree into /usr/src/\n" ;; esac diff --git a/libexec/srczap/git-changed-files b/libexec/sourcezap/git-changed-files similarity index 93% rename from libexec/srczap/git-changed-files rename to libexec/sourcezap/git-changed-files index e853a9f..16b948c 100644 --- a/libexec/srczap/git-changed-files +++ b/libexec/sourcezap/git-changed-files @@ -13,7 +13,7 @@ mode=u=rwX,g=rX,o= # functions gitexec() { - doas -n -u _srczap \ + doas -n -u _sourcezap \ /bin/sh -c "umask ${mode}; ${git} ${1}" } diff --git a/libexec/srczap/git-removed-files b/libexec/sourcezap/git-removed-files similarity index 91% rename from libexec/srczap/git-removed-files rename to libexec/sourcezap/git-removed-files index 3ab177f..6603ff1 100644 --- a/libexec/srczap/git-removed-files +++ b/libexec/sourcezap/git-removed-files @@ -13,7 +13,7 @@ mode=u=rwX,g=rX,o= # functions gitexec() { - doas -n -u _srczap \ + doas -n -u _sourcezap \ /bin/sh -c "umask ${mode}; ${git} ${1}" } diff --git a/libexec/srczap/git-rev b/libexec/sourcezap/git-rev similarity index 88% rename from libexec/srczap/git-rev rename to libexec/sourcezap/git-rev index e35d6f7..48e1cdb 100644 --- a/libexec/srczap/git-rev +++ b/libexec/sourcezap/git-rev @@ -11,7 +11,7 @@ mode=u=rwX,g=rX,o= # functions gitexec() { - doas -n -u _srczap \ + doas -n -u _sourcezap \ /bin/sh -c "umask ${mode}; ${git} ${1}" } diff --git a/libexec/srczap/issrczap-member b/libexec/sourcezap/issourcezap-member similarity index 87% rename from libexec/srczap/issrczap-member rename to libexec/sourcezap/issourcezap-member index d8d63dc..e0bad3b 100644 --- a/libexec/srczap/issrczap-member +++ b/libexec/sourcezap/issourcezap-member @@ -1,7 +1,7 @@ #!/bin/sh set -e -group="_srczap" +group="_sourcezap" if id -Gn | \ tr ' ' '\n' | \ grep -e "^${group}$" \ diff --git a/libexec/srczap/srczap-clone b/libexec/sourcezap/sourcezap-clone similarity index 73% rename from libexec/srczap/srczap-clone rename to libexec/sourcezap/sourcezap-clone index 5bafcd1..990e28b 100755 --- a/libexec/srczap/srczap-clone +++ b/libexec/sourcezap/sourcezap-clone @@ -15,20 +15,20 @@ mode=u=rwX,g=rX,o= # functions gitexec() { - doas -n -u _srczap \ + doas -n -u _sourcezap \ /bin/sh -c "umask ${mode}; ${git} ${1}" } ## # main -if ! "${libexec}"/issrczap-member; then - echo "[x] This command must be run by a member of the '_srczap' group" +if ! "${libexec}"/issourcezap-member; then + echo "[x] This command must be run by a member of the '_sourcezap' group" exit 1 fi if [ -e "${gitdir}/.git" ]; then echo "[x] ${gitdir} exists." - echo "[x] Try 'srczap pull'" + echo "[x] Try 'sourcezap pull'" exit 1 fi diff --git a/libexec/srczap/srczap-erase b/libexec/sourcezap/sourcezap-erase similarity index 100% rename from libexec/srczap/srczap-erase rename to libexec/sourcezap/sourcezap-erase diff --git a/libexec/srczap/srczap-install b/libexec/sourcezap/sourcezap-install similarity index 96% rename from libexec/srczap/srczap-install rename to libexec/sourcezap/sourcezap-install index 1bead03..be76a61 100755 --- a/libexec/srczap/srczap-install +++ b/libexec/sourcezap/sourcezap-install @@ -60,7 +60,7 @@ perform_install() run_install() { - install -o root -g _srczap -m "${mode}" -v "$@" + install -o root -g _sourcezap -m "${mode}" -v "$@" } ## diff --git a/libexec/srczap/srczap-pull b/libexec/sourcezap/sourcezap-pull similarity index 84% rename from libexec/srczap/srczap-pull rename to libexec/sourcezap/sourcezap-pull index e5cf1dc..86aa7ee 100755 --- a/libexec/srczap/srczap-pull +++ b/libexec/sourcezap/sourcezap-pull @@ -14,7 +14,7 @@ mode="u=rwX,g=rX,o=" # functions gitexec() { - doas -n -u _srczap \ + doas -n -u _sourcezap \ /bin/sh -c "umask ${mode}; ${git} ${1}" } @@ -38,15 +38,15 @@ change_branch() ## # main -if ! "${libexec}"/issrczap-member; then - echo "[x] This command must be run by a member of the '_srczap' group" +if ! "${libexec}"/issourcezap-member; then + echo "[x] This command must be run by a member of the '_sourcezap' group" exit 1 fi if [ ! -e "${gitdir}/.git" ]; then set +x echo "[x] ${gitdir} is not a valid git repository." - echo "[x] Try 'srczap clone'" + echo "[x] Try 'sourcezap clone'" exit 1 fi diff --git a/man/man8/srczap.8 b/man/man8/sourcezap.8 similarity index 56% rename from man/man8/srczap.8 rename to man/man8/sourcezap.8 index 20a4278..4a1e758 100644 --- a/man/man8/srczap.8 +++ b/man/man8/sourcezap.8 @@ -1,68 +1,68 @@ .Dd May 2023 -.Dt SRCZAP 8 +.Dt SOURCEZAP 8 .Os .Sh NAME -.Nm srczap +.Nm sourcezap .Nd manages a copy of the HardenedBSD source tree .Sh SYNOPSIS .br -srczap clone +sourcezap clone .br -srczap pull +sourcezap pull .br -srczap install +sourcezap install .br -srczap erase +sourcezap erase .Sh DESCRIPTION -.Nm srczap +.Nm sourcezap manages a copy of the HardenedBSD source tree. The copy of the source tree is maintained by members of -the '_srczap' group, and a copy of the source tree +the '_sourcezap' group, and a copy of the source tree can be installed into /usr/src/ by root. .Sh EXAMPLES .sp .sp -.Nm srczap clone +.Nm sourcezap clone .br -Clone the HardenedBSD source tree into /home/_srczap/src/. +Clone the HardenedBSD source tree into /home/_sourcezap/src/. .br -This command is delegated to the '_srczap' user. +This command is delegated to the '_sourcezap' user. .Pp -.Nm srczap pull +.Nm sourcezap pull .br -Pull updates into /home/_srczap/src/. +Pull updates into /home/_sourcezap/src/. .br -This command is delegated to the '_srczap' user. +This command is delegated to the '_sourcezap' user. .Pp -.Nm srczap install +.Nm sourcezap install .br -Install /home/_srczap/src/ into /usr/src/. +Install /home/_sourcezap/src/ into /usr/src/. .br This command requires root privileges. .Pp -.Nm srczap erase +.Nm sourcezap erase .br -Start over: erase /usr/src/ and /home/_srczap/src/. +Start over: erase /usr/src/ and /home/_sourcezap/src/. .br This command requires root privileges. .br .Sh ENVIRONMENT .sp .sp -.Nm SRCZAP_GITURL +.Nm SOURCEZAP_GITURL .br The URL to a git repository. .br Default: https://git.HardenedBSD.org/HardenedBSD/HardenedBSD.git/ .sp -.Nm SRCZAP_BRANCH +.Nm SOURCEZAP_BRANCH .br The git branch to clone and pull updates from. .br Default: hardened/14-stable/master .br .sp -.Nm SRCZAP_INSTALLDIR +.Nm SOURCEZAP_INSTALLDIR .br The directory where the ports collection will be installed. .br @@ -70,6 +70,6 @@ Default: /usr/src/ .sp .Sh AUTHORS The -.Nm srczap +.Nm sourcezap utility and this manual page were written by 0x1eef <0x1eef@protonmail.com>. diff --git a/share/srczap/VERSION b/share/sourcezap/VERSION similarity index 100% rename from share/srczap/VERSION rename to share/sourcezap/VERSION diff --git a/share/sourcezap/doas.conf b/share/sourcezap/doas.conf new file mode 100644 index 0000000..7c79a27 --- /dev/null +++ b/share/sourcezap/doas.conf @@ -0,0 +1,4 @@ +## +# sourcezap +permit nopass root as _sourcezap cmd /bin/sh +permit nopass :_sourcezap as _sourcezap cmd /bin/sh diff --git a/share/srczap/doas.conf b/share/srczap/doas.conf deleted file mode 100644 index c51359a..0000000 --- a/share/srczap/doas.conf +++ /dev/null @@ -1,4 +0,0 @@ -## -# srczap -permit nopass root as _srczap cmd /bin/sh -permit nopass :_srczap as _srczap cmd /bin/sh