Compare commits

..

No commits in common. "3f625d08dbc7c73f544c743d8f89bb426eb7cb22" and "00def5a0874d5475ccfe7b7c3185a940475fafa8" have entirely different histories.

17 changed files with 63 additions and 188 deletions

View file

@ -5,12 +5,11 @@ LIBEXECDIR = $(PREFIX)/libexec/portzap
SHAREDIR = $(PREFIX)/share/portzap
install:
install -d $(BINDIR) $(LIBEXECDIR) $(LIBEXECDIR)/commands $(LIBEXECDIR)/utils $(LIBEXECDIR)/setup $(SHAREDIR) $(MANDIR)
install -d $(BINDIR) $(LIBEXECDIR) $(LIBEXECDIR)/commands $(LIBEXECDIR)/utils $(SHAREDIR) $(MANDIR)
install -m 0755 bin/portzap $(BINDIR)
install -m 0755 bin/setup-portzap $(BINDIR)
install -m 0755 libexec/portzap/commands/* $(LIBEXECDIR)/commands
install -m 0755 libexec/portzap/utils/* $(LIBEXECDIR)/utils
install -m 0755 libexec/portzap/setup/* $(LIBEXECDIR)/setup
install -m 0644 share/portzap/* $(SHAREDIR)
install -m 0644 man/man8/portzap.8 $(MANDIR)
@ -25,4 +24,3 @@ shellcheck:
shellcheck bin/*
shellcheck libexec/portzap/utils/*
shellcheck libexec/portzap/commands/*
shellcheck libexec/portzap/setup/*

View file

@ -41,8 +41,8 @@ the first time:
#### Environment
* __$PORTZAP\_CLONEURL__ <br>
The URL of a git repository <br>
* __$PORTZAP\_GITURL__ <br>
The URL to a git repository <br>
Default: https://git.HardenedBSD.org/HardenedBSD/ports.git
* __$PORTZAP\_INSTALLDIR__ <br>
@ -51,26 +51,27 @@ the first time:
## Install
#### Package
**Port**
portzap is available
[from the HardenedBSD ports tree](https://git.HardenedBSD.org/HardenedBSD/ports/-/tree/HardenedBSD/main/hardenedbsd/portzap). <br>
[as a HardenedBSD port](https://git.HardenedBSD.org/HardenedBSD/ports/-/tree/HardenedBSD/main/hardenedbsd/portzap). <br>
`pkg install portzap` should work too but expect slower updates.
#### Git
**Source**
The most recent version of portzap can be installed via git:
The most recent version of portzap can be installed directly
via git:
user@localhost$ git clone https://git.hardenedbsd.org/0x1eef/portzap.git
user@localhost$ git clone https://github.com/0x1eef/portzap.git
user@localhost$ cd portzap
root@localhost# make install
root@localhost# root make install
root@localhost# setup-portzap
root@localhost# pw groupmod -n _portzap -m <user>
## Requirements
* [doas](https://man.openbsd.org/doas)
* [git](https://www.man7.org/linux/man-pages/man1/git.1.html)
* [doas](https://man.openbsd.org/doas) (`pkg install doas`)
* [git](https://www.man7.org/linux/man-pages/man1/git.1.html) (`pkg install git`)
## Sources

View file

@ -6,20 +6,18 @@ set -e
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/..)}
libexec="${localbase}"/libexec/portzap
gitdir="/home/_portzap/ports"
giturl="${PORTZAP_CLONEURL:-https://git.hardenedbsd.org/hardenedbsd/ports.git}"
giturl="${PORTZAP_GITURL:-https://git.hardenedbsd.org/hardenedbsd/ports.git}"
installdir="${PORTZAP_INSTALLDIR:-/usr/ports}"
defaultbranch="hardenedbsd/main"
revfile="${installdir}"/.portzap
##
# functions
printerr()
{
printerr() {
"${libexec}"/utils/printerr "$1"
}
require_dependency()
{
require_dependency() {
deps=$1
for dep in $deps; do
if ! which -s "$dep"; then

View file

@ -5,16 +5,16 @@ set -e
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/..)}
libexec="${localbase}"/libexec/portzap
conf=$(cat "${localbase}"/share/portzap/doas.conf)
doas="${localbase}"/etc/doas.conf
##
# functions
printok()
{
printok() {
"${libexec}"/utils/printok "$1"
}
printerr()
{
printerr() {
"${libexec}"/utils/printerr "$1"
}
@ -33,12 +33,15 @@ else
-m \
-s /sbin/nologin
chmod u=rwX,g=rX,o= /home/_portzap/
printok "_portzap user created"
printok "create _portzap user"
fi
"${libexec}"/setup/setup-doas
"${libexec}"/setup/setup-cron
echo
echo "If you haven't already, add users to the _portzap group: "
echo "root@$(hostname)# pw groupmod -n _portzap -m user1,user2"
echo
if grep -F "^${conf}$" "${doas}" > /dev/null 2>&1; then
printok "${doas} is up to date"
else
echo "$conf" >> "$doas"
printok "update ${doas} (note: review the update)"
fi
printf "Add user(s) to the _portzap group:\n"
printf "root# pw groupmod -n _portzap -m user1,user2\n"

View file

@ -5,8 +5,8 @@ set -e
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/portzap
gitdir=$1
branch=$2
gitdir="$1"
branch="$2"
##
# functions
@ -16,11 +16,11 @@ gitexec()
}
printok() {
"${libexec}"/utils/printok "${1}"
"${libexec}"/utils/printok "$1"
}
printerr() {
"${libexec}"/utils/printerr "${1}"
"${libexec}"/utils/printerr "$1"
}
##

View file

@ -17,11 +17,11 @@ gitexec()
}
printok() {
"${libexec}"/utils/printok "${1}"
"${libexec}"/utils/printok "$1"
}
printerr() {
"${libexec}"/utils/printerr "${1}"
"${libexec}"/utils/printerr "$1"
}
##

View file

@ -55,15 +55,15 @@ perform_install()
run_install()
{
install -o root -g _portzap -m "${mode}" -v "${@}"
install -o root -g _portzap -m "${mode}" -v "$@"
}
printok() {
"${libexec}"/utils/printok "${1}"
"${libexec}"/utils/printok "$1"
}
printerr() {
"${libexec}"/utils/printerr "${1}"
"${libexec}"/utils/printerr "$1"
}
##

View file

@ -15,11 +15,11 @@ gitexec()
}
printok() {
"${libexec}"/utils/printok "${1}"
"${libexec}"/utils/printok "$1"
}
printerr() {
"${libexec}"/utils/printerr "${1}"
"${libexec}"/utils/printerr "$1"
}
##

View file

@ -25,7 +25,7 @@ erase()
}
printerr() {
"${libexec}"/utils/printerr "${1}"
"${libexec}"/utils/printerr "$1"
}
##

View file

@ -1,84 +0,0 @@
#!/bin/sh
set -e
##
# variables
user="_portzap"
localbase=$(realpath "$(dirname "$0")"/../../..)
libexec="${localbase}"/libexec/portzap
sharedir="${localbase}"/share/portzap
##
# functions
printok()
{
"${libexec}"/utils/printok "$1"
}
printerr()
{
"${libexec}"/utils/printerr "$1"
}
verify_allowfile()
{
allowfile="/var/cron/allow"
if [ -e "${allowfile}" ]; then
if grep -Eqe "^${user}$" "${allowfile}"; then
printok "${user} found in ${allowfile}"
else
printerr "add ${user} to ${allowfile} in order to proceed"
exit 1
fi
else
printok "${allowfile} not found"
fi
}
verify_denyfile()
{
denyfile="/var/cron/deny"
if [ -e "${denyfile}" ]; then
if grep -Eqe "^${user}$" "${denyfile}"; then
printerr "remove ${user} from ${denyfile} in order to proceed"
exit 1
else
printok "${user} not found in ${denyfile}"
fi
else
printok "${denyfile} not found"
fi
}
install_crontab()
{
src="${sharedir}/crontab"
dest="/var/cron/tabs/${user}"
if [ -e "${dest}" ]; then
yes | crontab -u "${user}" -r
printok "crontab removed (${dest})"
fi
crontab -u "${user}" "${src}"
chmod u=rw,g=,o= "${dest}"
printok "crontab installed (${dest})"
}
##
# main
echo -n "configure portzap to run via cron(8) ? yes or no: "
while read -r r; do
case "${r}" in
yes|YES)
verify_allowfile
verify_denyfile
install_crontab
break
;;
no|NO)
break
;;
*)
echo -n "yes or no: "
;;
esac
done

View file

@ -1,36 +0,0 @@
#!/bin/sh
set -e
##
# variables
localbase=$(realpath "$(dirname "$0")"/../../..)
libexec="${localbase}/libexec/portzap"
sharedir="${localbase}/share/portzap"
##
# functions
printok()
{
"${libexec}"/utils/printok "$1"
}
printerr()
{
"${libexec}"/utils/printerr "$1"
}
install_doasconf()
{
src="${sharedir}/doas.conf"
dest="${localbase}/etc/doas.conf"
if grep -Fq "$(cat "${src}")" "${dest}"; then
printok "doas.conf looks up to date"
else
cat "${src}" >> "${dest}"
printok "${dest} has been updated"
fi
}
##
# main
install_doasconf

View file

@ -10,13 +10,15 @@ commit=$2
##
# functions
diff()
gitexec()
{
"${libexec}"/utils/gitdiff ${@}
"${libexec}"/utils/gitexec "${1}"
}
##
# main
cd "${gitdir}"
diff "--name-only" "--diff-filter=A" "${commit}" "HEAD"
diff "--name-only" "--diff-filter=M" "${commit}" "HEAD"
add=$(gitexec "diff --name-only --diff-filter=A ${commit} HEAD")
mod=$(gitexec "diff --name-only --diff-filter=M ${commit} HEAD")
echo "${add}"
echo "${mod}"

View file

@ -10,12 +10,12 @@ commit=$2
##
# functions
diff()
gitexec()
{
"${libexec}"/utils/gitdiff ${@}
"${libexec}"/utils/gitexec "${1}"
}
##
# main
cd "${gitdir}"
diff "--name-only" "--diff-filter=D" "${commit}" "HEAD"
gitexec "diff --name-only --diff-filter=D ${commit} HEAD"

View file

@ -1,11 +0,0 @@
#!/bin/sh
set -e
##
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/portzap
##
# main
"${libexec}"/utils/gitexec diff -l0 ${@}

View file

@ -5,11 +5,16 @@
.Nm portzap
.Nd manages a copy of the HardenedBSD ports tree
.Sh SYNOPSIS
.Nm portzap clone
.Nm portzap pull
.Nm portzap checkout
.Nm portzap install
.Nm portzap rm
.br
portzap clone
.br
portzap pull
.br
portzap checkout
.br
portzap install
.br
portzap rm
.Sh DESCRIPTION
.Nm portzap
manages a copy of the HardenedBSD ports tree.
@ -53,9 +58,9 @@ This command requires root privileges
.Sh ENVIRONMENT
.sp
.sp
.Nm PORTZAP_CLONEURL
.Nm PORTZAP_GITURL
.br
The URL of a git repository
The URL to a git repository
.br
Default: https://git.HardenedBSD.org/HardenedBSD/ports.git
.sp

View file

@ -1 +1 @@
v0.12.0
v0.11.5

View file

@ -1 +0,0 @@
0 0 * * * /usr/local/bin/portzap pull