Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 65baba4

Browse files
committed
Implemented mixer reset command
It reverts the mix to a previous version in case of a build failure or in case the user wants to roll back to a specific version. By default, the command will bring back the mix to the same state it have when it last build a successful mix. This value can be overridden if a `--to` flag is provided with a version number. The command will not be destructive unless a `--clean` flag is provided specified. If so, mixer will delete all files associated with versions that are bigger than the one provided. If not, only the values of the state files will change, but the files will be kept. Signed-off-by: Ashlesha Atrey <[email protected]>
1 parent 2991b0f commit 65baba4

File tree

9 files changed

+474
-1
lines changed

9 files changed

+474
-1
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ MANPAGES = \
103103
docs/mixer.init.1 \
104104
docs/mixer.repo.1 \
105105
docs/mixer.versions.1 \
106-
docs/mixin.1
106+
docs/mixin.1 \
107+
docs/mixer.reset.1
107108

108109
man: $(MANPAGES)
109110

bat/tests/reset-command/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.PHONY: check clean
2+
3+
check:
4+
bats ./run.bats
5+
6+
CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles
7+
CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles
8+
clean:
9+
sudo rm -rf $(CLEANDIRS) $(CLEANFILES)
10+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
reset
2+
====================
3+
This test attempts to create multiple mixes of different versions
4+
in different format. It then tries to revert the mix to a previous stable
5+
version. If clean flag is set, mixer will delete all files associated with
6+
versions that are bigger than the one provided.
7+

