changeset 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 88991b4731c9
files docs/conf.py docs/man/index8.rst docs/man/man8/ftjail-build-etcupdate-current-tmpl.rst docs/man/man8/ftjail.rst docs/man/man8/local-bsdtools.rst pkg-plist sbin/ftjail
diffstat 7 files changed, 73 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/docs/conf.py	Tue Sep 20 09:16:13 2022 +0200
+++ b/docs/conf.py	Fri Sep 23 00:37:33 2022 +0200
@@ -73,6 +73,7 @@
 man_pages = [
     ("man/man8/local-bsdtools", "local-bsdtools", 'FreeBSD administration helper tools v%s' % release, [author], 8),
     ("man/man8/ftjail", "ftjail", "Management of Thin Jails", [author], 8),
+    ("man/man8/ftjail-build-etcupdate-current-tmpl", "ftjail-build-etcupdate-current-tmpl", "Build a \"current\" tree suitable for the default and extract mode of \"etcupdate\"", [author], 8),    
     ("man/man8/ftjail-copy-skel", "ftjail-copy-skel", "Recursively copy skeleton contents", [author], 8),
     ("man/man8/ftjail-datasets-tmpl", "ftjail-datasets-tmpl", "Create ZFS datasets for new Thin Jails using base and skeleton", [author], 8),
     ("man/man8/ftjail-interlink-tmpl", "ftjail-interlink-tmpl", "Create proper symlinks for \"skeleton\" style Thin Jails", [author], 8),
--- a/docs/man/index8.rst	Tue Sep 20 09:16:13 2022 +0200
+++ b/docs/man/index8.rst	Fri Sep 23 00:37:33 2022 +0200
@@ -10,6 +10,7 @@
 
    man8/local-bsdtools
    man8/ftjail
+   man8/ftjail-build-etcupdate-current-tmpl
    man8/ftjail-copy-skel
    man8/ftjail-datasets-tmpl
    man8/ftjail-interlink-tmpl
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man/man8/ftjail-build-etcupdate-current-tmpl.rst	Fri Sep 23 00:37:33 2022 +0200
@@ -0,0 +1,39 @@
+.. -*- coding: utf-8; indent-tabs-mode: nil; -*-
+
+ftjail-build-etcupdate-current-tmpl
+===================================
+
+Synopsis
+--------
+
+**ftjail build-etcupdate-current-tmpl** `directory` `tarball`
+
+
+Description
+-----------
+
+Build a tarball in `tarball` of a "current" tree from the template
+mounted at `directory`.
+
+This tarball can be used by the default and extract modes of
+:command:`etcupdate`. Using a tarball can allow :command:`etcupdate`
+to perform a merge without requiring a source tree that matches the
+currently installed world.  The tarball argument specifies the name of
+the file to create.  The file will be a :manpage:`tar(5)` file compressed with
+:manpage:`bzip2(1)`.
+
+Within `directory` the default database locations are assumed. They are
+:file:`{directory}/var/db/etcupdate/current`.
+
+
+Environment
+-----------
+
+All environment variables that affect :manpage:`tar(1)` are effective also.
+
+
+See Also
+--------
+
+:manpage:`ftjail(8)`, :manpage:`etcupdate(8)`,
+:manpage:`tar(1)`, :manpage:`tar(5)`
--- a/docs/man/man8/ftjail.rst	Tue Sep 20 09:16:13 2022 +0200
+++ b/docs/man/man8/ftjail.rst	Fri Sep 23 00:37:33 2022 +0200
@@ -21,6 +21,11 @@
 Subcommands
 -----------
 
+:manpage:`ftjail-build-etcupdate-current-tmpl(8)`
+
+    Build a "current" tree suitable for the default and extract mode
+    of \"etcupdate\"
+
 :manpage:`ftjail-datasets-tmpl(8)`
 
     Create ZFS template datasets for new Thin Jails using base and skeleton
--- a/docs/man/man8/local-bsdtools.rst	Tue Sep 20 09:16:13 2022 +0200
+++ b/docs/man/man8/local-bsdtools.rst	Fri Sep 23 00:37:33 2022 +0200
@@ -16,6 +16,7 @@
 - :manpage:`fjail(8)`
 - :manpage:`ftjail(8)`
 
+  * :manpage:`ftjail-build-etcupdate-current-tmpl(8)`  
   * :manpage:`ftjail-copy-skel(8)`
   * :manpage:`ftjail-datasets-tmpl(8)`
   * :manpage:`ftjail-interlink-tmpl(8)`
--- a/pkg-plist	Tue Sep 20 09:16:13 2022 +0200
+++ b/pkg-plist	Fri Sep 23 00:37:33 2022 +0200
@@ -8,6 +8,7 @@
 sbin/fzfs
 %%DOCS%%man/man8/local-bsdtools.8.gz
 %%DOCS%%man/man8/ftjail.8.gz
+%%DOCS%%man/man8/ftjail-build-etcupdate-current-tmpl.8.gz
 %%DOCS%%man/man8/ftjail-copy-skel.8.gz
 %%DOCS%%man/man8/ftjail-datasets-tmpl.8.gz
 %%DOCS%%man/man8/ftjail-interlink-tmpl.8.gz
--- 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