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

Commit 12eab83

Browse files
committed
Implemented mixer reset command
It reverts the mix to a good state in case of a build failure or in case the user wants to roll back to a previous 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 4e76482 commit 12eab83

File tree

9 files changed

+411
-5
lines changed

9 files changed

+411
-5
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 upstream version
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 27310 10
12+
mixer build all --format 30 --native
13+
mixer versions update --upstream-version 30000
14+
mixer build upstream-format --new-format 28 --native
15+
sudo mixer versions update --upstream-version 30800
16+
mixer build upstream-format --new-format 20 --native
17+
#check LAST_VER and PREVIOUS_MIX_VERSION match
18+
test $(< update/image/LAST_VER) -eq 50
19+
test $(sed -n 's/[ ]*PREVIOUS_MIX_VERSION[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) -eq 50
20+
mixer reset --to 40
21+
#check LAST_VER and PREVIOUS_MIX_VERSION match
22+
test $(< update/image/LAST_VER) -eq 40
23+
test $(sed -n 's/[ ]*PREVIOUS_MIX_VERSION[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) -eq 40
24+
test -d "./update/www/50"
25+
test -d "./update/image/50"
26+
mixer reset --to 30 --clean
27+
#check LAST_VER and PREVIOUS_MIX_VERSION match
28+
test $(< update/image/LAST_VER) -eq 30
29+
test $(sed -n 's/[ ]*PREVIOUS_MIX_VERSION[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) -eq 30
30+
test ! -d "./update/www/40"
31+
test ! -d "./update/image/40"
32+
}
33+
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
34+

docs/mixer.1

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ configure remote RPM repositories.
5050
The output of \fBmixer\fP is a set of manifests readable by \fBswupd\fP as well as
5151
all the OS content \fBswupd\fP needs to perform its update operations. The OS
5252
content includes all the files in an update as well as zero\- and delta\-packs for
53-
improved update performance. See \fBswupd\fP(1) for more details.
53+
improved update performance. The content that \fBmixer\fP produces is tied to a
54+
specific format so that \fBswupd\fP is guaranteed to understand it if the client
55+
is using the right version of \fBswupd\fP\&. See \fBswupd\fP(1) and \fBos\-format\fP(7)
56+
for more details.
5457
.SH OPTIONS
5558
.sp
5659
The following options are applicable to most subcommands, and can be
@@ -102,9 +105,8 @@ itself. See \fBmixer.build\fP(1) for more details.
102105
.INDENT 0.0
103106
.INDENT 3.5
104107
Perform various configuration actions on local and upstream bundles. The
105-
user can add or remove bundles from their mix, edit local and upstream
106-
bundles, create new bundle definitions, or validate local bundle definition
107-
files. See \fBmixer.bundle\fP(1) for more details.
108+
user can add or remove bundles from their mix, create new bundle definitions,
109+
or validate local bundle definition files. See \fBmixer.bundle\fP(1) for more details.
108110
.UNINDENT
109111
.UNINDENT
110112
.sp
@@ -151,6 +153,16 @@ upstream available. Also allows the user to update mix and upstream
151153
versions. See \fBmixer.versions\fP(1) for more details.
152154
.UNINDENT
153155
.UNINDENT
156+
.sp
157+
\fBreset\fP
158+
.INDENT 0.0
159+
.INDENT 3.5
160+
It reverts the mix to a good state in case of a build failure or in case
161+
the user wants to roll back to a previous version.By default, the command
162+
will bring back the mix to the same state it have when it last build a
163+
successful mix. See \fBmixer.reset\fP(1) for more details.
164+
.UNINDENT
165+
.UNINDENT
154166
.SH FILES
155167
.sp
156168
\fI<mixer/workspace>/builder.conf\fP
@@ -186,8 +198,12 @@ On success, 0 is returned. A non\-zero return code indicates a failure.
186198
.IP \(bu 2
187199
\fBmixer.versions\fP(1)
188200
.IP \(bu 2
201+
\fBmixer.reset\fP(1)
202+
.IP \(bu 2
189203
\fBswupd\fP(1)
190204
.IP \(bu 2
205+
\fBos\-format\fP(7)
206+
.IP \(bu 2
191207
\fI\%https://github.com/clearlinux/mixer\-tools\fP
192208
.IP \(bu 2
193209
\fI\%https://github.com/clearlinux/swupd\-client\fP

docs/mixer.1.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ SUBCOMMANDS
118118
upstream available. Also allows the user to update mix and upstream
119119
versions. See ``mixer.versions``\(1) for more details.
120120

121+
``reset``
122+
123+
It reverts the mix to a good state in case of a build failure or in case
124+
the user wants to roll back to a previous version.By default, the command
125+
will bring back the mix to the same state it have when it last build a
126+
successful mix. See ``mixer.reset``\(1) for more details.
127+
121128

122129
FILES
123130
=====
@@ -146,6 +153,7 @@ SEE ALSO
146153
* ``mixer.init``\(1)
147154
* ``mixer.repo``\(1)
148155
* ``mixer.versions``\(1)
156+
* ``mixer.reset``\(1)
149157
* ``swupd``\(1)
150158
* ``os-format``\(7)
151159
* https://github.com/clearlinux/mixer-tools

docs/mixer.reset.1

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
.\" Man page generated from reStructuredText.
2+
.
3+
.TH MIXER.RESET 1 "" "" ""
4+
.SH NAME
5+
mixer.reset \- Reset mixer to a given or stable 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+
It reverts the mix to a good state in case of a build failure or in case
39+
the user wants to roll back to a previous version. By default, the command
40+
will bring back the mix to the same state it have when it last build a
41+
successful mix.
42+
.SH OPTIONS
43+
.sp
44+
In addition to the globally recognized \fBmixer\fP flags (see \fBmixer\fP(1) for
45+
more details), the following options are recognized.
46+
.INDENT 0.0
47+
.IP \(bu 2
48+
\fB\-\-to\fP
49+
.sp
50+
Reverts the mix to the version provided by the flag
51+
.IP \(bu 2
52+
\fB\-\-clean\fP
53+
.sp
54+
Delete all files associated with versions that are bigger than the one provided.
55+
.IP \(bu 2
56+
\fB\-h, \-\-help\fP
57+
.sp
58+
Display \fBreset\fP help information and exit.
59+
.UNINDENT
60+
.SH EXIT STATUS
61+
.sp
62+
On success, 0 is returned. A non\-zero return code indicates a failure.
63+
.SS SEE ALSO
64+
.INDENT 0.0
65+
.IP \(bu 2
66+
\fBmixer\fP(1)
67+
.UNINDENT
68+
.SH COPYRIGHT
69+
(C) 2019 Intel Corporation, CC-BY-SA-3.0
70+
.\" Generated by docutils manpage writer.
71+
.

docs/mixer.reset.1.rst

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
===========
2+
mixer.reset
3+
===========
4+
5+
----------------------------------------
6+
Reset mixer to a given or stable 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+
It reverts the mix to a good state in case of a build failure or in case
23+
the user wants to roll back to a previous version. By default, the command
24+
will bring back the mix to the same state it have when it last build a
25+
successful mix.
26+
27+
OPTIONS
28+
=======
29+
30+
In addition to the globally recognized ``mixer`` flags (see ``mixer``\(1) for
31+
more details), the following options are recognized.
32+
33+
- ``--to``
34+
35+
Reverts the mix to the version provided by the flag
36+
37+
- ``--clean``
38+
39+
Delete all files associated with versions that are bigger than the one provided.
40+
41+
- ``-h, --help``
42+
43+
Display ``reset`` help information and exit.
44+
45+
46+
EXIT STATUS
47+
===========
48+
49+
On success, 0 is returned. A non-zero return code indicates a failure.
50+
51+
SEE ALSO
52+
--------
53+
54+
* ``mixer``\(1)

0 commit comments

Comments
 (0)