@@ -49,11 +49,14 @@ def main():
49
49
# import into the tmp/repo to get the ostree-commit but also so it's cached
50
50
ostree_commit = import_oci_archive (tmpd , tmp_oci_archive , buildid )
51
51
52
+ # artificially recreate generated lockfile
53
+ tmp_lockfile = generate_lockfile (tmpd , ostree_commit )
54
+
52
55
# create meta.json
53
56
build_meta = generate_build_meta (tmp_oci_archive , tmp_oci_manifest , metadata , ostree_commit )
54
57
55
58
# move into official location
56
- finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest )
59
+ finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest , tmp_lockfile )
57
60
58
61
subprocess .check_call (['/usr/lib/coreos-assembler/cmd-prune' ])
59
62
@@ -85,6 +88,25 @@ def generate_oci_manifest(args, tmpd):
85
88
return tmpf
86
89
87
90
91
+ def generate_lockfile (tmpd , ostree_commit ):
92
+ tmpf = os .path .join (tmpd , 'lockfile.json' )
93
+
94
+ out = subprocess .check_output (['rpm-ostree' , 'db' , 'list' , '--repo' , 'tmp/repo' , ostree_commit ], encoding = 'utf-8' )
95
+ rpmdb = {}
96
+ for line in out .splitlines ():
97
+ if not line .startswith (' ' ):
98
+ continue
99
+ n , ev , ra = line .strip ().rsplit ('-' , 2 )
100
+ rpmdb [n ] = {'evra' : f'{ ev } -{ ra } ' }
101
+
102
+ with open (tmpf , 'w' ) as f :
103
+ json .dump (fp = f , obj = {
104
+ 'packages' : rpmdb
105
+ })
106
+
107
+ return tmpf
108
+
109
+
88
110
def generate_build_meta (tmp_oci_archive , tmp_oci_manifest , metadata , ostree_commit ):
89
111
name = metadata ['Labels' ]['com.coreos.osname' ]
90
112
buildid = metadata ['Labels' ]['org.opencontainers.image.version' ]
@@ -117,7 +139,7 @@ def generate_build_meta(tmp_oci_archive, tmp_oci_manifest, metadata, ostree_comm
117
139
}
118
140
119
141
120
- def finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest ):
142
+ def finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest , tmp_lockfile ):
121
143
buildid = build_meta ['buildid' ]
122
144
arch = build_meta ['coreos-assembler.basearch' ]
123
145
@@ -126,6 +148,7 @@ def finalize_build(builds, build_meta, tmp_oci_archive, tmp_oci_manifest):
126
148
127
149
shutil .move (tmp_oci_archive , f'{ destdir } /{ build_meta ['images' ]['ostree' ]['path' ]} ' )
128
150
shutil .move (tmp_oci_manifest , f'{ destdir } /{ build_meta ['images' ]['oci-manifest' ]['path' ]} ' )
151
+ shutil .move (tmp_lockfile , f'{ destdir } /manifest-lock.generated.{ arch } .json' )
129
152
130
153
with open (f'{ destdir } /meta.json' , 'w' ) as f :
131
154
json .dump (build_meta , f , indent = 4 )
0 commit comments