nicoboss / nsz

NSZ - Homebrew compatible NSP/XCI compressor/decompressor
Other
1.36k stars 91 forks source link

is it possible to combine multiple nsp into one .xci file #113

Open ghost opened 2 years ago

ghost commented 2 years ago

is it possible to combine multiple nsp into one .xci file on macos

nicoboss commented 2 years ago

Putting multiple games into a single XCI is not something that's possible. All NSP, XCI, NSZ and XCZ can only hold a single game. They are all just containers containing the actual NCA/NCZ files. Technically nothing stops you from putting multiple games into one container, but it would create a huge unplayable mess with absolutely no use. If you want to combine multiple games into one file just tar the resulting NSZ files but I don't see any reason why you would want to do that.

Do you maybe mean split NSPs used to overcome the fat32 file system limitations? In that case just merge them first using cat *.nsp > merged.nsp and then put the combined NSP into this tool.

I'm maybe misunderstanding your question. Can you please elaborate what you want to achieve?

ghost commented 2 years ago

Sorry, I didn't express myself correctly. I mean, the NSP files of base, patches and DLCs of the same game to be merged into one NSP or XCI file, maybe say it as multicontents NSP or XCI of one game.

I found such multicontents XCI on the internet, but don't know how they produce it.

Masamune3210 commented 2 years ago

You use something like nsc_builder to make the multicontent file, nsz is just for compressing or validating the resulting nsp file

ghost commented 2 years ago

OK but problem is nsc builder only support Windows. how to do the same thing on mac?

Masamune3210 commented 2 years ago

iirc nsc_builder is mostly if not completely in python, or does it rely on some windows exe that I'm forgetting. The most work you would have to do is either call the tools manually or figure out a way to convert the gigantic AF batch files it uses as a menu system to .sh files or the ilk

ghost commented 2 years ago

Will nsz -c repack multiple nsp files into one nsp file? How to use --create command?

nicoboss commented 2 years ago

There currently is no official support for multicontent files inside this tool.

You are correct and there indeed is --create that allows you to recreate an NSP based on the content of a folder. By using --extract for base, updates and DLCs to the same folder and then using --create to get an NSP of that folder you indeed get an NSP that contains base, updates and DLCs. You could than compress that to an NSZ. But is that really what you want? It would just be an NSZ that contains base, update and DLCs but updates and DLCs aren't really applied so whatever title installer you use would still need to install them all separately and somehow be able to deal with the quite messed up metadata. I don't think that's how multicontent files work and what you would get is likely not supported by any currently existing title installer.

I never looked into multicontent files so far so no idea how they work. I might plan to support them in the future as they are probably not that hard to implement. If you or anyone else wants to implement them, feel free to do so and create a pull request.

Masamune3210 commented 2 years ago

afaik they are multiple cmnt and file combos inside of the nsp and the installer just iterates through all the cmnt files to see what is included in the nsp

Here is a issue chain from nsc_builder kinda explaining the format a bit https://web.archive.org/web/20200919101029/https://github.com/julesontheroad/NSC_BUILDER/issues/135

Masamune3210 commented 2 years ago

In total, it seems that the nsp is just treated as a archive, all the different individual nsp's files are included in the multi nsp and the installer and tools just have to change the assumption that there is only one title, and scan through all the included files to see what is included in the multi nsp

ghost commented 2 years ago

wow i tried some tests and it actually works well, so i would like to share and communicate with you: 1.on windows (virtual machine) i use nsc builder to combine game base.xci, update.nsp, dlc.nsp together, into one multicontent xci file.

  1. on Mac i use nsz -C to compress the multicontent xci file, and nsz cli shows it compress game base, update, dlc one by one, and output one multicontent xcz file. xcz file saves about 20% size of original xci file.
  2. i use DBI to connect Switch to Mac, start MTP, drag xcz file to 'MicroSD install' partitioninin in the SD card, game base, update, dlc are installed successfully.

multicontent xcz file is better to store, especially for old games that not updating anymore.

so, if nsz cli can originally provide repacking multicontent xci or nsp file, it would be very helpful to Mac users.

