diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 91d4095..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "Builder"] - path = Builder - url = git@github.com:AtlasNX/Kosmos-Builder.git diff --git a/Builder b/Builder deleted file mode 160000 index c85f0ae..0000000 --- a/Builder +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c85f0aedc4bafd1d0983b828b90f36f1b962aabe diff --git a/Builder/.gitignore b/Builder/.gitignore new file mode 100644 index 0000000..576f5db --- /dev/null +++ b/Builder/.gitignore @@ -0,0 +1,138 @@ +config.py +.vscode + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ diff --git a/Builder/LICENSE.md b/Builder/LICENSE.md new file mode 100644 index 0000000..d511905 --- /dev/null +++ b/Builder/LICENSE.md @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/Builder/Modules/atmosphere/system_settings.ini b/Builder/Modules/atmosphere/system_settings.ini new file mode 100644 index 0000000..d88418f --- /dev/null +++ b/Builder/Modules/atmosphere/system_settings.ini @@ -0,0 +1,60 @@ +; Disable uploading error reports to Nintendo +[eupld] +upload_enabled = u8!0x0 + +; Control whether RO should ease its validation of NROs. +; (note: this is normally not necessary, and ips patches can be used.) +[ro] +ease_nro_restriction = u8!0x0 + +; Atmosphere custom settings +[atmosphere] +; Reboot from fatal automatically after some number of milliseconds. +; If field is not present or 0, fatal will wait indefinitely for user input. +fatal_auto_reboot_interval = u64!0x0 + +; Make the power menu's "reboot" button reboot to payload. +; Set to "normal" for normal reboot, "rcm" for rcm reboot. +power_menu_reboot_function = str!payload + +; Controls whether dmnt cheats should be toggled on or off by +; default. 1 = toggled on by default, 0 = toggled off by default. +dmnt_cheats_enabled_by_default = u8!0x0 + +; Controls whether dmnt should always save cheat toggle state +; for restoration on new game launch. 1 = always save toggles, +; 0 = only save toggles if toggle file exists. +dmnt_always_save_cheat_toggles = u8!0x0 + +; Enable writing to BIS partitions for HBL. +; This is probably undesirable for normal usage. +enable_hbl_bis_write = u8!0x0 + +; Enable reading the CAL0 partition for HBL. +; This is probably undesirable for normal usage. +enable_hbl_cal_read = u8!0x0 + +; Controls whether fs.mitm should redirect save files +; to directories on the sd card. +; 0 = Do not redirect, 1 = Redirect. +; NOTE: EXPERIMENTAL +; If you do not know what you are doing, do not touch this yet. +fsmitm_redirect_saves_to_sd = u8!0x0 + +; Controls whether to enable the deprecated hid mitm +; to fix compatibility with old homebrew. +; 0 = Do not enable, 1 = Enable. +; Please note this setting may be removed in a +; future release of Atmosphere. +enable_deprecated_hid_mitm = u8!0x0 + +[hbloader] +; Controls the size of the homebrew heap when running as applet. +; If set to zero, all available applet memory is used as heap. +; The default is zero. +applet_heap_size = u64!0x0 + +; Controls the amount of memory to reserve when running as applet +; for usage by other applets. This setting has no effect if +; applet_heap_size is non-zero. The default is 0x8600000. +applet_heap_reservation_size = u64!0x8600000 diff --git a/Builder/Modules/emuiibo/toolbox.json b/Builder/Modules/emuiibo/toolbox.json new file mode 100644 index 0000000..8e4cab2 --- /dev/null +++ b/Builder/Modules/emuiibo/toolbox.json @@ -0,0 +1,5 @@ +{ + "name" : "emuiibo", + "tid" : "0100000000000352", + "requires_reboot": true +} diff --git a/Builder/Modules/hekate/bootlogo.bmp b/Builder/Modules/hekate/bootlogo.bmp new file mode 100644 index 0000000..7bc5148 Binary files /dev/null and b/Builder/Modules/hekate/bootlogo.bmp differ diff --git a/Builder/Modules/hekate/hekate_ipl.ini b/Builder/Modules/hekate/hekate_ipl.ini new file mode 100644 index 0000000..219e1fd --- /dev/null +++ b/Builder/Modules/hekate/hekate_ipl.ini @@ -0,0 +1,41 @@ +[config] +autoboot=0 +autoboot_list=0 +bootwait=1 +verification=1 +backlight=100 +autohosoff=0 +autonogc=1 +updater2p=1 + +{AtlasNX/Kosmos KOSMOS_VERSION} +{} +{Discord: discord.teamatlasnx.com} +{Github: git.teamatlasnx.com} +{Patreon: patreon.teamatlasnx.com} +{Pegascape DNS: pegascape.sdsetup.com} +{} + +{--- Custom Firmware ---} +[CFW (SYSNAND)] +emummc_force_disable=1 +fss0=atmosphere/fusee-secondary.bin +atmosphere=1 +logopath=bootloader/bootlogo.bmp +icon=bootloader/res/icon_payload.bmp +{} + +[CFW (EMUMMC)] +fss0=atmosphere/fusee-secondary.bin +atmosphere=1 +logopath=bootloader/bootlogo.bmp +icon=bootloader/res/icon_payload.bmp +{} + +{--- Stock ---} +[Stock (SYSNAND)] +emummc_force_disable=1 +fss0=atmosphere/fusee-secondary.bin +stock=1 +icon=bootloader/res/icon_switch.bmp +{} diff --git a/Builder/Modules/kosmos-toolbox/config.json b/Builder/Modules/kosmos-toolbox/config.json new file mode 100644 index 0000000..340c6c3 --- /dev/null +++ b/Builder/Modules/kosmos-toolbox/config.json @@ -0,0 +1,29 @@ +{ + "sysmodules" : [ + { + "name" : "bootsoundnx", + "tid" : "00FF0000000002AA", + "requires_reboot": true + }, + { + "name" : "hid-mitm", + "tid" : "0100000000000FAF", + "requires_reboot": true + }, + { + "name" : "nxsh", + "tid" : "43000000000000FF", + "requires_reboot": false + }, + { + "name" : "ojds-nx", + "tid" : "0100000000000901", + "requires_reboot": false + }, + { + "name" : "sys-netcheat", + "tid" : "430000000000000A", + "requires_reboot": false + } + ] +} diff --git a/Builder/Modules/kosmos-updater/internal.db b/Builder/Modules/kosmos-updater/internal.db new file mode 100644 index 0000000..64c6387 --- /dev/null +++ b/Builder/Modules/kosmos-updater/internal.db @@ -0,0 +1,5 @@ +version = "KOSMOS_VERSION"; +installed_files = [ ]; +received_exfat_warning = false; +received_ignore_config_warning = false; +ignore_config_files = false; diff --git a/Builder/Modules/ldn_mitm/toolbox.json b/Builder/Modules/ldn_mitm/toolbox.json new file mode 100644 index 0000000..b2529ac --- /dev/null +++ b/Builder/Modules/ldn_mitm/toolbox.json @@ -0,0 +1,5 @@ +{ + "name" : "ldn_mitm", + "tid" : "4200000000000010", + "requires_reboot": true +} diff --git a/Builder/Modules/sys-clk/toolbox.json b/Builder/Modules/sys-clk/toolbox.json new file mode 100644 index 0000000..6b425cd --- /dev/null +++ b/Builder/Modules/sys-clk/toolbox.json @@ -0,0 +1,5 @@ +{ + "name" : "sys-clk", + "tid" : "00FF0000636C6BFF", + "requires_reboot": false +} diff --git a/Builder/Modules/sys-ftpd-light/toolbox.json b/Builder/Modules/sys-ftpd-light/toolbox.json new file mode 100644 index 0000000..3bae078 --- /dev/null +++ b/Builder/Modules/sys-ftpd-light/toolbox.json @@ -0,0 +1,5 @@ +{ + "name" : "sys-ftpd-light", + "tid" : "420000000000000E", + "requires_reboot": false +} diff --git a/Builder/builder.py b/Builder/builder.py new file mode 100644 index 0000000..3691106 --- /dev/null +++ b/Builder/builder.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python +# +# Kosmos Builder +# Copyright (C) 2020 Nichole Mattera +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# + +import argparse +import common +import config +import modules +import os +import shutil +import sys + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument( + '-v', '--version', + default=None, + type=str, + help='Overides the Kosmos Version from the config file.', + metavar='KosmosVersion') + subparsers = parser.add_subparsers() + + # Kosmos subcommands + parser_kosmos = subparsers.add_parser('kosmos', help='Create a release build of Kosmos.') + parser_kosmos.add_argument('output', help='Zip file to create.') + parser_kosmos.set_defaults(command=common.Command.Kosmos) + + # SDSetup subcommands + parser_sdsetup = subparsers.add_parser('sdsetup', help='Create a Kosmos modules for SDSetup.') + parser_sdsetup.add_argument('output', help='Directory to output modules to.') + parser_sdsetup.add_argument( + '-a', '--auto', + action='store_true', + default=False, + help='Perform an auto build.') + parser_sdsetup.set_defaults(command=common.Command.SDSetup) + + # Parse arguments + args = parser.parse_args() + + if not hasattr(args, 'command'): + parser.print_help() + sys.exit() + + return args + +def get_kosmos_version(args): + if args.version is not None: + return args.version + return config.version + +def init_version_messages(args, kosmos_version): + if args.command == common.Command.Kosmos: + return [ f'Kosmos {kosmos_version} built with:' ] + elif args.command == common.Command.SDSetup and not args.auto: + return [ 'SDSetup Modules built with:' ] + return [] + +if __name__ == '__main__': + args = parse_args() + + temp_directory = common.generate_temp_path() + os.makedirs(temp_directory) + kosmos_version = get_kosmos_version(args) + + auto_build = False + if hasattr(args, 'auto'): + auto_build = args.auto + + version_messages = init_version_messages(args, kosmos_version) + + is_kosmos_build = args.command == common.Command.Kosmos + build_messages = modules.build(temp_directory, kosmos_version, is_kosmos_build, auto_build) + + common.delete_path(args.output) + + if build_messages is not None: + version_messages += build_messages + + if is_kosmos_build: + shutil.make_archive( + os.path.splitext(args.output)[0], + 'zip', + temp_directory) + else: + shutil.move(temp_directory, args.output) + + common.delete_path(os.path.join(os.getcwd(), 'tmp')) + + for message in version_messages: + print(message) + else: + common.delete_path(os.path.join(os.getcwd(), 'tmp')) diff --git a/Builder/common.py b/Builder/common.py new file mode 100644 index 0000000..e505bea --- /dev/null +++ b/Builder/common.py @@ -0,0 +1,62 @@ +# +# Kosmos Builder +# Copyright (C) 2020 Nichole Mattera +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# + +import enum +import glob +import os +import re +import shutil +import uuid + +class Command(enum.Enum): + Kosmos = 0 + SDSetup = 1 + +class GitService(enum.Enum): + GitHub = 0 + GitLab = 1 + +def generate_temp_path(): + return os.path.join(os.getcwd(), 'tmp', str(uuid.uuid4())) + +def delete_path(path): + if os.path.exists(path): + if os.path.isfile(path): + os.remove(path) + else: + shutil.rmtree(path) + +def copy_module_file(module_name, file_name, destination): + return shutil.copyfile(os.path.join(os.getcwd(), 'Modules', module_name, file_name), destination) + +def find_file(pattern): + return glob.glob(pattern, recursive=False) + +def sed(pattern, replace, file_path): + lines = [] + with open(file_path, 'r') as text_file: + lines += text_file.readlines() + with open(file_path, 'w') as text_file: + for line in lines: + text_file.write(re.sub(pattern, replace, line)) + +def mkdir(path): + if not os.path.exists(path): + os.makedirs(path) diff --git a/Builder/config_template.py b/Builder/config_template.py new file mode 100644 index 0000000..05ae396 --- /dev/null +++ b/Builder/config_template.py @@ -0,0 +1,9 @@ +# Current version of Kosmos +version = 'v15.1' + +# GitHub Login Information +github_username = '' +github_password = '' + +# GitLab Login Information +gitlab_private_access_token = '' diff --git a/Builder/modules.json b/Builder/modules.json new file mode 100644 index 0000000..2b93553 --- /dev/null +++ b/Builder/modules.json @@ -0,0 +1,326 @@ +[ + { + "name": "Atmosphère", + "download_function_name": "download_atmosphere", + "git": { + "service": 0, + "org_name": "Atmosphere-NX", + "repo_name": "Atmosphere", + "asset_patterns": [ + ".*atmosphere.*\\.zip", + ".*fusee.*\\.bin" + ], + "group": null + }, + "sdsetup": { + "included": true, + "name": "must_have" + } + }, + { + "name": "Hekate", + "download_function_name": "download_hekate", + "git": { + "service": 0, + "org_name": "CTCaer", + "repo_name": "hekate", + "asset_patterns": [ + ".*hekate.*\\.zip" + ], + "group": null + }, + "sdsetup": { + "included": true, + "name": "hekate" + } + }, + { + "name": "Homebrew App Store", + "download_function_name": "download_appstore", + "git": { + "service": 1, + "org_name": "4TU", + "repo_name": "hb-appstore", + "asset_patterns": [ + "\\[.*\\.nro\\.zip\\]\\((.*\\.nro\\.zip)\\)" + ], + "group": 0 + }, + "sdsetup": { + "included": false, + "name": null + } + }, + { + "name": "EdiZon", + "download_function_name": "download_edizon", + "git": { + "service": 0, + "org_name": "WerWolv", + "repo_name": "EdiZon", + "asset_patterns": [ + ".*\\.nro" + ], + "group": null + }, + "sdsetup": { + "included": false, + "name": null + } + }, + { + "name": "Emuiibo", + "download_function_name": "download_emuiibo", + "git": { + "service": 0, + "org_name": "XorTroll", + "repo_name": "emuiibo", + "asset_patterns": [ + ".*emuiibo.*\\.zip" + ], + "group": null + }, + "sdsetup": { + "included": true, + "name": "emuiibo" + } + }, + { + "name": "Goldleaf", + "download_function_name": "download_goldleaf", + "git": { + "service": 0, + "org_name": "XorTroll", + "repo_name": "Goldleaf", + "asset_patterns": [ + ".*\\.nro" + ], + "group": null + }, + "sdsetup": { + "included": false, + "name": null + } + }, + { + "name": "Kosmos Toolbox", + "download_function_name": "download_kosmos_toolbox", + "git": { + "service": 0, + "org_name": "AtlasNX", + "repo_name": "Kosmos-Toolbox", + "asset_patterns": [ + ".*\\.nro" + ], + "group": null + }, + "sdsetup": { + "included": true, + "name": "kosmos_toolbox" + } + }, + { + "name": "Kosmos Updater", + "download_function_name": "download_kosmos_updater", + "git": { + "service": 0, + "org_name": "AtlasNX", + "repo_name": "Kosmos-Updater", + "asset_patterns": [ + ".*\\.nro" + ], + "group": null + }, + "sdsetup": { + "included": true, + "name": "kosmos_updater" + } + }, + { + "name": "ldn_mitm", + "download_function_name": "download_ldn_mitm", + "git": { + "service": 0, + "org_name": "spacemeowx2", + "repo_name": "ldn_mitm", + "asset_patterns": [ + ".*ldn_mitm.*\\.zip" + ], + "group": null + }, + "sdsetup": { + "included": true, + "name": "ldn_mitm" + } + }, + { + "name": "Lockpick", + "download_function_name": "download_lockpick", + "git": { + "service": 0, + "org_name": "shchmue", + "repo_name": "Lockpick", + "asset_patterns": [ + ".*\\.nro" + ], + "group": null + }, + "sdsetup": { + "included": false, + "name": null + } + }, + { + "name": "Lockpick_RCM", + "download_function_name": "download_lockpick_rcm", + "git": { + "service": 0, + "org_name": "shchmue", + "repo_name": "Lockpick_RCM", + "asset_patterns": [ + ".*\\.bin" + ], + "group": null + }, + "sdsetup": { + "included": true, + "name": "lockpick_rcm" + } + }, + { + "name": "nxdumptool", + "download_function_name": "download_nxdumptool", + "git": { + "service": 0, + "org_name": "DarkMatterCore", + "repo_name": "nxdumptool", + "asset_patterns": [ + ".*nxdumptool.*\\.nro" + ], + "group": null + }, + "sdsetup": { + "included": false, + "name": null + } + }, + { + "name": "nx-ovlloader", + "download_function_name": "download_nx_ovlloader", + "git": { + "service": 0, + "org_name": "WerWolv", + "repo_name": "nx-ovlloader", + "asset_patterns": [ + ".*\\.zip" + ], + "group": null + }, + "sdsetup": { + "included": true, + "name": "nx_ovlloader" + } + }, + { + "name": "ovlSysModules", + "download_function_name": "download_ovl_sysmodules", + "git": { + "service": 0, + "org_name": "WerWolv", + "repo_name": "ovl-sysmodules", + "asset_patterns": [ + ".*\\.ovl" + ], + "group": null + }, + "sdsetup": { + "included": true, + "name": "ovl_sysmodules" + } + }, + { + "name": "Status Monitor Overlay", + "download_function_name": "download_status_monitor_overlay", + "git": { + "service": 0, + "org_name": "masagrator", + "repo_name": "Status-Monitor-Overlay", + "asset_patterns": [ + ".*\\.ovl" + ], + "group": null + }, + "sdsetup": { + "included": true, + "name": "status_monitor_overlay" + } + }, + { + "name": "sys-clk", + "download_function_name": "download_sys_clk", + "git": { + "service": 0, + "org_name": "retronx-team", + "repo_name": "sys-clk", + "asset_patterns": [ + ".*sys-clk-.*\\.zip" + ], + "group": null + }, + "sdsetup": { + "included": true, + "name": "sys_clk" + } + }, + { + "name": "sys-con", + "download_function_name": "download_sys_con", + "git": { + "service": 0, + "org_name": "cathery", + "repo_name": "sys-con", + "asset_patterns": [ + ".*sys-con-.*\\.zip" + ], + "group": null + }, + "sdsetup": { + "included": true, + "name": "sys_con" + } + }, + { + "name": "sys-ftpd-light", + "download_function_name": "download_sys_ftpd_light", + "git": { + "service": 0, + "org_name": "cathery", + "repo_name": "sys-ftpd-light", + "asset_patterns": [ + ".*sys-ftpd-light.*\\.zip" + ], + "group": null + }, + "sdsetup": { + "included": true, + "name": "sys_ftpd" + } + }, + { + "name": "Tesla-Menu", + "download_function_name": "download_tesla_menu", + "git": { + "service": 0, + "org_name": "WerWolv", + "repo_name": "Tesla-Menu", + "asset_patterns": [ + ".*\\.zip" + ], + "group": null + }, + "sdsetup": { + "included": true, + "name": "tesla_menu" + } + } +] diff --git a/Builder/modules.py b/Builder/modules.py new file mode 100644 index 0000000..beb6a93 --- /dev/null +++ b/Builder/modules.py @@ -0,0 +1,440 @@ +# +# Kosmos Builder +# Copyright (C) 2020 Nichole Mattera +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# + +import common +import config +from github import Github +from gitlab import Gitlab +import json +import os +import re +import shutil +import urllib.request +import uuid +import zipfile + +gh = Github(config.github_username, config.github_password) +gl = Gitlab('https://gitlab.com', private_token=config.gitlab_private_access_token) +gl.auth() + +def get_latest_release(module): + if common.GitService(module['git']['service']) == common.GitService.GitHub: + try: + repo = gh.get_repo(f'{module["git"]["org_name"]}/{module["git"]["repo_name"]}') + except: + print(f'[Error] Unable to find repo: {module["git"]["org_name"]}/{module["git"]["repo_name"]}') + return None + + releases = repo.get_releases() + if releases.totalCount == 0: + print(f'[Error] Unable to find any releases for repo: {module["git"]["org_name"]}/{module["git"]["repo_name"]}') + return None + + return releases[0] + else: + try: + project = gl.projects.get(f'{module["git"]["org_name"]}/{module["git"]["repo_name"]}') + except: + print(f'[Error] Unable to find repo: {module["git"]["org_name"]}/{module["git"]["repo_name"]}') + return None + + tags = project.tags.list() + for tag in tags: + if tag.release is not None: + return tag + + print(f'[Error] Unable to find any releases for repo: {module["git"]["org_name"]}/{module["git"]["repo_name"]}') + return None + +def download_asset(module, release, index): + pattern = module['git']['asset_patterns'][index] + + if common.GitService(module['git']['service']) == common.GitService.GitHub: + if release is None: + return None + + matched_asset = None + for asset in release.get_assets(): + if re.search(pattern, asset.name): + matched_asset = asset + break + + if matched_asset is None: + print(f'[Error] Unable to find asset that match pattern: "{pattern}"') + return None + + download_path = common.generate_temp_path() + urllib.request.urlretrieve(matched_asset.browser_download_url, download_path) + + return download_path + else: + group = module['git']['group'] + + match = re.search(pattern, release.release['description']) + if match is None: + return None + + groups = match.groups() + if len(groups) <= group: + return None + + download_path = common.generate_temp_path() + urllib.request.urlretrieve(f'https://gitlab.com/{module["git"]["org_name"]}/{module["git"]["repo_name"]}{groups[group]}', download_path) + + return download_path + +def find_asset(release, pattern): + for asset in release.get_assets(): + if re.search(pattern, asset.name): + return asset + + return None + +def download_atmosphere(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + bundle_path = download_asset(module, release, 0) + if bundle_path is None: + return None + + with zipfile.ZipFile(bundle_path, 'r') as zip_ref: + zip_ref.extractall(temp_directory) + + common.delete_path(bundle_path) + common.delete_path(os.path.join(temp_directory, 'switch', 'reboot_to_payload.nro')) + common.delete_path(os.path.join(temp_directory, 'atmosphere', 'reboot_payload.bin')) + + payload_path = download_asset(module, release, 1) + if payload_path is None: + return None + + common.mkdir(os.path.join(temp_directory, 'bootloader', 'payloads')) + shutil.move(payload_path, os.path.join(temp_directory, 'bootloader', 'payloads', 'fusee-primary.bin')) + common.copy_module_file('atmosphere', 'system_settings.ini', os.path.join(temp_directory, 'atmosphere', 'config', 'system_settings.ini')) + + if not kosmos_build: + common.delete_path(os.path.join(temp_directory, 'hbmenu.nro')) + + return release.tag_name + +def download_hekate(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + bundle_path = download_asset(module, release, 0) + if bundle_path is None: + return None + + with zipfile.ZipFile(bundle_path, 'r') as zip_ref: + zip_ref.extractall(temp_directory) + + common.delete_path(bundle_path) + + common.copy_module_file('hekate', 'bootlogo.bmp', os.path.join(temp_directory, 'bootloader', 'bootlogo.bmp')) + common.copy_module_file('hekate', 'hekate_ipl.ini', os.path.join(temp_directory, 'bootloader', 'hekate_ipl.ini')) + common.sed('KOSMOS_VERSION', kosmos_version, os.path.join(temp_directory, 'bootloader', 'hekate_ipl.ini')) + + payload = common.find_file(os.path.join(temp_directory, 'hekate_ctcaer_*.bin')) + if len(payload) != 0: + shutil.copyfile(payload[0], os.path.join(temp_directory, 'bootloader', 'update.bin')) + common.mkdir(os.path.join(temp_directory, 'atmosphere')) + shutil.copyfile(payload[0], os.path.join(temp_directory, 'atmosphere', 'reboot_payload.bin')) + + if not kosmos_build: + common.mkdir(os.path.join(temp_directory, '..', 'must_have')) + shutil.move(os.path.join(temp_directory, 'bootloader'), os.path.join(temp_directory, '..', 'must_have')) + shutil.move(os.path.join(temp_directory, 'atmosphere'), os.path.join(temp_directory, '..', 'must_have')) + + return release.tag_name + +def download_appstore(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + bundle_path = download_asset(module, release, 0) + if bundle_path is None: + return None + + with zipfile.ZipFile(bundle_path, 'r') as zip_ref: + zip_ref.extractall(temp_directory) + + common.delete_path(bundle_path) + common.mkdir(os.path.join(temp_directory, 'switch', 'appstore')) + shutil.move(os.path.join(temp_directory, 'appstore.nro'), os.path.join(temp_directory, 'switch', 'appstore', 'appstore.nro')) + + return release.name + +def download_edizon(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + app_path = download_asset(module, release, 0) + if app_path is None: + return None + + common.mkdir(os.path.join(temp_directory, 'switch', 'EdiZon')) + shutil.move(app_path, os.path.join(temp_directory, 'switch', 'EdiZon', 'EdiZon.nro')) + + return release.tag_name + +def download_emuiibo(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + bundle_path = download_asset(module, release, 0) + if bundle_path is None: + return None + + with zipfile.ZipFile(bundle_path, 'r') as zip_ref: + zip_ref.extractall(temp_directory) + + common.delete_path(bundle_path) + common.mkdir(os.path.join(temp_directory, 'atmosphere', 'contents')) + shutil.move(os.path.join(temp_directory, 'contents', '0100000000000352'), os.path.join(temp_directory, 'atmosphere', 'contents', '0100000000000352')) + common.delete_path(os.path.join(temp_directory, 'contents')) + if kosmos_build: + common.delete_path(os.path.join(temp_directory, 'atmosphere', 'contents', '0100000000000352', 'flags', 'boot2.flag')) + common.copy_module_file('emuiibo', 'toolbox.json', os.path.join(temp_directory, 'atmosphere', 'contents', '0100000000000352', 'toolbox.json')) + + return release.tag_name + +def download_goldleaf(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + app_path = download_asset(module, release, 0) + if app_path is None: + return None + + common.mkdir(os.path.join(temp_directory, 'switch', 'Goldleaf')) + shutil.move(app_path, os.path.join(temp_directory, 'switch', 'Goldleaf', 'Goldleaf.nro')) + + return release.tag_name + +def download_kosmos_toolbox(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + app_path = download_asset(module, release, 0) + if app_path is None: + return None + + common.mkdir(os.path.join(temp_directory, 'switch', 'KosmosToolbox')) + shutil.move(app_path, os.path.join(temp_directory, 'switch', 'KosmosToolbox', 'KosmosToolbox.nro')) + common.copy_module_file('kosmos-toolbox', 'config.json', os.path.join(temp_directory, 'switch', 'KosmosToolbox', 'config.json')) + + return release.tag_name + +def download_kosmos_updater(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + app_path = download_asset(module, release, 0) + if app_path is None: + return None + + common.mkdir(os.path.join(temp_directory, 'switch', 'KosmosUpdater')) + shutil.move(app_path, os.path.join(temp_directory, 'switch', 'KosmosUpdater', 'KosmosUpdater.nro')) + common.copy_module_file('kosmos-updater', 'internal.db', os.path.join(temp_directory, 'switch', 'KosmosUpdater', 'internal.db')) + common.sed('KOSMOS_VERSION', kosmos_version, os.path.join(temp_directory, 'switch', 'KosmosUpdater', 'internal.db')) + + return release.tag_name + +def download_ldn_mitm(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + bundle_path = download_asset(module, release, 0) + if bundle_path is None: + return None + + with zipfile.ZipFile(bundle_path, 'r') as zip_ref: + zip_ref.extractall(temp_directory) + + common.delete_path(bundle_path) + if kosmos_build: + common.delete_path(os.path.join(temp_directory, 'atmosphere', 'contents', '4200000000000010', 'flags', 'boot2.flag')) + common.copy_module_file('ldn_mitm', 'toolbox.json', os.path.join(temp_directory, 'atmosphere', 'contents', '4200000000000010', 'toolbox.json')) + + return release.tag_name + +def download_lockpick(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + app_path = download_asset(module, release, 0) + if app_path is None: + return None + + common.mkdir(os.path.join(temp_directory, 'switch', 'Lockpick')) + shutil.move(app_path, os.path.join(temp_directory, 'switch', 'Lockpick', 'Lockpick.nro')) + + return release.tag_name + +def download_lockpick_rcm(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + payload_path = download_asset(module, release, 0) + if payload_path is None: + return None + + if kosmos_build: + common.mkdir(os.path.join(temp_directory, 'bootloader', 'payloads')) + shutil.move(payload_path, os.path.join(temp_directory, 'bootloader', 'payloads', 'Lockpick_RCM.bin')) + else: + shutil.move(payload_path, os.path.join(temp_directory, 'Lockpick_RCM.bin')) + + return release.tag_name + +def download_nxdumptool(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + app_path = download_asset(module, release, 0) + if app_path is None: + return None + + common.mkdir(os.path.join(temp_directory, 'switch', 'NXDumpTool')) + shutil.move(app_path, os.path.join(temp_directory, 'switch', 'NXDumpTool', 'NXDumpTool.nro')) + + return release.tag_name + +def download_nx_ovlloader(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + bundle_path = download_asset(module, release, 0) + if bundle_path is None: + return None + + with zipfile.ZipFile(bundle_path, 'r') as zip_ref: + zip_ref.extractall(temp_directory) + + common.delete_path(bundle_path) + + return release.tag_name + +def download_ovl_sysmodules(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + app_path = download_asset(module, release, 0) + if app_path is None: + return None + + common.mkdir(os.path.join(temp_directory, 'switch', '.overlays')) + shutil.move(app_path, os.path.join(temp_directory, 'switch', '.overlays', 'ovlSysmodules.ovl')) + + return release.tag_name + +def download_status_monitor_overlay(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + app_path = download_asset(module, release, 0) + if app_path is None: + return None + + common.mkdir(os.path.join(temp_directory, 'switch', '.overlays')) + shutil.move(app_path, os.path.join(temp_directory, 'switch', '.overlays', 'Status-Monitor-Overlay.ovl')) + + return release.tag_name + +def download_sys_clk(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + bundle_path = download_asset(module, release, 0) + if bundle_path is None: + return None + + with zipfile.ZipFile(bundle_path, 'r') as zip_ref: + zip_ref.extractall(temp_directory) + + common.delete_path(bundle_path) + common.mkdir(os.path.join(temp_directory, 'atmosphere', 'contents')) + shutil.move(os.path.join(temp_directory, 'atmosphere', 'titles', '00FF0000636C6BFF'), os.path.join(temp_directory, 'atmosphere', 'contents', '00FF0000636C6BFF')) + common.delete_path(os.path.join(temp_directory, 'atmosphere', 'titles')) + if kosmos_build: + common.delete_path(os.path.join(temp_directory, 'atmosphere', 'contents', '00FF0000636C6BFF', 'flags', 'boot2.flag')) + common.delete_path(os.path.join(temp_directory, 'README.md')) + common.copy_module_file('sys-clk', 'toolbox.json', os.path.join(temp_directory, 'atmosphere', 'contents', '00FF0000636C6BFF', 'toolbox.json')) + + return release.tag_name + +def download_sys_con(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + bundle_path = download_asset(module, release, 0) + if bundle_path is None: + return None + + with zipfile.ZipFile(bundle_path, 'r') as zip_ref: + zip_ref.extractall(temp_directory) + + common.delete_path(bundle_path) + if kosmos_build: + common.delete_path(os.path.join(temp_directory, 'atmosphere', 'contents', '690000000000000D', 'flags', 'boot2.flag')) + + return release.tag_name + +def download_sys_ftpd_light(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + bundle_path = download_asset(module, release, 0) + if bundle_path is None: + return None + + with zipfile.ZipFile(bundle_path, 'r') as zip_ref: + zip_ref.extractall(temp_directory) + + common.delete_path(bundle_path) + if kosmos_build: + common.delete_path(os.path.join(temp_directory, 'atmosphere', 'contents', '420000000000000E', 'flags', 'boot2.flag')) + common.copy_module_file('sys-ftpd-light', 'toolbox.json', os.path.join(temp_directory, 'atmosphere', 'contents', '420000000000000E', 'toolbox.json')) + + return release.tag_name + +def download_tesla_menu(module, temp_directory, kosmos_version, kosmos_build): + release = get_latest_release(module) + bundle_path = download_asset(module, release, 0) + if bundle_path is None: + return None + + with zipfile.ZipFile(bundle_path, 'r') as zip_ref: + zip_ref.extractall(temp_directory) + + common.delete_path(bundle_path) + + return release.tag_name + +def build(temp_directory, kosmos_version, kosmos_build, auto_build): + results = [] + + # Open up modules.json + with open('modules.json') as json_file: + # Parse JSON + data = json.load(json_file) + + # Loop through modules + for module in data: + sdsetup_opts = module['sdsetup'] + + # Running a Kosmos Build + if kosmos_build: + # Download the module. + print(f'Downloading {module["name"]}...') + download = globals()[module['download_function_name']] + version = download(module, temp_directory, kosmos_version, kosmos_build) + if version is None: + return None + results.append(f' {module["name"]} - {version}') + + # Running a SDSetup Build + elif not kosmos_build and sdsetup_opts['included']: + # Only show prompts when it's not an auto build. + if not auto_build: + print(f'Downloading {module["name"]}...') + + # Make sure module directory is created. + module_directory = os.path.join(temp_directory, sdsetup_opts['name']) + common.mkdir(module_directory) + + # Download the module. + download = globals()[module['download_function_name']] + version = download(module, module_directory, kosmos_version, kosmos_build) + if version is None: + return None + + # Auto builds have a different prompt at the end for parsing. + if auto_build: + results.append(f'{sdsetup_opts["name"]}:{version}') + else: + results.append(f' {module["name"]} - {version}') + + return results diff --git a/Builder/requirements.txt b/Builder/requirements.txt new file mode 100644 index 0000000..abc97a8 --- /dev/null +++ b/Builder/requirements.txt @@ -0,0 +1,2 @@ +PyGithub +python-gitlab \ No newline at end of file