Skip to content

Commit c32af2a

Browse files
committed
Remove deprecated options
revert: remove deprecated -a flag snapshot: remove -n and -a deprecated options export: remove deprecated option -s
1 parent b17ffbc commit c32af2a

File tree

10 files changed

+71
-176
lines changed

10 files changed

+71
-176
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2727

2828
### Removed
2929
- alias: remove option -I, in favour of a more flexible and powerful -i
30+
- export: remove option -s, to select a specific snapshot (already deprecated)
31+
- snapshot: remove option -n, to specify a snapshot name (already deprecated)
32+
- snapshot: remove flag -a, to snapshot external ZFS datasets (already deprecated)
33+
- revert: remove flag -a, to restore external ZFS datasets (already deprecated)
3034

3135
### Fixed
3236
- mount-in: compute the realpath of the mount-point

share/pot/common.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,12 @@ _remove_oldest_fscomp_snap()
267267
}
268268
# take a zfs snapshot of a fscomp
269269
# $1 fscomp name
270-
# $2 optional name
271270
_fscomp_zfs_snap()
272271
{
273272
# shellcheck disable=SC2039
274273
local _fscomp _snaptag _dset
275274
_fscomp=$1
276-
if [ -z "$2" ]; then
277-
_snaptag="$(date +%s)"
278-
else
279-
_snaptag="$2"
280-
fi
275+
_snaptag="$(date +%s)"
281276
_debug "Take snapshot of $_fscomp"
282277
zfs snapshot "${POT_ZFS_ROOT}/fscomp/${_fscomp}@${_snaptag}"
283278
}

share/pot/export.sh

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ export-help() {
1212
echo ' -p pot : the working pot'
1313
echo ' -t tag : the tag to be used as suffix in the filename'
1414
echo ' if no tag is specified, tha snapshot will be used as suffix'
15-
echo ' -s snapshot : by default, the last snapshot is taken. [ DEPRECATED ]'
16-
echo ' this option allows to use a different snapshot'
1715
echo ' -D directory : where to store the compressed file with the pot'
1816
echo ' -l compression-level : from 0 (fast) to 9 (best). Defaul level 6. (man xz for more information)'
1917
echo ' -F : force exports of multiple snapshot (only 1 snapshot should be allowed)'
@@ -59,7 +57,7 @@ pot-export()
5957
_auto_purge=
6058
_force=
6159
OPTIND=1
62-
while getopts "hvp:s:t:D:l:FA" _o ; do
60+
while getopts "hvp:t:D:l:FA" _o ; do
6361
case "$_o" in
6462
h)
6563
export-help
@@ -71,12 +69,6 @@ pot-export()
7169
p)
7270
_pname="$OPTARG"
7371
;;
74-
s)
75-
_snap="$OPTARG"
76-
echo '####################'
77-
echo '# -s is deprecated #'
78-
echo '####################'
79-
;;
8072
t)
8173
_tag="$OPTARG"
8274
;;
@@ -122,30 +114,24 @@ pot-export()
122114
_error "pot $_pname not supported - only single type pot can be exported"
123115
${EXIT} 1
124116
fi
125-
if [ -n "$_snap" ]; then
126-
if _is_zfs_pot_snap "$_pname" "$_snap" ; then
127-
_error "no snap $_snap for pot $_pname found"
128-
export-help
129-
${EXIT} 1
130-
fi
131-
else
132-
_snap="$(_zfs_last_snap "${POT_ZFS_ROOT}/jails/$_pname" )"
133-
if [ -z "$_snap" ]; then
134-
if [ "$_auto_purge" = "YES" ]; then
135-
_info "Taking a snapshot of $_pname"
136-
if ! pot-cmd snapshot -p "$_pname" ; then
137-
_error "Failed to take a snapshot of pot $_pname"
138-
${EXIT} 1
139-
else
140-
_snap="$(_zfs_last_snap "${POT_ZFS_ROOT}/jails/$_pname" )"
141-
_debug "A snapshot of $_pname has been automatically taken (@$_snap)"
142-
fi
143-
else
144-
_error "Pot $_pname has no snapshots - please use pot snapshot for that"
117+
118+
_snap="$(_zfs_last_snap "${POT_ZFS_ROOT}/jails/$_pname" )"
119+
if [ -z "$_snap" ]; then
120+
if [ "$_auto_purge" = "YES" ]; then
121+
_info "Taking a snapshot of $_pname"
122+
if ! pot-cmd snapshot -p "$_pname" ; then
123+
_error "Failed to take a snapshot of pot $_pname"
145124
${EXIT} 1
125+
else
126+
_snap="$(_zfs_last_snap "${POT_ZFS_ROOT}/jails/$_pname" )"
127+
_debug "A snapshot of $_pname has been automatically taken (@$_snap)"
146128
fi
129+
else
130+
_error "Pot $_pname has no snapshots - please use pot snapshot for that"
131+
${EXIT} 1
147132
fi
148133
fi
134+
149135
if [ "$( _zfs_count_snap "${POT_ZFS_ROOT}/jails/$_pname" )" -gt 1 ]; then
150136
if [ "$_force" = "YES" ]; then
151137
_info "Pot $_pname has multiple snapshots and they all will be exported"