please consider to use the same backbone that NSCB does to create the XCI, squirrel.py. https://github.com/ItsCinnabar/Mass_Custom_XCIs

i prefer to do all things above on mac with one nsz cli, and without using virtual machine.

but anyway, nsz is very good tool by now, thanks a lot!

ghost commented 2 years ago

I cd to folder where .nsp files are, and run nsz -c CREATE, it shows error below, am i doing wrong way or how can it fix error, thx a lot!

❯ nsz -c CREATE

             NSZ v4.1   ,;:;;,
                       ;;;;;
               .=',    ;:;;:,
              /_', "=. ';:;:;
              @=:__,  \,;:;:'
                _(\.=  ;:;;'
               `"_(  _/="`
                `"'

Creating "CREATE"
    Repacking to NSP...
nut exception: 'Counter' object has no attribute 'write'
Traceback (most recent call last):
  File "/Users/username/.pyenv/versions/3.10.6/bin/nsz", line 8, in <module>
    sys.exit(main())
  File "/Users/username/.pyenv/versions/3.10.6/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nsz/__init__.py", line 148, in main
    nsp.pack(args.file)
  File "/Users/username/.pyenv/versions/3.10.6/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nsz/Fs/Nsp.py", line 384, in pack
    t.write('\t\tWriting header...')
AttributeError: 'Counter' object has no attribute 'write'
ghost commented 2 years ago

You are correct and there indeed is --create that allows you to recreate an NSP based on the content of a folder. By using --extract for base, updates and DLCs to the same folder and then using --create to get an NSP of that folder you indeed get an NSP that contains base, updates and DLCs.

I think yes, it is what i am trying, but get trouble with nsz --create step. I have used nsz --extract to game base, dlc, updates nsp file, for the same game, and got a few folders for each nsp file. Then i cd to folder where those output folders are, and run nsz --create CREATE, it gave the same error as above. don't know how to solve, please help, thank you!

nicoboss commented 2 years ago

@blacklein You should now be able to repack the extracted folders back to an NSP if you use latest master. I fixed the issue you experienced with --create and improved its syntax and documentation.

Example how to use it:

python .\nsz.py --create name_of_outfile.nsp .\first_extracted_folder .\second_extracted_folder .\third_extracted_folder
ghost commented 2 years ago

it still not works, gives error below

❯ python nsz.py --create output.nsp ./base, ./updates, ./dlc

             NSZ v4.1   ,;:;;,
                       ;;;;;
               .=',    ;:;;:,
              /_', "=. ';:;:;
              @=:__,  \,;:;:'
                _(\.=  ;:;;'
               `"_(  _/="`
                `"'

nut exception: module 'enlighten' has no attribute 'get_manager'
Traceback (most recent call last):
  File "/Users/username/Downloads/nsz/nsz.py", line 18, in <module>
    nsz.main()
  File "/Users/username/Downloads/nsz/nsz/__init__.py", line 110, in main
    barManager = enlighten.get_manager()
AttributeError: module 'enlighten' has no attribute 'get_manager'
RinMaru commented 4 months ago

i couldn't get this to work much unfortunately but i also am useless in cmd so a gui would be great. NSC Builder will combine files but NSZ will have issues compressing them so im not sure what to do

Masamune3210 commented 4 months ago

NSC_BUILDER can also compress, btw. It's just not focused on certain things like nsz is

RinMaru commented 4 months ago

NSC_BUILDER can also compress, btw. It's just not focused on certain things like nsz is

problem is its outdated and has issues. anytime i merge stuff in NSC, it and NSZ can no longer find the titlekey and NSZ just has issues compressing anything NSC spits out with validation errors

RinMaru commented 4 months ago

@blacklein You should now be able to repack the extracted folders back to an NSP if you use latest master. I fixed the issue you experienced with --create and improved its syntax and documentation.

Example how to use it:

python .\nsz.py --create name_of_outfile.nsp .\first_extracted_folder .\second_extracted_folder .\third_extracted_folder

could you possibly make a bat script out of that so i can just drag the folder into it and it will spit it out?