@@ -49,11 +49,14 @@ def main():
4949 # import into the tmp/repo to get the ostree-commit but also so it's cached
5050 ostree_commit = import_oci_archive (tmpd , tmp_oci_archive , buildid )
5151
52+ # artificially recreate generated lockfile
53+ tmp_lockfile = generate_lockfile (tmpd , ostree_commit )
54+
5255 # create meta.json
5356 build_meta = generate_build_meta (tmp_oci_archive , tmp_oci_manifest , metadata , ostree_commit )
5457
5558 # 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 )
5760
5861 subprocess .check_call (['/usr/lib/coreos-assembler/cmd-prune' ])
5962
@@ -85,6 +88,25 @@ def generate_oci_manifest(args, tmpd):
8588 return tmpf
8689
8790
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+
88110def generate_build_meta (tmp_oci_archive , tmp_oci_manifest , metadata , ostree_commit ):
89111 name = metadata ['Labels' ]['com.coreos.osname' ]
90112 buildid = metadata ['Labels' ]['org.opencontainers.image.version' ]
@@ -117,7 +139,7 @@ def generate_build_meta(tmp_oci_archive, tmp_oci_manifest, metadata, ostree_comm
117139 }
118140
119141
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 ):
121143 buildid = build_meta ['buildid' ]
122144 arch = build_meta ['coreos-assembler.basearch' ]
123145
@@ -126,6 +148,7 @@ def finalize_build(builds, build_meta, tmp_oci_archive, tmp_oci_manifest):
126148
127149 shutil .move (tmp_oci_archive , f'{ destdir } /{ build_meta ['images' ]['ostree' ]['path' ]} ' )
128150 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' )
129152
130153 with open (f'{ destdir } /meta.json' , 'w' ) as f :
131154 json .dump (build_meta , f , indent = 4 )
0 commit comments