share/pot/revert.sh

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ revert-help()
66
echo "pot revert [-hva] -p potname|-f fscomp"
77
echo ' -h print this help'
88
echo ' -v verbose'
9-
echo ' -a all components of a pot [DEPRECATED]'
109
echo ' -p potname : the pot target of the revert'
1110
echo ' -f fscomp : the fs component target of the revert'
1211
}
@@ -42,36 +41,14 @@ _fscomp_zfs_rollback()
4241
done
4342
}
4443

45-
# DEPRECATED
46-
_pot_zfs_rollback_full()
47-
{
48-
local _pname _pdir _snap _node _opt _dset
49-
_pname=$1
50-
_pdir=${POT_FS_ROOT}/jails/$_pname
51-
while read -r line ; do
52-
_dset=$( echo $line | awk '{print $1}' )
53-
_opt=$( echo $line | awk '{print $3}' )
54-
if [ "$_opt" = "ro" ]; then
55-
continue
56-
fi
57-
_snap="$( _zfs_last_snap $_dset)"
58-
if [ -z "$_snap" ]; then
59-
_info "$_dset has not snapshot - no possible rollback"
60-
continue
61-
fi
62-
zfs rollback ${_dset}@${_snap}
63-
done < ${_pdir}/conf/fscomp.conf
64-
}
65-
6644
pot-revert()
6745
{
68-
local _obj _full_pot
69-
args=$(getopt hvap:f: $*)
46+
local _obj
47+
args=$(getopt hvp:f: $*)
7048
if [ $? -ne 0 ]; then
7149
revert-help
7250
${EXIT} 1
7351
fi
74-
_full_pot="NO"
7552
_obj=
7653
set -- $args
7754
while true; do
@@ -84,13 +61,6 @@ pot-revert()
8461
_POT_VERBOSITY=$(( _POT_VERBOSITY + 1))
8562
shift
8663
;;
87-
-a)
88-
_full_pot="YES"
89-
echo "###########################"
90-
echo "# option -a is deprecated #"
91-
echo "###########################"
92-
shift
93-
;;
9464
-p)
9565
if [ -z "$_obj" ]; then
9666
_obj="pot"
@@ -143,11 +113,7 @@ pot-revert()
143113
if ! _is_uid0 ; then
144114
${EXIT} 1
145115
fi
146-
if [ "$_full_pot" = "YES" ]; then
147-
_pot_zfs_rollback_full $_objname
148-
else
149-
_pot_zfs_rollback $_objname
150-
fi
116+
_pot_zfs_rollback $_objname
151117
;;
152118
"fscomp")
153119
if ! _zfs_exist ${POT_ZFS_ROOT}/fscomp/$_objname ${POT_FS_ROOT}/fscomp/$_objname ; then

