Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
diff sbin/ftjail @ 308:2102b46566f0
Implement "ftjail build-etcupdate-curent-tmpl".
This allows to build a current tree suitable for using with etcupdate's default
and extract modes: allow updating a system without having a corresponding
source tree.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 23 Sep 2022 00:37:33 +0200 |
| parents | 23bcbbbd99ea |
| children | 8dbd11726ee5 |
line wrap: on
line diff
--- a/sbin/ftjail Tue Sep 20 09:16:13 2022 +0200 +++ b/sbin/ftjail Fri Sep 23 00:37:33 2022 +0200 @@ -42,6 +42,8 @@ copy-skel [-A] [-L] [-M MOUNTPOINT] [-P] [-u] SOURCE-DS SNAPSHOT-NAME TARGET-DS + build-etcupdate-current-tmpl DIRECTORY TARBALL + ENVIRONMENT: All environment variables that affect "zfs" are effective also. @@ -765,6 +767,26 @@ } +#: +#: Implement the "build-etcupdate-current-tmpl" command +#: +command_build_etcupdate_current_tmpl() { + local _directory _tarball + + _directory="${1-}" + _tarball="${2-}" + + [ -z "${_directory}" ] && { echo "ERROR: no directory given" 1>&2; return 2; } + [ -z "${_tarball}" ] && { echo "ERROR: no directory given" 1>&2; return 2; } + [ -e "${_tarball}" ] && { echo "ERROR: \`${_tarball}' exists already" 1>&2; return 1; } + + if ! tar -cjf "${_tarball}" -C "${_directory}/var/db/etcupdate/current" . ; then + rm -f "${_tarball}" || true + return 1 + fi +} + + # # Global option handling # @@ -822,6 +844,9 @@ copy-skel) command_copy_skel "$@" ;; + build-etcupdate-current-tmpl) + command_build_etcupdate_current_tmpl "$@" + ;; configure) echo "ERROR: use \`fjail configure' instead" 1>&2; exit 2
