1*86d41711SAndy Fiddaman# 2*86d41711SAndy Fiddaman# This file and its contents are supplied under the terms of the 3*86d41711SAndy Fiddaman# Common Development and Distribution License ("CDDL"), version 1.0. 4*86d41711SAndy Fiddaman# You may only use this file in accordance with the terms of version 5*86d41711SAndy Fiddaman# 1.0 of the CDDL. 6*86d41711SAndy Fiddaman# 7*86d41711SAndy Fiddaman# A full copy of the text of the CDDL should have accompanied this 8*86d41711SAndy Fiddaman# source. A copy of the CDDL is also available via the Internet at 9*86d41711SAndy Fiddaman# http://www.illumos.org/license/CDDL. 10*86d41711SAndy Fiddaman# 11*86d41711SAndy Fiddaman 12*86d41711SAndy Fiddaman# 13*86d41711SAndy Fiddaman# Copyright 2021 OmniOS Community Edition (OmniOSce) Association. 14*86d41711SAndy Fiddaman# 15*86d41711SAndy Fiddaman 16*86d41711SAndy Fiddaman# 17*86d41711SAndy Fiddaman# Package manifest check 18*86d41711SAndy Fiddaman# 19*86d41711SAndy Fiddaman 20*86d41711SAndy Fiddamanimport sys 21*86d41711SAndy Fiddamanfrom onbld.Checks.ProcessCheck import processcheck 22*86d41711SAndy Fiddaman 23*86d41711SAndy Fiddamandef check(fh, filename=None, output=sys.stderr, **opts): 24*86d41711SAndy Fiddaman if not filename: 25*86d41711SAndy Fiddaman filename = fh.name 26*86d41711SAndy Fiddaman 27*86d41711SAndy Fiddaman options = ['-c', '-f', 'v2'] 28*86d41711SAndy Fiddaman ret, tmpfile = processcheck('pkgfmt', options, fh, output) 29*86d41711SAndy Fiddaman tmpfile.close() 30*86d41711SAndy Fiddaman if ret == 0: 31*86d41711SAndy Fiddaman # Manifest passes validation 32*86d41711SAndy Fiddaman return 0 33*86d41711SAndy Fiddaman 34*86d41711SAndy Fiddaman output.write('{} is not in pkgfmt v2 form;\n'.format(filename)) 35*86d41711SAndy Fiddaman output.write('run `pkgfmt -f v2` on the file to re-format ' + 36*86d41711SAndy Fiddaman 'the manifest in-place\n') 37*86d41711SAndy Fiddaman 38*86d41711SAndy Fiddaman return 1 39*86d41711SAndy Fiddaman 40