share/pot/snapshot.sh

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ snapshot-help()
88
echo ' -h print this help'
99
echo ' -v verbose'
1010
echo ' -r replace the oldest available snapshot with the new one (not compatible with -a)'
11-
echo ' -a all components of a pot [DEPRECATED]'
1211
echo ' -p potname : the pot target of the snapshot'
1312
echo ' -f fscomp : the fs component target of the snapshot'
1413
}
@@ -20,10 +19,9 @@ pot-snapshot()
2019
_full_pot="NO"
2120
_obj=""
2221
_objname=
23-
_snapname=""
2422
_replace=
2523
OPTIND=1
26-
while getopts "hvap:f:n:r" _o ; do
24+
while getopts "hvp:f:r" _o ; do
2725
case "$_o" in
2826
h)
2927
snapshot-help
@@ -35,12 +33,6 @@ pot-snapshot()
3533
r)
3634
_replace="YES"
3735
;;
38-
a)
39-
_full_pot="YES"
40-
echo "###########################"
41-
echo "# option -a is deprecated #"
42-
echo "###########################"
43-
;;
4436
p)
4537
if [ -z "$_obj" ]; then
4638
_obj="pot"
@@ -61,12 +53,6 @@ pot-snapshot()
6153
return 1
6254
fi
6355
;;
64-
n)
65-
_snapname="$OPTARG"
66-
echo "###########################"
67-
echo "# option -n is deprecated #"
68-
echo "###########################"
69-
;;
7056
*)
7157
snapshot-help
7258
return 1
@@ -85,10 +71,6 @@ pot-snapshot()
8571
fi
8672
case $_obj in
8773
"pot")
88-
if [ -n "$_snapname" ]; then
89-
_error "Option -n usable only with fscomp"
90-
return 1
91-
fi
9274
if ! _is_pot "$_objname" ; then
9375
_error "$_objname is not a pot!"
9476
snapshot-help
@@ -117,16 +99,13 @@ pot-snapshot()
11799
snapshot-help
118100
return 1
119101
fi
120-
if [ "$_full_pot" = "YES" ]; then
121-
_info "-a option is incompatible with -f. Ignored"
122-
fi
123102
if ! _is_uid0 ; then
124103
return 1
125104
fi
126105
if [ "$_replace" = "YES" ]; then
127106
_remove_oldest_fscomp_snap "$_objname"
128107
fi
129-
_fscomp_zfs_snap "$_objname" "$_snapname"
108+
_fscomp_zfs_snap "$_objname"
130109
;;
131110
esac
132111
return 0

share/zsh/site-functions/_pot

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,16 +296,14 @@ _pot() {
296296
'-v[Verbose output]' \
297297
'-r[replace the oldest snapshot]' \
298298
'-p[pot name]:pot name:_pot_pots' \
299-
'-f[fscomp name]:fscomp name:_pot_fscomps' \
300-
'-a[also external components]'
299+
'-f[fscomp name]:fscomp name:_pot_fscomps'
301300
;;
302301
revert|rollback)
303302
_arguments -s \
304303
'-h[Show help]' \
305304
'-v[Verbose output]' \
306305
'-p[pot name]:pot name:_pot_pots' \
307-
'-f[fscomp name]:fscomp name:_pot_fscomps' \
308-
'-a[also external components]'
306+
'-f[fscomp name]:fscomp name:_pot_fscomps'
309307
;;
310308
purge-snapshots)
311309
_arguments -s \
@@ -328,7 +326,6 @@ _pot() {
328326
'-v[Verbose output]' \
329327
'-p[pot name]:pot name:_pot_pots' \
330328
'-t[tag name]::_normal' \
331-
'-s[snapshot]::_normal' \
332329
'-D[target directory]:target directory:_normal' \
333330
'-l[compression level]:compression level:(0 1 2 3 4 5 6 7 8 9)'
334331
;;

tests/common-zfs2.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ test_fscomp_zfs_snap_001()
2727

2828
test_fscomp_zfs_snap_002()
2929
{
30+
# the argument "new_snap" is ignored
3031
_fscomp_zfs_snap fscomp_name new_snap
3132
assertEquals "zfs calls" "1" "$ZFS_CALLS"
32-
assertEquals "zfs args" "/zroot/fscomp/fscomp_name@new_snap" "$ZFS_CALL1_ARG2"
33+
assertEquals "zfs args" "/zroot/fscomp/fscomp_name@123454321" "$ZFS_CALL1_ARG2"
3334
}
3435

3536
setUp()

tests/export1.sh

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ test_pot_export_024()
119119
pot-export -s ""
120120
assertEquals "Exit rc" "1" "$?"
121121
assertEquals "Help calls" "1" "$HELP_CALLS"
122-
assertEquals "Error calls" "1" "$ERROR_CALLS"
123122
assertEquals "_export calls" "0" "$EXPORTS_CALLS"
124123
}
125124

@@ -129,7 +128,6 @@ test_pot_export_025()
129128
pot-export -s 666
130129
assertEquals "Exit rc" "1" "$?"
131130
assertEquals "Help calls" "1" "$HELP_CALLS"
132-
assertEquals "Error calls" "1" "$ERROR_CALLS"
133131
assertEquals "_export calls" "0" "$EXPORTS_CALLS"
134132
}
135133

@@ -148,10 +146,6 @@ test_pot_export_027()
148146
pot-export -p test-pot-single -s 666
149147
assertEquals "Exit rc" "1" "$?"
150148
assertEquals "Help calls" "1" "$HELP_CALLS"
151-
assertEquals "Error calls" "1" "$ERROR_CALLS"
152-
assertEquals "_is_zfs_pot_snap calls" "1" "$ISZFSSNAP_CALLS"
153-
assertEquals "_is_zfs_pot_snap arg1" "test-pot-single" "$ISZFSSNAP_CALL1_ARG1"
154-
assertEquals "_is_zfs_pot_snap arg2" "666" "$ISZFSSNAP_CALL1_ARG2"
155149
assertEquals "_export calls" "0" "$EXPORTS_CALLS"
156150
}
157151

