@@ -30,112 +30,18 @@ func handleContainer(w worker) gwclient.BuildFunc {
30
30
return nil , nil , fmt .Errorf ("error creating rpm: %w" , err )
31
31
}
32
32
33
- rpms , err := readRPMs (ctx , client , rpmDir )
34
- if err != nil {
35
- return nil , nil , err
36
- }
37
-
38
- st , err := specToContainerLLB (w , spec , targetKey , rpmDir , rpms , sOpt , pg )
39
- if err != nil {
40
- return nil , nil , err
41
- }
42
-
43
- def , err := st .Marshal (ctx , pg )
44
- if err != nil {
45
- return nil , nil , fmt .Errorf ("error marshalling llb: %w" , err )
46
- }
47
-
48
- res , err := client .Solve (ctx , gwclient.SolveRequest {
49
- Definition : def .ToPB (),
50
- })
51
- if err != nil {
52
- return nil , nil , err
53
- }
54
-
55
33
img , err := resolveBaseConfig (ctx , w , client , platform , spec , targetKey )
56
34
if err != nil {
57
35
return nil , nil , errors .Wrap (err , "could not resolve base image config" )
58
36
}
59
37
60
- ref , err := res .SingleRef ()
61
- if err != nil {
62
- return nil , nil , err
63
- }
64
-
65
- base , err := w .Base (sOpt , pg )
66
- if err != nil {
67
- return nil , nil , err
68
- }
69
-
70
- withTestDeps := func (in llb.State ) llb.State {
71
- deps := spec .GetTestDeps (targetKey )
72
- if len (deps ) == 0 {
73
- return in
74
- }
75
- return base .Run (
76
- w .Install (spec .GetTestDeps (targetKey ), atRoot ("/tmp/rootfs" )),
77
- pg ,
78
- dalec .ProgressGroup ("Install test dependencies" ),
79
- ).AddMount ("/tmp/rootfs" , in )
80
- }
81
-
82
- if err := frontend .RunTests (ctx , client , spec , ref , withTestDeps , targetKey ); err != nil {
83
- return nil , nil , err
84
- }
85
-
38
+ ref , err := runTests (ctx , client , w , spec , sOpt , rpmDir , targetKey )
86
39
return ref , img , err
87
40
})
88
41
}
89
42
}
90
43
91
- func readRPMs (ctx context.Context , client gwclient.Client , st llb.State ) ([]string , error ) {
92
- def , err := st .Marshal (ctx )
93
- if err != nil {
94
- return nil , err
95
- }
96
-
97
- res , err := client .Solve (ctx , gwclient.SolveRequest {
98
- Definition : def .ToPB (),
99
- })
100
- if err != nil {
101
- return nil , err
102
- }
103
-
104
- ref , err := res .SingleRef ()
105
- if err != nil {
106
- return nil , err
107
- }
108
-
109
- // Directory layout will have arch-specific sub-folders and/or `noarch`
110
- // RPMs will be in those subdirectories.
111
- arches , err := ref .ReadDir (ctx , gwclient.ReadDirRequest {
112
- Path : "/RPMS" ,
113
- })
114
- if err != nil {
115
- return nil , errors .Wrap (err , "error reading output state" )
116
- }
117
-
118
- var out []string
119
-
120
- for _ , arch := range arches {
121
- files , err := ref .ReadDir (ctx , gwclient.ReadDirRequest {
122
- Path : filepath .Join ("/RPMS" , arch .Path ),
123
- IncludePattern : "*.rpm" ,
124
- })
125
-
126
- if err != nil {
127
- return nil , errors .Wrap (err , "could not read arch specific output dir" )
128
- }
129
-
130
- for _ , e := range files {
131
- out = append (out , filepath .Join (arch .Path , e .Path ))
132
- }
133
- }
134
-
135
- return out , nil
136
- }
137
-
138
- func specToContainerLLB (w worker , spec * dalec.Spec , targetKey string , rpmDir llb.State , files []string , sOpt dalec.SourceOpts , opts ... llb.ConstraintsOpt ) (llb.State , error ) {
44
+ func specToContainerLLB (w worker , spec * dalec.Spec , targetKey string , rpmDir llb.State , sOpt dalec.SourceOpts , opts ... llb.ConstraintsOpt ) (llb.State , error ) {
139
45
opts = append (opts , dalec .ProgressGroup ("Install RPMs" ))
140
46
const workPath = "/tmp/rootfs"
141
47
@@ -149,19 +55,15 @@ func specToContainerLLB(w worker, spec *dalec.Spec, targetKey string, rpmDir llb
149
55
rootfs = llb .Image (ref , llb .WithMetaResolver (sOpt .Resolver ), dalec .WithConstraints (opts ... ))
150
56
}
151
57
152
- if len (files ) > 0 {
153
- rpmMountDir := "/tmp/rpms"
154
- updated := w .BasePackages ()
155
- for _ , f := range files {
156
- updated = append (updated , filepath .Join (rpmMountDir , f ))
157
- }
58
+ rpmMountDir := "/tmp/rpms"
59
+ pkgs := w .BasePackages ()
60
+ pkgs = append (pkgs , filepath .Join (rpmMountDir , "**/*.rpm" ))
158
61
159
- rootfs = builderImg .Run (
160
- w .Install (updated , atRoot (workPath ), noGPGCheck , withManifests , installWithConstraints (opts )),
161
- llb .AddMount (rpmMountDir , rpmDir , llb .SourcePath ("/RPMS" )),
162
- dalec .WithConstraints (opts ... ),
163
- ).AddMount (workPath , rootfs )
164
- }
62
+ rootfs = builderImg .Run (
63
+ w .Install (pkgs , atRoot (workPath ), noGPGCheck , withManifests , installWithConstraints (opts )),
64
+ llb .AddMount (rpmMountDir , rpmDir , llb .SourcePath ("/RPMS" )),
65
+ dalec .WithConstraints (opts ... ),
66
+ ).AddMount (workPath , rootfs )
165
67
166
68
if post := spec .GetImagePost (targetKey ); post != nil && len (post .Symlinks ) > 0 {
167
69
rootfs = builderImg .
0 commit comments