bat/tests/reset-command/run.bats

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bats
2+
3+
# shared test functions
4+
load ../../lib/mixerlib
5+
6+
setup() {
7+
global_setup
8+
}
9+
10+
@test "reset" {
11+
mixer-init-stripped-down latest 10
12+
sudo mixer build all --format 1 --native
13+
mixer-versions-update 20 latest
14+
sudo mixer build all --format 2 --native
15+
mixer-versions-update 30 latest
16+
sudo mixer build all --format 3 --native
17+
#check LAST_VER and PREVIOUS_MIX_VERSION match
18+
test $(< update/image/LAST_VER) -eq 30
19+
test $(sed -n 's/[ ]*PREVIOUS_MIX_VERSION[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) -eq 20
20+
sudo mixer reset --to 20
21+
#check LAST_VER and PREVIOUS_MIX_VERSION match
22+
test $(< update/image/LAST_VER) -eq 20
23+
test $(sed -n 's/[ ]*PREVIOUS_MIX_VERSION[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) -eq 10
24+
test -d "./update/www/30"
25+
test -d "./update/image/30"
26+
sudo mixer reset --to 10 --clean
27+
#check LAST_VER and PREVIOUS_MIX_VERSION match
28+
test $(< update/image/LAST_VER) -eq 10
29+
test $(sed -n 's/[ ]*PREVIOUS_MIX_VERSION[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) -eq 0
30+
test ! -d "./update/www/20"
31+
test ! -d "./update/image/30"
32+
}
33+
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
34+

docs/mixer.1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,18 @@ upstream available. Also allows the user to update mix and upstream
149149
versions. See \fBmixer.versions\fP(1) for more details.
150150
.UNINDENT
151151
.UNINDENT
152+
.sp
153+
\fBreset\fP
154+
.INDENT 0.0
155+
.INDENT 3.5
156+
Reverts a mix state to the end of the last build or to the end
157+
of a given version build if one is provided. By default, the value
158+
of PREVIOUS_MIX_VERSION in mixer.state will be used to define the
159+
last build. This command can be used to roll back the mixer state
160+
in case of a build failure or in case the user wants to roll back
161+
to a previous version. See \fBmixer.reset\fP(1) for more details.
162+
.UNINDENT
163+
.UNINDENT
152164
.SH FILES
153165
.sp
154166
\fI<mixer/workspace>/builder.conf\fP
@@ -184,6 +196,8 @@ On success, 0 is returned. A non\-zero return code indicates a failure.
184196
.IP \(bu 2
185197
\fBmixer.versions\fP(1)
186198
.IP \(bu 2
199+
\fBmixer.reset\fP(1)
200+
.IP \(bu 2
187201
\fBswupd\fP(1)
188202
.IP \(bu 2
189203
\fBos\-format\fP(7)

docs/mixer.1.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ SUBCOMMANDS
114114
upstream available. Also allows the user to update mix and upstream
115115
versions. See ``mixer.versions``\(1) for more details.
116116

117+
``reset``
118+
119+
Reverts a mix state to the end of the last build or to the end
120+
of a given version build if one is provided. By default, the value
121+
of PREVIOUS_MIX_VERSION in mixer.state will be used to define the
122+
last build. This command can be used to roll back the mixer state
123+
in case of a build failure or in case the user wants to roll back
124+
to a previous version. See ``mixer.reset``\(1) for more details.
125+
117126

118127
FILES
119128
=====
@@ -142,6 +151,7 @@ SEE ALSO
142151
* ``mixer.init``\(1)
143152
* ``mixer.repo``\(1)
144153
* ``mixer.versions``\(1)
154+
* ``mixer.reset``\(1)
145155
* ``swupd``\(1)
146156
* ``os-format``\(7)
147157
* https://github.com/clearlinux/mixer-tools

docs/mixer.reset.1

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
.\" Man page generated from reStructuredText.
2+
.
3+
.TH MIXER.RESET 1 "" "" ""
4+
.SH NAME
5+
mixer.reset \- Reset mixer to a given or previous version
6+
.
7+
.nr rst2man-indent-level 0
8+
.
9+
.de1 rstReportMargin
10+
\\$1 \\n[an-margin]
11+
level \\n[rst2man-indent-level]
12+
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
13+
-
14+
\\n[rst2man-indent0]
15+
\\n[rst2man-indent1]
16+
\\n[rst2man-indent2]
17+
..
18+
.de1 INDENT
19+
.\" .rstReportMargin pre:
20+
. RS \\$1
21+
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
22+
. nr rst2man-indent-level +1
23+
.\" .rstReportMargin post:
24+
..
25+
.de UNINDENT
26+
. RE
27+
.\" indent \\n[an-margin]
28+
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
29+
.nr rst2man-indent-level -1
30+
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
31+
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
32+
..
33+
.SH SYNOPSIS
34+
.sp
35+
\fBmixer reset [flags]\fP
36+
.SH DESCRIPTION
37+
.sp
38+
Reverts a mix state to the end of the last build or to the end
39+
of a given version build if one is provided. By default, the value
40+
of PREVIOUS_MIX_VERSION in mixer.state will be used to define the
41+
last build. This command can be used to roll back the mixer state
42+
in case of a build failure or in case the user wants to roll back
43+
to a previous version.
44+
.SH OPTIONS
45+
.sp
46+
In addition to the globally recognized \fBmixer\fP flags (see \fBmixer\fP(1) for
47+
more details), the following options are recognized.
48+
.INDENT 0.0
49+
.IP \(bu 2
50+
\fB\-\-to\fP
51+
.sp
52+
Reverts the mix to the version provided by the flag
53+
.IP \(bu 2
54+
\fB\-\-clean\fP
55+
.sp
56+
Delete all files associated with versions that are bigger than the one provided.
57+
.IP \(bu 2
58+
\fB\-h, \-\-help\fP
59+
.sp
60+
Display \fBreset\fP help information and exit.
61+
.UNINDENT
62+
.SH EXIT STATUS
63+
.sp
64+
On success, 0 is returned. A non\-zero return code indicates a failure.
65+
.SS SEE ALSO
66+
.INDENT 0.0
67+
.IP \(bu 2
68+
\fBmixer\fP(1)
69+
.UNINDENT
70+
.SH COPYRIGHT
71+
(C) 2019 Intel Corporation, CC-BY-SA-3.0
72+
.\" Generated by docutils manpage writer.
73+
.

docs/mixer.reset.1.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
===========
2+
mixer.reset
3+
===========
4+
5+
------------------------------------------
6+
Reset mixer to a given or previous version
7+
------------------------------------------
8+
9+
:Copyright: \(C) 2019 Intel Corporation, CC-BY-SA-3.0
10+
:Manual section: 1
11+
12+
13+
SYNOPSIS
14+
========
15+
16+
``mixer reset [flags]``
17+
18+
19+
DESCRIPTION
20+
===========
21+
22+
Reverts a mix state to the end of the last build or to the end
23+
of a given version build if one is provided. By default, the value
24+
of PREVIOUS_MIX_VERSION in mixer.state will be used to define the
25+
last build. This command can be used to roll back the mixer state
26+
in case of a build failure or in case the user wants to roll back
27+
to a previous version.
28+
29+
OPTIONS
30+
=======
31+
32+
In addition to the globally recognized ``mixer`` flags (see ``mixer``\(1) for
33+
more details), the following options are recognized.
34+
35+
- ``--to``
36+
37+
Reverts the mix to the version provided by the flag
38+
39+
- ``--clean``
40+
41+
Delete all files associated with versions that are bigger than the one provided.
42+
43+
- ``-h, --help``
44+
45+
Display ``reset`` help information and exit.
46+
47+
48+
EXIT STATUS
49+
===========
50+
51+
On success, 0 is returned. A non-zero return code indicates a failure.
52+
53+
SEE ALSO
54+
--------
55+
56+
* ``mixer``\(1)

0 commit comments

Comments
 (0)