@@ -231,49 +225,25 @@ test_pot_export_041()
231225
test_pot_export_042()
232226
{
233227
pot-export -p test-pot-single -s 1234
234-
assertEquals "Exit rc" "0" "$?"
235-
assertEquals "Help calls" "0" "$HELP_CALLS"
236-
assertEquals "Error calls" "0" "$ERROR_CALLS"
237-
assertEquals "_is_zfs_pot_snap calls" "1" "$ISZFSSNAP_CALLS"
238-
assertEquals "_is_zfs_pot_snap arg1" "test-pot-single" "$ISZFSSNAP_CALL1_ARG1"
239-
assertEquals "_is_zfs_pot_snap arg2" "1234" "$ISZFSSNAP_CALL1_ARG2"
240-
assertEquals "_export calls" "1" "$EXPORTS_CALLS"
241-
assertEquals "_export arg1" "test-pot-single" "$EXPORTS_CALL1_ARG1"
242-
assertEquals "_export arg2" "1234" "$EXPORTS_CALL1_ARG2"
243-
assertEquals "_export arg3" "1234" "$EXPORTS_CALL1_ARG3"
244-
assertEquals "_export arg4" "." "$EXPORTS_CALL1_ARG4"
228+
assertEquals "Exit rc" "1" "$?"
229+
assertEquals "Help calls" "1" "$HELP_CALLS"
230+
assertEquals "_export calls" "0" "$EXPORTS_CALLS"
245231
}
246232

247233
test_pot_export_043()
248234
{
249235
pot-export -p test-pot-single -s 1234 -t 1.0
250-
assertEquals "Exit rc" "0" "$?"
251-
assertEquals "Help calls" "0" "$HELP_CALLS"
252-
assertEquals "Error calls" "0" "$ERROR_CALLS"
253-
assertEquals "_is_zfs_pot_snap calls" "1" "$ISZFSSNAP_CALLS"
254-
assertEquals "_is_zfs_pot_snap arg1" "test-pot-single" "$ISZFSSNAP_CALL1_ARG1"
255-
assertEquals "_is_zfs_pot_snap arg2" "1234" "$ISZFSSNAP_CALL1_ARG2"
256-
assertEquals "_export calls" "1" "$EXPORTS_CALLS"
257-
assertEquals "_export arg1" "test-pot-single" "$EXPORTS_CALL1_ARG1"
258-
assertEquals "_export arg2" "1234" "$EXPORTS_CALL1_ARG2"
259-
assertEquals "_export arg3" "1.0" "$EXPORTS_CALL1_ARG3"
260-
assertEquals "_export arg4" "." "$EXPORTS_CALL1_ARG4"
236+
assertEquals "Exit rc" "1" "$?"
237+
assertEquals "Help calls" "1" "$HELP_CALLS"
238+
assertEquals "_export calls" "0" "$EXPORTS_CALLS"
261239
}
262240

263241
test_pot_export_044()
264242
{
265243
pot-export -p test-pot-single -s 1234 -t 1.0 -D /tmp
266-
assertEquals "Exit rc" "0" "$?"
267-
assertEquals "Help calls" "0" "$HELP_CALLS"
268-
assertEquals "Error calls" "0" "$ERROR_CALLS"
269-
assertEquals "_is_zfs_pot_snap calls" "1" "$ISZFSSNAP_CALLS"
270-
assertEquals "_is_zfs_pot_snap arg1" "test-pot-single" "$ISZFSSNAP_CALL1_ARG1"
271-
assertEquals "_is_zfs_pot_snap arg2" "1234" "$ISZFSSNAP_CALL1_ARG2"
272-
assertEquals "_export calls" "1" "$EXPORTS_CALLS"
273-
assertEquals "_export arg1" "test-pot-single" "$EXPORTS_CALL1_ARG1"
274-
assertEquals "_export arg2" "1234" "$EXPORTS_CALL1_ARG2"
275-
assertEquals "_export arg3" "1.0" "$EXPORTS_CALL1_ARG3"
276-
assertEquals "_export arg4" "/tmp" "$EXPORTS_CALL1_ARG4"
244+
assertEquals "Exit rc" "1" "$?"
245+
assertEquals "Help calls" "1" "$HELP_CALLS"
246+
assertEquals "_export calls" "0" "$EXPORTS_CALLS"
277247
}
278248

279249
test_pot_export_050()

0 commit comments

Comments
 (0)