@@ -163,11 +163,12 @@ images_register()
163
163
fi
164
164
[ -r /tmp/images.$$ ] && ${RM_CMD} -f /tmp/images.$$
165
165
echo "Image name: ${_imgname}"
166
+ _imgshort=$( substr --pos=0 --len=12 --str="${_imgname}" )
166
167
if [ -n "${NOCOLOR}" ]; then
167
- ${BUILDAH_CMD} --root ${workdir}/basejail/buildah images | ${GREP_CMD} "${path }"
168
+ ${BUILDAH_CMD} --root ${workdir}/basejail/buildah images ${_imgname} | ${GREP_CMD} "${_imgshort }"
168
169
_ret=$?
169
170
else
170
- ${BUILDAH_CMD} --root ${workdir}/basejail/buildah images | ${ENV_CMD} GREP_COLORS='mt=37;45' GREP_COLOR='37;45' ${GREP_CMD} --colour=always "${path }"
171
+ ${BUILDAH_CMD} --root ${workdir}/basejail/buildah images ${_imgname} | ${ENV_CMD} GREP_COLORS='mt=37;45' GREP_COLOR='37;45' ${GREP_CMD} --colour=always "${_imgshort }"
171
172
_ret=$?
172
173
fi
173
174
@@ -215,7 +216,20 @@ images_register()
215
216
216
217
##ZFS
217
218
if [ ${zfsfeat} -eq 1 ]; then
218
- jcreate jname="${_md5}" host_hostname=${_md5}.my.domain ver=empty baserw=1 pkg_bootstrap=0 floatresolv=0 applytpl=0 etcupdate_init=0
219
+ _buildah_container_volume=$(${MOUNT_CMD} | ${AWK_CMD} '($2 == "on" && $3 == "'"${_imgpath}"'") { print $1; }')
220
+ if [ -z "$_buildah_container_volume" ]; then
221
+ ${ECHO} "${N1_COLOR}${CBSD_APP}: unable find zfs volume for ${_imgpath} ${N0_COLOR}"
222
+ exit 1
223
+ fi
224
+
225
+ _buildah_image_snapshot=$(${ZFS_CMD} get origin "${_buildah_container_volume}" | ${AWK_CMD} '($2 == "origin") {print $3;}')
226
+ if [ -z "${_buildah_image_snapshot}" ]; then
227
+ ${ECHO} "${N1_COLOR}${CBSD_APP}: unable find ZFS image orign for ${_buildah_container_volume} ${N0_COLOR}"
228
+ exit 1
229
+ fi
230
+
231
+ jcreate jname="${_md5}" host_hostname=${_md5}.my.domain zfs_snapsrc="${_buildah_image_snapshot}"\
232
+ ver=empty baserw=1 pkg_bootstrap=0 floatresolv=0 applytpl=0 etcupdate_init=0
219
233
_ret=$?
220
234
[ ${_ret} -ne 0 ] && err 1 "${N1_COLOR}${CBSD_APP}unable to create jail: ${N2_COLOR}jcreate jname="${_md5}" host_hostname=${_md5}.my.domain${N0_COLOR}"
221
235
_rootfs="${workdir}/jails-data/${_md5}-data"
@@ -227,7 +241,7 @@ images_register()
227
241
# create_from_srcsnap loop
228
242
. ${subrdir}/zfs.subr
229
243
DATA=$( ${ZFS_CMD} get -Ho value name ${jaildatadir} )
230
- ${RSYNC_CMD} -z -a --hard-links --links --acls --xattrs --numeric-ids --recursive --partial ${_imgpath}/ ${_rootfs}/
244
+
231
245
_zfssrc="${DATA}/${_md5}"
232
246
_zfssrc_snap=$( get_zfs_image_snap ${_zfssrc} )
233
247
# with ZFS we dont need image file anymore
@@ -256,7 +270,6 @@ images_register()
256
270
257
271
${BUILDAH_CMD} --root ${workdir}/basejail/buildah unmount ${_md5}
258
272
${BUILDAH_CMD} --root ${workdir}/basejail/buildah rm ${_md5}
259
- ${BUILDAH_CMD} --root ${workdir}/basejail/buildah rmi ${_imgname}
260
273
261
274
[ -z "${emulator}" ] && emulator="jail"
262
275
[ -z "${name}" ] && name="${path}"
0 commit comments