@@ -8,7 +8,7 @@ use containers_image_proxy::oci_spec;
8
8
use oci_image:: ImageManifest ;
9
9
use oci_spec:: image as oci_image;
10
10
use ocidir:: oci_spec:: image:: { Arch , DigestAlgorithm } ;
11
- use once_cell:: sync:: Lazy ;
11
+ use once_cell:: sync:: { Lazy , OnceCell } ;
12
12
use ostree_ext:: chunking:: ObjectMetaSized ;
13
13
use ostree_ext:: container:: { store, ManifestDiff } ;
14
14
use ostree_ext:: container:: {
@@ -32,6 +32,12 @@ use ostree_ext::fixture::{
32
32
const EXAMPLE_TAR_LAYER : & [ u8 ] = include_bytes ! ( "fixtures/hlinks.tar.gz" ) ;
33
33
const TEST_REGISTRY_DEFAULT : & str = "localhost:5000" ;
34
34
35
+ /// Check if we have skopeo
36
+ fn check_skopeo ( ) -> bool {
37
+ static HAVE_SKOPEO : OnceCell < bool > = OnceCell :: new ( ) ;
38
+ * HAVE_SKOPEO . get_or_init ( || Command :: new ( "skopeo" ) . arg ( "--help" ) . status ( ) . is_ok ( ) )
39
+ }
40
+
35
41
#[ track_caller]
36
42
fn assert_err_contains < T > ( r : Result < T > , s : impl AsRef < str > ) {
37
43
let s = s. as_ref ( ) ;
@@ -624,6 +630,9 @@ async fn impl_test_container_import_export(chunked: bool) -> Result<()> {
624
630
625
631
#[ tokio:: test]
626
632
async fn test_export_as_container_nonderived ( ) -> Result < ( ) > {
633
+ if !check_skopeo ( ) {
634
+ return Ok ( ( ) ) ;
635
+ }
627
636
let fixture = Fixture :: new_v1 ( ) ?;
628
637
// Export into an OCI directory
629
638
let src_imgref = fixture. export_container ( ) . await . unwrap ( ) . 0 ;
@@ -662,6 +671,9 @@ async fn test_export_as_container_nonderived() -> Result<()> {
662
671
663
672
#[ tokio:: test]
664
673
async fn test_export_as_container_derived ( ) -> Result < ( ) > {
674
+ if !check_skopeo ( ) {
675
+ return Ok ( ( ) ) ;
676
+ }
665
677
let fixture = Fixture :: new_v1 ( ) ?;
666
678
// Export into an OCI directory
667
679
let src_imgref = fixture. export_container ( ) . await . unwrap ( ) . 0 ;
@@ -711,6 +723,9 @@ async fn test_export_as_container_derived() -> Result<()> {
711
723
712
724
#[ tokio:: test]
713
725
async fn test_unencapsulate_unbootable ( ) -> Result < ( ) > {
726
+ if !check_skopeo ( ) {
727
+ return Ok ( ( ) ) ;
728
+ }
714
729
let fixture = {
715
730
let mut fixture = Fixture :: new_base ( ) ?;
716
731
fixture. bootable = false ;
@@ -801,6 +816,9 @@ fn validate_chunked_structure(oci_path: &Utf8Path) -> Result<()> {
801
816
802
817
#[ tokio:: test]
803
818
async fn test_container_arch_mismatch ( ) -> Result < ( ) > {
819
+ if !check_skopeo ( ) {
820
+ return Ok ( ( ) ) ;
821
+ }
804
822
let fixture = Fixture :: new_v1 ( ) ?;
805
823
806
824
let imgref = fixture. export_container ( ) . await . unwrap ( ) . 0 ;
@@ -850,6 +868,9 @@ async fn test_container_arch_mismatch() -> Result<()> {
850
868
851
869
#[ tokio:: test]
852
870
async fn test_container_chunked ( ) -> Result < ( ) > {
871
+ if !check_skopeo ( ) {
872
+ return Ok ( ( ) ) ;
873
+ }
853
874
let nlayers = LAYERS_V0_LEN - 1 ;
854
875
let mut fixture = Fixture :: new_v1 ( ) ?;
855
876
@@ -1044,6 +1065,9 @@ r usr/bin/bash bash-v0
1044
1065
1045
1066
#[ tokio:: test]
1046
1067
async fn test_container_var_content ( ) -> Result < ( ) > {
1068
+ if !check_skopeo ( ) {
1069
+ return Ok ( ( ) ) ;
1070
+ }
1047
1071
let fixture = Fixture :: new_v1 ( ) ?;
1048
1072
1049
1073
let imgref = fixture. export_container ( ) . await . unwrap ( ) . 0 ;
@@ -1146,6 +1170,9 @@ async fn test_container_etc_hardlinked_relative() -> Result<()> {
1146
1170
}
1147
1171
1148
1172
async fn test_container_etc_hardlinked ( absolute : bool ) -> Result < ( ) > {
1173
+ if !check_skopeo ( ) {
1174
+ return Ok ( ( ) ) ;
1175
+ }
1149
1176
let fixture = Fixture :: new_v1 ( ) ?;
1150
1177
1151
1178
let imgref = fixture. export_container ( ) . await . unwrap ( ) . 0 ;
@@ -1257,6 +1284,9 @@ async fn test_container_etc_hardlinked(absolute: bool) -> Result<()> {
1257
1284
1258
1285
#[ tokio:: test]
1259
1286
async fn test_non_ostree ( ) -> Result < ( ) > {
1287
+ if !check_skopeo ( ) {
1288
+ return Ok ( ( ) ) ;
1289
+ }
1260
1290
let fixture = NonOstreeFixture :: new_base ( ) ?;
1261
1291
let src_digest = fixture. export_container ( ) . await ?. 1 ;
1262
1292
@@ -1285,13 +1315,19 @@ async fn oci_clone(src: impl AsRef<Utf8Path>, dest: impl AsRef<Utf8Path>) -> Res
1285
1315
1286
1316
#[ tokio:: test]
1287
1317
async fn test_container_import_export_v1 ( ) {
1318
+ if !check_skopeo ( ) {
1319
+ return ;
1320
+ }
1288
1321
impl_test_container_import_export ( false ) . await . unwrap ( ) ;
1289
1322
impl_test_container_import_export ( true ) . await . unwrap ( ) ;
1290
1323
}
1291
1324
1292
1325
/// But layers work via the container::write module.
1293
1326
#[ tokio:: test]
1294
1327
async fn test_container_write_derive ( ) -> Result < ( ) > {
1328
+ if !check_skopeo ( ) {
1329
+ return Ok ( ( ) ) ;
1330
+ }
1295
1331
let cancellable = gio:: Cancellable :: NONE ;
1296
1332
let fixture = Fixture :: new_v1 ( ) ?;
1297
1333
let sh = fixture. new_shell ( ) ?;
@@ -1539,6 +1575,9 @@ async fn test_container_write_derive() -> Result<()> {
1539
1575
1540
1576
/// Implementation of a test case for non-gzip (i.e. zstd or zstd:chunked) compression
1541
1577
async fn test_non_gzip ( format : & str ) -> Result < ( ) > {
1578
+ if !check_skopeo ( ) {
1579
+ return Ok ( ( ) ) ;
1580
+ }
1542
1581
let fixture = Fixture :: new_v1 ( ) ?;
1543
1582
let baseimg = & fixture. export_container ( ) . await ?. 0 ;
1544
1583
let basepath = & match baseimg. transport {
@@ -1592,6 +1631,9 @@ async fn test_container_zstd_chunked() -> Result<()> {
1592
1631
/// We need to handle the case of modified hardlinks into /sysroot
1593
1632
#[ tokio:: test]
1594
1633
async fn test_container_write_derive_sysroot_hardlink ( ) -> Result < ( ) > {
1634
+ if !check_skopeo ( ) {
1635
+ return Ok ( ( ) ) ;
1636
+ }
1595
1637
let fixture = Fixture :: new_v1 ( ) ?;
1596
1638
let sh = fixture. new_shell ( ) ?;
1597
1639
let baseimg = & fixture. export_container ( ) . await ?. 0 ;
@@ -1688,6 +1730,9 @@ async fn test_container_write_derive_sysroot_hardlink() -> Result<()> {
1688
1730
// verifies that the old ostree-rs-ext code can parse the containers
1689
1731
// generated by the new ostree code.
1690
1732
async fn test_old_code_parses_new_export ( ) -> Result < ( ) > {
1733
+ if !check_skopeo ( ) {
1734
+ return Ok ( ( ) ) ;
1735
+ }
1691
1736
let rpmostree = Utf8Path :: new ( "/usr/bin/rpm-ostree" ) ;
1692
1737
if !rpmostree. exists ( ) {
1693
1738
return Ok ( ( ) ) ;
@@ -1722,6 +1767,9 @@ async fn test_old_code_parses_new_export() -> Result<()> {
1722
1767
/// Test for https://github.com/ostreedev/ostree-rs-ext/issues/655
1723
1768
#[ tokio:: test]
1724
1769
async fn test_container_xattr ( ) -> Result < ( ) > {
1770
+ if !check_skopeo ( ) {
1771
+ return Ok ( ( ) ) ;
1772
+ }
1725
1773
let fixture = Fixture :: new_v1 ( ) ?;
1726
1774
let sh = fixture. new_shell ( ) ?;
1727
1775
let baseimg = & fixture. export_container ( ) . await ?. 0 ;
0 commit comments