comparison sbin/fjail @ 346:3b2935985c73

Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 05 Dec 2022 09:37:53 +0100
parents 4a17b1f4c378
children 673505e96cea
comparison
equal deleted inserted replaced
345:1fa72d63ae08 346:3b2935985c73
131 else 131 else
132 _ve_mount="${_mountpoint}/var/empty" 132 _ve_mount="${_mountpoint}/var/empty"
133 fi 133 fi
134 134
135 _get_dataset_for_mountpoint "${_ve_mount}" 135 _get_dataset_for_mountpoint "${_ve_mount}"
136 }
137
138
139 #:
140 #: Check whether a FreeBSD version at a given location matches the userland
141 #: version of the host where the current process run.
142 #:
143 #: Args:
144 #: $1: the location where to check for
145 #:
146 #: Returns:
147 #: 0 if the userland versions match, 1 otherwise
148 #:
149 #: Exit:
150 #: 1 on fatal errors (e.g. /bin/freebsd-version not found or errors)
151 #:
152 _has_same_userland_version() {
153 local directory
154
155 local _host_version _directory_version
156
157 directory="$1"
158
159 _host_version=$(/bin/freebsd-version -u) || exit 1
160 _directory_version=$(chroot "${directory}" /bin/freebsd-version -u) || exit 1
161 if [ "${_host_version%%-*}" = "${_directory_version%%-*}" ]; then
162 return 0
163 fi
164 return 1
136 } 165 }
137 166
138 167
139 # 168 #
140 # "datasets" -- create the ZFS dataset tree 169 # "datasets" -- create the ZFS dataset tree