@@ -25,7 +25,6 @@ use ostree_ext::ostree;
2525use rand:: seq:: SliceRandom ;
2626use rand:: Rng ;
2727use serde:: { Deserialize , Serialize } ;
28- use sh_inline:: bash;
2928use std:: collections:: BTreeMap ;
3029use std:: io:: Write ;
3130use std:: path:: Path ;
@@ -132,12 +131,15 @@ impl InterruptStrategy {
132131
133132/// TODO add readonly sysroot handling into base ostree
134133fn testinit ( ) -> Result < ( ) > {
134+ let sh = xshell:: Shell :: new ( ) ?;
135135 assert ! ( std:: path:: Path :: new( "/run/ostree-booted" ) . exists( ) ) ;
136- bash ! (
136+ cmd ! (
137+ sh,
137138 r"if ! test -w /sysroot; then
138139 mount -o remount,rw /sysroot
139140fi"
140- ) ?;
141+ )
142+ . run ( ) ?;
141143 Ok ( ( ) )
142144}
143145
@@ -146,16 +148,19 @@ fi"
146148/// reworked the tree mutation to operate on an ostree repo
147149/// rather than a filesystem.
148150fn generate_update ( commit : & str ) -> Result < ( ) > {
151+ let sh = xshell:: Shell :: new ( ) ?;
149152 println ! ( "Generating update from {}" , commit) ;
150153 crate :: treegen:: update_os_tree ( SRVREPO , TESTREF , TREEGEN_PERCENTAGE )
151154 . context ( "Failed to generate new content" ) ?;
152155 // Amortize the prune across multiple runs; we don't want to leak space,
153156 // but traversing all the objects is expensive. So here we only prune 1/5 of the time.
154157 if rand:: thread_rng ( ) . gen_ratio ( 1 , 5 ) {
155- bash ! (
158+ cmd ! (
159+ sh,
156160 "ostree --repo=${srvrepo} prune --refs-only --depth=1" ,
157161 srvrepo = SRVREPO
158- ) ?;
162+ )
163+ . run ( ) ?;
159164 }
160165 Ok ( ( ) )
161166}
@@ -165,7 +170,9 @@ fn generate_update(commit: &str) -> Result<()> {
165170/// and then teach our webserver to redirect to the system for objects it doesn't
166171/// have.
167172fn generate_srv_repo ( commit : & str ) -> Result < ( ) > {
168- bash ! (
173+ let sh = xshell:: Shell :: new ( ) ?;
174+ cmd ! (
175+ sh,
169176 r#"
170177 ostree --repo=${srvrepo} init --mode=archive
171178 ostree --repo=${srvrepo} config set archive.zlib-level 1
@@ -176,6 +183,7 @@ fn generate_srv_repo(commit: &str) -> Result<()> {
176183 commit = commit,
177184 testref = TESTREF
178185 )
186+ . run ( )
179187 . context ( "Failed to generate srv repo" ) ?;
180188 generate_update ( commit) ?;
181189 Ok ( ( ) )
@@ -200,11 +208,14 @@ struct RebootStats {
200208}
201209
202210fn upgrade_and_finalize ( ) -> Result < ( ) > {
203- bash ! (
211+ let sh = xshell:: Shell :: new ( ) ?;
212+ cmd ! (
213+ sh,
204214 "rpm-ostree upgrade
205215 systemctl start ostree-finalize-staged
206216 systemctl stop ostree-finalize-staged"
207217 )
218+ . run ( )
208219 . context ( "Upgrade and finalize failed" ) ?;
209220 Ok ( ( ) )
210221}
@@ -309,9 +320,10 @@ fn parse_and_validate_reboot_mark<M: AsRef<str>>(
309320}
310321
311322fn validate_pending_commit ( pending_commit : & str , commitstates : & CommitStates ) -> Result < ( ) > {
323+ let sh = xshell:: Shell :: new ( ) ?;
312324 if pending_commit != commitstates. target {
313- bash ! ( "rpm-ostree status -v" ) ?;
314- bash ! ( "ostree show ${pending_commit}" , pending_commit) ?;
325+ cmd ! ( sh , "rpm-ostree status -v" ) . run ( ) ?;
326+ cmd ! ( sh , "ostree show ${pending_commit}" , pending_commit) . run ( ) ?;
315327 anyhow:: bail!(
316328 "Expected target commit={} but pending={} ({:?})" ,
317329 commitstates. target,
@@ -622,7 +634,8 @@ pub(crate) fn itest_transactionality() -> Result<()> {
622634 // FIXME: make this saner
623635 let origref = ORIGREF ;
624636 let testref = TESTREF ;
625- bash ! (
637+ cmd ! (
638+ sh,
626639 "
627640 ostree admin set-origin testrepo ${url} ${testref}
628641 ostree refs --create testrepo:${testref} ${commit}
@@ -632,7 +645,8 @@ pub(crate) fn itest_transactionality() -> Result<()> {
632645 origref,
633646 testref,
634647 commit
635- ) ?;
648+ )
649+ . run ( ) ?;
636650 // We gather a single "cycle time" at start as a way of gauging how
637651 // long an upgrade should take, so we know when to interrupt. This
638652 // obviously has some pitfalls, mainly when there are e.g. other competing
0 commit comments