diff options
Diffstat (limited to 'packaging')
-rw-r--r-- | packaging/License.rtf | 73 | ||||
-rwxr-xr-x | packaging/create_zipapp.py | 23 | ||||
-rwxr-xr-x | packaging/createmsi.py | 336 | ||||
-rwxr-xr-x | packaging/createpkg.py | 119 | ||||
-rw-r--r-- | packaging/hook-mesonbuild.py | 56 | ||||
-rw-r--r-- | packaging/macpages/English.lproj/conclusion.html | 24 | ||||
-rw-r--r-- | packaging/macpages/English.lproj/license.html | 209 | ||||
-rw-r--r-- | packaging/macpages/English.lproj/welcome.html | 12 |
8 files changed, 852 insertions, 0 deletions
diff --git a/packaging/License.rtf b/packaging/License.rtf new file mode 100644 index 0000000..b3945ba --- /dev/null +++ b/packaging/License.rtf @@ -0,0 +1,73 @@ +{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}} +{\colortbl ;\red0\green0\blue255;} +{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\qc\lang1033\b\f0\fs18 Apache License\par +Version 2.0, January 2004\par +{\field{\*\fldinst{HYPERLINK "http://www.apache.org/licenses/"}}{\fldrslt{\ul\cf1 http://www.apache.org/licenses/}}}\f0\fs18\par +\b0\par +\pard TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\par +\par +\pard\fi-180\li180 1. Definitions.\par +\par +\pard\li180 "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.\par +\par +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.\par +\par +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.\par +\par +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.\par +\par +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.\par +\par +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.\par +\par +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).\par +\par +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.\par +\par +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."\par +\par +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.\par +\pard\par +\pard\fi-180\li180 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.\par +\par +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.\par +\par +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:\par +\pard\par +\pard\fi-270\li450 (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and\par +\par +(b) You must cause any modified files to carry prominent notices stating that You changed the files; and\par +\par +(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and\par +\par +(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.\par +\pard\par +\pard\li180 You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.\par +\pard\par +\pard\fi-180\li180 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.\par +\par +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.\par +\par +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.\par +\par +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.\par +\par +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.\par +\pard\par +END OF TERMS AND CONDITIONS\par +\par +APPENDIX: How to apply the Apache License to your work.\par +\par +To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.\par +\par +\pard\li180 Copyright [yyyy] [name of copyright owner]\par +\par +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\par +\par +\pard\li360{\field{\*\fldinst{HYPERLINK "http://www.apache.org/licenses/LICENSE-2.0"}}{\fldrslt{\ul\cf1 http://www.apache.org/licenses/LICENSE-2.0}}}\f0\fs18\par +\pard\li180\par +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\par +\pard\par +\par +} + diff --git a/packaging/create_zipapp.py b/packaging/create_zipapp.py new file mode 100755 index 0000000..9fd0f5b --- /dev/null +++ b/packaging/create_zipapp.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +import argparse +from pathlib import Path +import shutil +import sys +import tempfile +import zipapp + +parser = argparse.ArgumentParser() +parser.add_argument('source', nargs='?', default='.', help='Source directory') +parser.add_argument('--outfile', default='meson.pyz', help='Output file for the zipapp') +parser.add_argument('--interpreter', default='/usr/bin/env python3', help='The name of the Python interpreter to use') +parser.add_argument('--compress', action='store_true', default=False, help='Compress files') + +options = parser.parse_args(sys.argv[1:]) + +source = Path(options.source).resolve() + +with tempfile.TemporaryDirectory() as d: + shutil.copy2(source / 'meson.py', Path(d, '__main__.py')) + shutil.copytree(source / 'mesonbuild', Path(d, 'mesonbuild')) + zipapp.create_archive(d, interpreter=options.interpreter, target=options.outfile, compressed=options.compress) diff --git a/packaging/createmsi.py b/packaging/createmsi.py new file mode 100755 index 0000000..fe49b7b --- /dev/null +++ b/packaging/createmsi.py @@ -0,0 +1,336 @@ +#!/usr/bin/env python3 + +# Copyright 2017-2021 The Meson development team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +''' +This script is for generating MSI packages +for Windows users. +''' + +import subprocess +import shutil +import uuid +import sys +import os +from glob import glob +import xml.etree.ElementTree as ET + +sys.path.append(os.getcwd()) +from mesonbuild import coredata + +# Elementtree does not support CDATA. So hack it. +WINVER_CHECK = '<![CDATA[Installed OR (VersionNT64 > 602)]]>' + +def gen_guid(): + ''' + Generate guid + ''' + return str(uuid.uuid4()).upper() + +class Node: + ''' + Node to hold path and directory values + ''' + + def __init__(self, dirs, files): + self.check_dirs(dirs) + self.check_files(files) + self.dirs = dirs + self.files = files + + @staticmethod + def check_dirs(dirs): + ''' + Check to see if directory is instance of list + ''' + assert isinstance(dirs, list) + + @staticmethod + def check_files(files): + ''' + Check to see if files is instance of list + ''' + assert isinstance(files, list) + + +class PackageGenerator: + ''' + Package generator for MSI packages + ''' + + def __init__(self): + self.product_name = 'Meson Build System' + self.manufacturer = 'The Meson Development Team' + self.version = coredata.version.replace('dev', '') + self.root = None + self.guid = '*' + self.update_guid = '141527EE-E28A-4D14-97A4-92E6075D28B2' + self.main_xml = 'meson.wxs' + self.main_o = 'meson.wixobj' + self.final_output = f'meson-{self.version}-64.msi' + self.staging_dirs = ['dist', 'dist2'] + self.progfile_dir = 'ProgramFiles64Folder' + redist_globs = ['C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Redist\\MSVC\\v*\\MergeModules\\Microsoft_VC142_CRT_x64.msm', + 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Redist\\MSVC\\v*\\MergeModules\\Microsoft_VC143_CRT_x64.msm'] + redist_path = None + for g in redist_globs: + trials = glob(g) + if len(trials) > 1: + sys.exit('MSM glob matched multiple entries:' + '\n'.join(trials)) + if len(trials) == 1: + redist_path = trials[0] + break + if redist_path is None: + sys.exit('No MSMs found.') + self.redist_path = redist_path + self.component_num = 0 + self.feature_properties = { + self.staging_dirs[0]: { + 'Id': 'MainProgram', + 'Title': 'Meson', + 'Description': 'Meson executables', + 'Level': '1', + 'Absent': 'disallow', + }, + self.staging_dirs[1]: { + 'Id': 'NinjaProgram', + 'Title': 'Ninja', + 'Description': 'Ninja build tool', + 'Level': '1', + } + } + self.feature_components = {} + for s_d in self.staging_dirs: + self.feature_components[s_d] = [] + + def build_dist(self): + ''' + Build dist file from PyInstaller info + ''' + for sdir in self.staging_dirs: + if os.path.exists(sdir): + shutil.rmtree(sdir) + main_stage, ninja_stage = self.staging_dirs + + pyinstaller = shutil.which('pyinstaller') + if not pyinstaller: + print("ERROR: This script requires pyinstaller.") + sys.exit(1) + + pyinstaller_tmpdir = 'pyinst-tmp' + if os.path.exists(pyinstaller_tmpdir): + shutil.rmtree(pyinstaller_tmpdir) + pyinst_cmd = [pyinstaller, + '--clean', + '--additional-hooks-dir=packaging', + '--distpath', + pyinstaller_tmpdir] + pyinst_cmd += ['meson.py'] + subprocess.check_call(pyinst_cmd) + shutil.move(pyinstaller_tmpdir + '/meson', main_stage) + self.del_infodirs(main_stage) + if not os.path.exists(os.path.join(main_stage, 'meson.exe')): + sys.exit('Meson exe missing from staging dir.') + os.mkdir(ninja_stage) + shutil.copy(shutil.which('ninja'), ninja_stage) + if not os.path.exists(os.path.join(ninja_stage, 'ninja.exe')): + sys.exit('Ninja exe missing from staging dir.') + + def del_infodirs(self, dirname): + # Starting with 3.9.something there are some + # extra metadatadirs that have a hyphen in their + # file names. This is a forbidden character in WiX + # filenames so delete them. + for d in glob(os.path.join(dirname, '*-info')): + shutil.rmtree(d) + + def generate_files(self): + ''' + Generate package files for MSI installer package + ''' + self.root = ET.Element('Wix', {'xmlns': 'http://schemas.microsoft.com/wix/2006/wi'}) + product = ET.SubElement(self.root, 'Product', { + 'Name': self.product_name, + 'Manufacturer': 'The Meson Development Team', + 'Id': self.guid, + 'UpgradeCode': self.update_guid, + 'Language': '1033', + 'Codepage': '1252', + 'Version': self.version, + }) + + package = ET.SubElement(product, 'Package', { + 'Id': '*', + 'Keywords': 'Installer', + 'Description': f'Meson {self.version} installer', + 'Comments': 'Meson is a high performance build system', + 'Manufacturer': 'The Meson Development Team', + 'InstallerVersion': '500', + 'Languages': '1033', + 'Compressed': 'yes', + 'SummaryCodepage': '1252', + }) + + condition = ET.SubElement(product, 'Condition', {'Message': 'This application is only supported on Windows 10 or higher.'}) + + condition.text = 'X'*len(WINVER_CHECK) + ET.SubElement(product, 'MajorUpgrade', + {'DowngradeErrorMessage': 'A newer version of Meson is already installed.'}) + + package.set('Platform', 'x64') + ET.SubElement(product, 'Media', { + 'Id': '1', + 'Cabinet': 'meson.cab', + 'EmbedCab': 'yes', + }) + targetdir = ET.SubElement(product, 'Directory', { + 'Id': 'TARGETDIR', + 'Name': 'SourceDir', + }) + progfiledir = ET.SubElement(targetdir, 'Directory', { + 'Id': self.progfile_dir, + }) + installdir = ET.SubElement(progfiledir, 'Directory', { + 'Id': 'INSTALLDIR', + 'Name': 'Meson', + }) + ET.SubElement(installdir, 'Merge', { + 'Id': 'VCRedist', + 'SourceFile': self.redist_path, + 'DiskId': '1', + 'Language': '0', + }) + + ET.SubElement(product, 'Property', { + 'Id': 'WIXUI_INSTALLDIR', + 'Value': 'INSTALLDIR', + }) + ET.SubElement(product, 'UIRef', { + 'Id': 'WixUI_FeatureTree', + }) + for s_d in self.staging_dirs: + assert os.path.isdir(s_d) + top_feature = ET.SubElement(product, 'Feature', { + 'Id': 'Complete', + 'Title': 'Meson ' + self.version, + 'Description': 'The complete package', + 'Display': 'expand', + 'Level': '1', + 'ConfigurableDirectory': 'INSTALLDIR', + }) + for s_d in self.staging_dirs: + nodes = {} + for root, dirs, files in os.walk(s_d): + cur_node = Node(dirs, files) + nodes[root] = cur_node + self.create_xml(nodes, s_d, installdir, s_d) + self.build_features(top_feature, s_d) + vcredist_feature = ET.SubElement(top_feature, 'Feature', { + 'Id': 'VCRedist', + 'Title': 'Visual C++ runtime', + 'AllowAdvertise': 'no', + 'Display': 'hidden', + 'Level': '1', + }) + ET.SubElement(vcredist_feature, 'MergeRef', {'Id': 'VCRedist'}) + ET.ElementTree(self.root).write(self.main_xml, encoding='utf-8', xml_declaration=True) + # ElementTree can not do prettyprinting so do it manually + import xml.dom.minidom + doc = xml.dom.minidom.parse(self.main_xml) + with open(self.main_xml, 'w') as open_file: + open_file.write(doc.toprettyxml()) + # One last fix, add CDATA. + with open(self.main_xml) as open_file: + data = open_file.read() + data = data.replace('X'*len(WINVER_CHECK), WINVER_CHECK) + with open(self.main_xml, 'w') as open_file: + open_file.write(data) + + def build_features(self, top_feature, staging_dir): + ''' + Generate build features + ''' + feature = ET.SubElement(top_feature, 'Feature', self.feature_properties[staging_dir]) + for component_id in self.feature_components[staging_dir]: + ET.SubElement(feature, 'ComponentRef', { + 'Id': component_id, + }) + + def create_xml(self, nodes, current_dir, parent_xml_node, staging_dir): + ''' + Create XML file + ''' + cur_node = nodes[current_dir] + if cur_node.files: + component_id = f'ApplicationFiles{self.component_num}' + comp_xml_node = ET.SubElement(parent_xml_node, 'Component', { + 'Id': component_id, + 'Guid': gen_guid(), + }) + self.feature_components[staging_dir].append(component_id) + comp_xml_node.set('Win64', 'yes') + if self.component_num == 0: + ET.SubElement(comp_xml_node, 'Environment', { + 'Id': 'Environment', + 'Name': 'PATH', + 'Part': 'last', + 'System': 'yes', + 'Action': 'set', + 'Value': '[INSTALLDIR]', + }) + self.component_num += 1 + for f_node in cur_node.files: + file_id = os.path.join(current_dir, f_node).replace('\\', '_').replace('#', '_').replace('-', '_') + ET.SubElement(comp_xml_node, 'File', { + 'Id': file_id, + 'Name': f_node, + 'Source': os.path.join(current_dir, f_node), + }) + + for dirname in cur_node.dirs: + dir_id = os.path.join(current_dir, dirname).replace('\\', '_').replace('/', '_') + dir_node = ET.SubElement(parent_xml_node, 'Directory', { + 'Id': dir_id, + 'Name': dirname, + }) + self.create_xml(nodes, os.path.join(current_dir, dirname), dir_node, staging_dir) + + def build_package(self): + ''' + Generate the Meson build MSI package. + ''' + wixdir = 'c:\\Program Files\\Wix Toolset v3.11\\bin' + if not os.path.isdir(wixdir): + wixdir = 'c:\\Program Files (x86)\\Wix Toolset v3.11\\bin' + if not os.path.isdir(wixdir): + print("ERROR: This script requires WIX") + sys.exit(1) + subprocess.check_call([os.path.join(wixdir, 'candle'), self.main_xml]) + subprocess.check_call([os.path.join(wixdir, 'light'), + '-ext', 'WixUIExtension', + '-cultures:en-us', + '-dWixUILicenseRtf=packaging\\License.rtf', + '-out', self.final_output, + self.main_o]) + +if __name__ == '__main__': + if not os.path.exists('meson.py'): + sys.exit(print('Run me in the top level source dir.')) + subprocess.check_call(['pip', 'install', '--upgrade', 'pyinstaller']) + + p = PackageGenerator() + p.build_dist() + p.generate_files() + p.build_package() diff --git a/packaging/createpkg.py b/packaging/createpkg.py new file mode 100755 index 0000000..70da656 --- /dev/null +++ b/packaging/createpkg.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python3 + +# Copyright 2017-2021 The Meson development team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import subprocess +import shutil, sys, os + +import xml.etree.ElementTree as ET + +sys.path.append(os.getcwd()) +from mesonbuild import coredata + +class PkgGenerator: + + def __init__(self): + self.pkg_dir = 'macpkg' + self.sharedir = os.path.join(self.pkg_dir, 'usr/local/share') + self.bindir = os.path.join(self.pkg_dir, 'usr/local/bin') + self.product_name = 'Meson Build System' + self.identifier = 'com.mesonbuild.meson' + self.version = coredata.version.replace('dev', '') + self.mesonstashdir = os.path.join(self.sharedir, f'meson-{self.version}') + self.pkgname = 'meson.pkg' + self.productname = f'meson-{self.version}.pkg' + self.distribution_file = 'meson-distribution.xml' + self.resourcedir = 'packaging/macpages' + + def build_dist(self): + if os.path.exists(self.pkg_dir): + shutil.rmtree(self.pkg_dir) + os.mkdir(self.pkg_dir) + pyinstaller_bin = '/Users/jpakkane/Library/Python/3.8/bin/pyinstaller' + pyinst_cmd = [pyinstaller_bin, + '--clean', + '--additional-hooks-dir=packaging', + '--distpath', + self.pkg_dir] + pyinst_cmd += ['meson.py'] + subprocess.check_call(pyinst_cmd) + tmpdir = os.path.join(self.pkg_dir, 'meson') + shutil.move(tmpdir, self.mesonstashdir) + os.makedirs(self.bindir) + ln_base = os.path.relpath(self.mesonstashdir, self.bindir) + ninja_bin = shutil.which('ninja') + assert ninja_bin + shutil.copy(ninja_bin, self.bindir) + subprocess.check_call(['strip', os.path.join(self.bindir, 'ninja')]) + os.symlink(os.path.join(ln_base, 'meson'), os.path.join(self.bindir, 'meson')) + + def build_package(self): + subprocess.check_call(['pkgbuild', + '--root', + self.pkg_dir, + '--identifier', + self.identifier, + self.pkgname]) + self.generate_distribution() + subprocess.check_call(['productbuild', + '--distribution', + self.distribution_file, + '--resources', + self.resourcedir, + self.productname]) + + def generate_distribution(self): + root = ET.Element('installer-gui-script', {'minSpecVersion': '1'}) + ET.SubElement(root, 'welcome', {'file': 'welcome.html', + 'mime-type': 'text/html'}) + ET.SubElement(root, 'license', {'file': 'license.html', + 'mime-type': 'text/html'}) + ET.SubElement(root, 'conclusion', {'file': 'conclusion.html', + 'mime-type': 'text/html'}) + ET.SubElement(root, 'pkg-ref', {'id': self.identifier}) + ET.SubElement(root, 'options', {'customize': 'never', + 'require-scripts': 'false', + 'hostArhcitectures': 'x86_64,arm64'}) + choices_outline = ET.SubElement(root, 'choices-outline') + line = ET.SubElement(choices_outline, 'line', {'choice': 'default'}) + ET.SubElement(line, 'line', {'choice': self.identifier}) + ET.SubElement(root, 'choice', {'id': 'default'}) + choice = ET.SubElement(root, 'choice', {'id': self.identifier, 'visible': 'false'}) + ET.SubElement(choice, 'pkg-ref', {'id': self.identifier}) + ET.SubElement(root, 'pkg-ref', {'id': self.identifier, + 'version': '0', # self.version, + 'onConclusion': 'none'}).text = self.pkgname + ET.ElementTree(root).write(self.distribution_file, encoding='utf-8', xml_declaration=True) + # ElementTree can not do prettyprinting so do it manually + import xml.dom.minidom + doc = xml.dom.minidom.parse(self.distribution_file) + with open(self.distribution_file, 'w') as open_file: + open_file.write(doc.toprettyxml()) + + def remove_tempfiles(self): + shutil.rmtree('macpkg') + os.unlink('meson-distribution.xml') + os.unlink('meson.pkg') + os.unlink('meson.spec') + +if __name__ == '__main__': + if not os.path.exists('meson.py'): + sys.exit(print('Run me in the top level source dir.')) + subprocess.check_call(['pip3', 'install', '--user', '--upgrade', 'pyinstaller']) + + pg = PkgGenerator() + pg.build_dist() + pg.build_package() + pg.remove_tempfiles() diff --git a/packaging/hook-mesonbuild.py b/packaging/hook-mesonbuild.py new file mode 100644 index 0000000..b076c50 --- /dev/null +++ b/packaging/hook-mesonbuild.py @@ -0,0 +1,56 @@ +#!hint/python3 + +""" +PyInstaller hook to make mesonbuild include everything it needs to. +""" + +import os +from glob import glob + +from PyInstaller.utils.hooks import collect_data_files + +datas = [] +hiddenimports = [] + +def get_all_modules_from_dir(dirname): + ''' + Get all modules required for Meson itself from directories. + ''' + modname = os.path.basename(dirname) + modules = [os.path.splitext(os.path.split(x)[1])[0] for x in glob(os.path.join(dirname, '*'))] + modules = ['mesonbuild.' + modname + '.' + x for x in modules if not x.startswith('_')] + return modules + +datas += collect_data_files('mesonbuild.scripts') +datas += collect_data_files('mesonbuild.cmake.data') +datas += collect_data_files('mesonbuild.dependencies.data') + +hiddenimports += get_all_modules_from_dir('mesonbuild/modules') +hiddenimports += get_all_modules_from_dir('mesonbuild/scripts') + +# Python packagers want to be minimal and only copy the things +# that they can see being used. They are blind to many things. +hiddenimports += [ + # we run distutils as a subprocess via INTROSPECT_COMMAND. + 'distutils.archive_util', + 'distutils.cmd', + 'distutils.config', + 'distutils.core', + 'distutils.debug', + 'distutils.dep_util', + 'distutils.dir_util', + 'distutils.dist', + 'distutils.errors', + 'distutils.extension', + 'distutils.fancy_getopt', + 'distutils.file_util', + 'distutils.spawn', + 'distutils.util', + 'distutils.version', + 'distutils.command.build_ext', + 'distutils.command.build', + 'distutils.command.install', + + # needed for gtk's find_program() scripts + 'filecmp', +] diff --git a/packaging/macpages/English.lproj/conclusion.html b/packaging/macpages/English.lproj/conclusion.html new file mode 100644 index 0000000..0522455 --- /dev/null +++ b/packaging/macpages/English.lproj/conclusion.html @@ -0,0 +1,24 @@ +<html> + <head> + </head> + <body> + + <h1>Install finished</h1> + + <p>The Meson build system is now installed. Note that Meson does not + provide any GUI applications, it is only usable from the command + line. You can verify if your installation of Meson is working by + running the following command in a terminal + </p> + + <pre> + $ meson --version + </pre> + + <p>If the system reports that the program could not be found + you might need to edit your configuration files so + that <code>/usr/local/bin</code> is in your path. + </p> + + </body> +</html> diff --git a/packaging/macpages/English.lproj/license.html b/packaging/macpages/English.lproj/license.html new file mode 100644 index 0000000..235e582 --- /dev/null +++ b/packaging/macpages/English.lproj/license.html @@ -0,0 +1,209 @@ +<html> + <head> + </head> + <body> + <pre> + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + <pre> + </body> +</html> diff --git a/packaging/macpages/English.lproj/welcome.html b/packaging/macpages/English.lproj/welcome.html new file mode 100644 index 0000000..3832223 --- /dev/null +++ b/packaging/macpages/English.lproj/welcome.html @@ -0,0 +1,12 @@ +<html> + <head> + </head> + <body> + + <h1>Meson build system installer</h1> + + <p> This package will install the command line tools of Meson to + this computer. + </p> + </body> +</html> |