diff --git a/buildZip/__pycache__/fileTools.cpython-312.pyc b/buildZip/__pycache__/fileTools.cpython-312.pyc new file mode 100644 index 0000000..cccfd25 Binary files /dev/null and b/buildZip/__pycache__/fileTools.cpython-312.pyc differ diff --git a/buildZip/__pycache__/zipTools.cpython-312.pyc b/buildZip/__pycache__/zipTools.cpython-312.pyc new file mode 100644 index 0000000..4f5a721 Binary files /dev/null and b/buildZip/__pycache__/zipTools.cpython-312.pyc differ diff --git a/buildZip/build.bat b/buildZip/build.bat new file mode 100644 index 0000000..717a809 --- /dev/null +++ b/buildZip/build.bat @@ -0,0 +1,3 @@ +cd . +python main.py +pause \ No newline at end of file diff --git a/buildZip/cache_files/10001/bundle.ver.json b/buildZip/cache_files/10001/bundle.ver.json new file mode 100644 index 0000000..6f17cc1 --- /dev/null +++ b/buildZip/cache_files/10001/bundle.ver.json @@ -0,0 +1 @@ +{"10001": "1.0.0"} \ No newline at end of file diff --git a/buildZip/cache_files/10001/files.json b/buildZip/cache_files/10001/files.json new file mode 100644 index 0000000..6e391fa --- /dev/null +++ b/buildZip/cache_files/10001/files.json @@ -0,0 +1 @@ +[{"bundleName": "10001", "path": "10001\\cc.config.1a47b.json", "st": 1728979278.7997227}, {"bundleName": "10001", "path": "10001\\import\\01\\01265b959.9c731.json", "st": 1728979266.612694}, {"bundleName": "10001", "path": "10001\\import\\01\\01bd4475c.3dbf5.json", "st": 1728979266.7878058}, {"bundleName": "10001", "path": "10001\\import\\02\\027b29309.2fa66.json", "st": 1728979266.4808598}, {"bundleName": "10001", "path": "10001\\import\\03\\03d7f6e12.1da60.json", "st": 1728979266.7158973}, {"bundleName": "10001", "path": "10001\\import\\04\\04d61ff36.73822.json", "st": 1728979266.7618973}, {"bundleName": "10001", "path": "10001\\import\\04\\04efa922c.c3928.json", "st": 1728979266.7648983}, {"bundleName": "10001", "path": "10001\\import\\05\\055c9651a.fb210.json", "st": 1728979266.7944472}, {"bundleName": "10001", "path": "10001\\import\\05\\0585a0e84.e86b5.json", "st": 1728979266.709373}, {"bundleName": "10001", "path": "10001\\import\\05\\058ae7985.c8f69.json", "st": 1728979266.762898}, {"bundleName": "10001", "path": "10001\\import\\05\\05f9eef8d.1ae2a.json", "st": 1728979266.76966}, {"bundleName": "10001", "path": "10001\\import\\07\\078ef858f.95b5c.json", "st": 1728979264.988573}, {"bundleName": "10001", "path": "10001\\import\\07\\07c48cde9.e420f.json", "st": 1728979266.6978538}, {"bundleName": "10001", "path": "10001\\import\\08\\08fd7d74a.33790.json", "st": 1728979266.7209}, {"bundleName": "10001", "path": "10001\\import\\0a\\0a9f75d2f.79384.json", "st": 1728979266.7771869}, {"bundleName": "10001", "path": "10001\\import\\0a\\0aab3b428.d122f.json", "st": 1728979266.784043}, {"bundleName": "10001", "path": "10001\\import\\0a\\0ae87d8e0.53e3f.json", "st": 1728979266.7893908}, {"bundleName": "10001", "path": "10001\\import\\0b\\0b21f12d3.9e61a.json", "st": 1728979266.4615314}, {"bundleName": "10001", "path": "10001\\import\\0c\\0cbe5a53e.a7f88.json", "st": 1728979266.7741868}, {"bundleName": "10001", "path": "10001\\import\\0c\\0cedfbc6a.d5323.json", "st": 1728979266.7909272}, {"bundleName": "10001", "path": "10001\\import\\0d\\0d11d629-bcb7-447b-9ac4-95b2ec01ef70.60992.json", "st": 1728979266.7984467}, {"bundleName": "10001", "path": "10001\\import\\0d\\0d2493258.bd7ea.json", "st": 1728979266.7023664}, {"bundleName": "10001", "path": "10001\\import\\0e\\0e8d3977e.a9e32.json", "st": 1728979266.7271388}, {"bundleName": "10001", "path": "10001\\import\\0e\\0ee362c81.a3c2c.json", "st": 1728979266.7721796}, {"bundleName": "10001", "path": "10001\\import\\0e\\0efa5c89c.4e291.json", "st": 1728979266.7751875}, {"bundleName": "10001", "path": "10001\\import\\10\\100aa172-37a5-4165-aa19-823e9a9ab6d4.b44b4.json", "st": 1728979266.8089678}, {"bundleName": "10001", "path": "10001\\import\\10\\10972175-624b-4563-8cc5-d738c29e05c9.a0828.json", "st": 1728979266.8124833}, {"bundleName": "10001", "path": "10001\\import\\1b\\1b095b08-123b-445e-bd96-eb135d97a432.c7324.json", "st": 1728979266.834517}, {"bundleName": "10001", "path": "10001\\import\\1e\\1ec175a4-bde5-4739-84a6-d23fba5769df.5cc73.json", "st": 1728979266.8365152}, {"bundleName": "10001", "path": "10001\\import\\1f\\1fdda0d1-0fe9-438b-83cc-2a960a7fa480.fdefe.json", "st": 1728979266.8385184}, {"bundleName": "10001", "path": "10001\\import\\26\\264c8db4-8ef9-4116-9246-c50609f8250e@f9941.8c18b.json", "st": 1728979266.8410223}, {"bundleName": "10001", "path": "10001\\import\\26\\266c7cd1-1c63-477c-91d6-455bfec43242.7ccb2.json", "st": 1728979266.8470418}, {"bundleName": "10001", "path": "10001\\import\\26\\26d2efd3-4683-4a72-b9eb-07c40437d0f7.0930b.bin", "st": 1728979264.781876}, {"bundleName": "10001", "path": "10001\\import\\26\\26d2efd3-4683-4a72-b9eb-07c40437d0f7.0930b.json", "st": 1728979264.7648735}, {"bundleName": "10001", "path": "10001\\import\\2e\\2e009ad3-79fb-4f95-9dd7-6fe4d899745c.912b2.json", "st": 1728979266.8525589}, {"bundleName": "10001", "path": "10001\\import\\31\\317326a5-1bc2-412a-b3e1-ac60e254bec2.c670e.bin", "st": 1728979264.781876}, {"bundleName": "10001", "path": "10001\\import\\31\\317326a5-1bc2-412a-b3e1-ac60e254bec2.c670e.json", "st": 1728979264.7658734}, {"bundleName": "10001", "path": "10001\\import\\3b\\3b261399-f856-454b-ab27-a37b60c5c751@f9941.68961.json", "st": 1728979266.8545606}, {"bundleName": "10001", "path": "10001\\import\\4b\\4ba5a680-c418-473e-b0f7-5d987046178b.01b3d.json", "st": 1728979266.8575573}, {"bundleName": "10001", "path": "10001\\import\\58\\58f20123-d6a7-47b8-ad67-78d399f50871.9ed72.json", "st": 1728979266.8605576}, {"bundleName": "10001", "path": "10001\\import\\61\\61b348b9-7a0b-4525-a835-49717f6f1f1c.bc6f7.bin", "st": 1728979264.7828853}, {"bundleName": "10001", "path": "10001\\import\\61\\61b348b9-7a0b-4525-a835-49717f6f1f1c.bc6f7.json", "st": 1728979264.7658734}, {"bundleName": "10001", "path": "10001\\import\\64\\647469bd-3a50-4299-b9fa-a82b28c56573.2f829.json", "st": 1728979266.8640814}, {"bundleName": "10001", "path": "10001\\import\\70\\70b77d4b-e4bb-463d-a5c7-3aea097c7740.9021d.json", "st": 1728979266.8670788}, {"bundleName": "10001", "path": "10001\\import\\7a\\7af16545-1a18-4f82-81e3-ebb67b5b9767.cb886.json", "st": 1728979266.8986313}, {"bundleName": "10001", "path": "10001\\import\\7c\\7c0b9b56-b972-4571-8f2d-d56ae6bdc375@f9941.0fc0e.json", "st": 1728979266.9011366}, {"bundleName": "10001", "path": "10001\\import\\8d\\8d6da880-4756-45b7-bb4f-ca49f9c53033.46607.json", "st": 1728979266.9061508}, {"bundleName": "10001", "path": "10001\\import\\8e\\8e5342f7-24c0-4b3c-a583-d011dd81726f.08b13.json", "st": 1728979266.9176762}, {"bundleName": "10001", "path": "10001\\import\\8f\\8fba0b8f-9298-47ea-a62d-14678725bb97.8c915.json", "st": 1728979266.919677}, {"bundleName": "10001", "path": "10001\\import\\93\\9381398b-c87e-400e-a8f9-a75fe79d3a36.5cf66.json", "st": 1728979266.9281979}, {"bundleName": "10001", "path": "10001\\import\\94\\94134f26-edec-447a-833d-7761fa0f2ae7.f7e24.json", "st": 1728979266.931713}, {"bundleName": "10001", "path": "10001\\import\\9c\\9c1644a8-e686-4ad6-ac44-951ae7250077.9a1b1.bin", "st": 1728979264.781876}, {"bundleName": "10001", "path": "10001\\import\\9c\\9c1644a8-e686-4ad6-ac44-951ae7250077.9a1b1.json", "st": 1728979264.7658734}, {"bundleName": "10001", "path": "10001\\import\\ab\\ab150fdd-1650-4832-8aba-0b4dfb0a462b.ac09c.json", "st": 1728979266.9378006}, {"bundleName": "10001", "path": "10001\\import\\ae\\aefaba6e-15d6-4ba9-9726-c784aca0c855.9bce0.json", "st": 1728979266.945321}, {"bundleName": "10001", "path": "10001\\import\\af\\af0605ce-5678-4b95-9678-88a9ee47f434.f0d92.json", "st": 1728979267.001541}, {"bundleName": "10001", "path": "10001\\import\\af\\af2a018d-4c56-46a5-b8e1-a7511d7684ee.86d5d.json", "st": 1728979267.003552}, {"bundleName": "10001", "path": "10001\\import\\b1\\b14bf7e2-210f-4de5-9ede-72b8eb087d4d.eba9d.json", "st": 1728979267.0110588}, {"bundleName": "10001", "path": "10001\\import\\b1\\b16f76cd-fe20-4a6d-a962-040923426c7b.4878a.json", "st": 1728979267.0150766}, {"bundleName": "10001", "path": "10001\\import\\b6\\b685ebb8-3006-4304-b4a0-4effaf965fd0.f7818.json", "st": 1728979267.0235977}, {"bundleName": "10001", "path": "10001\\import\\d0\\d0aa775f-c336-46a6-b8ae-cdb584ad9e20.543b1.json", "st": 1728979267.0265987}, {"bundleName": "10001", "path": "10001\\import\\d0\\d0edc511-b033-4a3a-9138-94857af28d93.5cfd8.json", "st": 1728979267.0407727}, {"bundleName": "10001", "path": "10001\\import\\d7\\d79e83ec-2491-4098-aee9-43c85bfcdc46.dbe3c.json", "st": 1728979267.0431256}, {"bundleName": "10001", "path": "10001\\import\\da\\daeda4cf-f9b6-4ed0-9b1f-e05f619a3789.b5878.json", "st": 1728979267.0516436}, {"bundleName": "10001", "path": "10001\\import\\dc\\dc21c847-c3d5-472c-ba12-4419ff030510.82749.json", "st": 1728979267.0546517}, {"bundleName": "10001", "path": "10001\\import\\e2\\e230cfab-fefb-412a-9e42-405b8806eefe.63ee8.json", "st": 1728979267.0566506}, {"bundleName": "10001", "path": "10001\\import\\e5\\e5fb4bb6-2515-4d6b-b1ed-0dc841dfd9c8.bfb5c.json", "st": 1728979267.0706792}, {"bundleName": "10001", "path": "10001\\import\\ee\\ee52b186-225a-4811-a7a2-846a7e219a3a.10a74.json", "st": 1728979267.0726886}, {"bundleName": "10001", "path": "10001\\import\\f9\\f920a4c1-975f-493a-ab4b-8d443db782a8.67984.json", "st": 1728979267.0796964}, {"bundleName": "10001", "path": "10001\\import\\fe\\fe0a6e04-1c44-4ba3-88ee-5a44d9f0a3a5.47ee2.bin", "st": 1728979264.781876}, {"bundleName": "10001", "path": "10001\\import\\fe\\fe0a6e04-1c44-4ba3-88ee-5a44d9f0a3a5.47ee2.json", "st": 1728979264.7668731}, {"bundleName": "10001", "path": "10001\\import\\fe\\fe6e6b19-bc5d-489f-b209-3a5d59696ae8@f9941.31d52.json", "st": 1728979267.08475}, {"bundleName": "10001", "path": "10001\\index.1a47b.js", "st": 1728979277.3744357}, {"bundleName": "10001", "path": "10001\\native\\0d\\0d11d629-bcb7-447b-9ac4-95b2ec01ef70.1b18e.mp3", "st": 1728635839.9662144}, {"bundleName": "10001", "path": "10001\\native\\11\\11bd4475c.fd293.png", "st": 1728979263.555}, {"bundleName": "10001", "path": "10001\\native\\14\\14efa922c.ff7da.png", "st": 1728979261.838}, {"bundleName": "10001", "path": "10001\\native\\15\\155c9651a.77a4f.png", "st": 1728979264.3}, {"bundleName": "10001", "path": "10001\\native\\15\\158ae7985.7ed28.png", "st": 1728979261.319}, {"bundleName": "10001", "path": "10001\\native\\15\\15f9eef8d.00a1d.png", "st": 1728979262.254}, {"bundleName": "10001", "path": "10001\\native\\1a\\1a9f75d2f.1b980.png", "st": 1728979262.819}, {"bundleName": "10001", "path": "10001\\native\\1a\\1aab3b428.47476.png", "st": 1728979263.422}, {"bundleName": "10001", "path": "10001\\native\\1a\\1ae87d8e0.218c8.png", "st": 1728979263.698}, {"bundleName": "10001", "path": "10001\\native\\1c\\1cbe5a53e.ce1fd.png", "st": 1728979262.632}, {"bundleName": "10001", "path": "10001\\native\\1c\\1cedfbc6a.b208b.png", "st": 1728979264.21}, {"bundleName": "10001", "path": "10001\\native\\1e\\1ec175a4-bde5-4739-84a6-d23fba5769df.b258e.atlas", "st": 1728635839.9602141}, {"bundleName": "10001", "path": "10001\\native\\1e\\1ee362c81.f387a.png", "st": 1728979262.477}, {"bundleName": "10001", "path": "10001\\native\\1e\\1efa5c89c.7ed28.png", "st": 1728979262.733}, {"bundleName": "10001", "path": "10001\\native\\1f\\1fdda0d1-0fe9-438b-83cc-2a960a7fa480.71e59.mp3", "st": 1728635839.9752145}, {"bundleName": "10001", "path": "10001\\native\\26\\264c8db4-8ef9-4116-9246-c50609f8250e.bc59c.astc", "st": 1728660035.7257185}, {"bundleName": "10001", "path": "10001\\native\\26\\264c8db4-8ef9-4116-9246-c50609f8250e.bc59c.jpg", "st": 1728660034.026}, {"bundleName": "10001", "path": "10001\\native\\26\\264c8db4-8ef9-4116-9246-c50609f8250e.bc59c.pkm", "st": 1728660037.0166726}, {"bundleName": "10001", "path": "10001\\native\\26\\264c8db4-8ef9-4116-9246-c50609f8250e.bc59c.png", "st": 1728660034.025}, {"bundleName": "10001", "path": "10001\\native\\2d\\2d626b04-daa7-414d-9163-8b4119fa5c17.633ca.png", "st": 1728659982.2311091}, {"bundleName": "10001", "path": "10001\\native\\3b\\3b261399-f856-454b-ab27-a37b60c5c751.4b4f4.png", "st": 1728659981.8347626}, {"bundleName": "10001", "path": "10001\\native\\46\\46591340-2525-4429-96fc-1f06d9f18962.be7b3.png", "st": 1728659984.3059504}, {"bundleName": "10001", "path": "10001\\native\\4b\\4ba5a680-c418-473e-b0f7-5d987046178b.5fdef.mp3", "st": 1728635839.9722142}, {"bundleName": "10001", "path": "10001\\native\\58\\58f20123-d6a7-47b8-ad67-78d399f50871.83d96.atlas", "st": 1728635839.937215}, {"bundleName": "10001", "path": "10001\\native\\64\\647469bd-3a50-4299-b9fa-a82b28c56573.407d5.atlas", "st": 1728635839.9512143}, {"bundleName": "10001", "path": "10001\\native\\65\\6580298a-52f1-4938-b202-b38d08274149.e022e.png", "st": 1728659982.2641997}, {"bundleName": "10001", "path": "10001\\native\\6c\\6ce57146-7bfd-431b-9f34-a18ef79e842c.3ba25.png", "st": 1728659984.4267762}, {"bundleName": "10001", "path": "10001\\native\\70\\70b77d4b-e4bb-463d-a5c7-3aea097c7740.bfbcf.mp3", "st": 1728635839.9722142}, {"bundleName": "10001", "path": "10001\\native\\7c\\7c0b9b56-b972-4571-8f2d-d56ae6bdc375.3a29c.png", "st": 1728659982.3033066}, {"bundleName": "10001", "path": "10001\\native\\7d\\7d8f9b89-4fd1-4c9f-a3ab-38ec7cded7ca.cea68.png", "st": 1728659981.430873}, {"bundleName": "10001", "path": "10001\\native\\7e\\7eaffe90-fef4-403e-b740-3afdfc58bb60.f334e.png", "st": 1728659982.260181}, {"bundleName": "10001", "path": "10001\\native\\88\\88c15b62-1a96-4a04-988e-7221164591f3.d3330.png", "st": 1728659982.3744566}, {"bundleName": "10001", "path": "10001\\native\\8d\\8d6da880-4756-45b7-bb4f-ca49f9c53033.39756.atlas", "st": 1728635839.939215}, {"bundleName": "10001", "path": "10001\\native\\8f\\8fba0b8f-9298-47ea-a62d-14678725bb97.4fa77.wav", "st": 1728635839.9702146}, {"bundleName": "10001", "path": "10001\\native\\91\\919c28bb-f761-4cbb-9eb3-b626474b7b08.27f60.png", "st": 1728659982.3223464}, {"bundleName": "10001", "path": "10001\\native\\91\\91b869ef-d229-40c4-af4d-9f8e1be115c8.b8db9.png", "st": 1728659984.306953}, {"bundleName": "10001", "path": "10001\\native\\93\\9381398b-c87e-400e-a8f9-a75fe79d3a36.3bfc5.mp3", "st": 1728635839.9732146}, {"bundleName": "10001", "path": "10001\\native\\93\\93d9b87f-482f-48bc-9369-071fa0de0140.9d60e.png", "st": 1728659982.2621894}, {"bundleName": "10001", "path": "10001\\native\\94\\94134f26-edec-447a-833d-7761fa0f2ae7.af354.mp3", "st": 1728635839.9742143}, {"bundleName": "10001", "path": "10001\\native\\97\\97db8f09-63ec-4b62-b8ad-09b82c4978b4.90689.png", "st": 1728659982.3223464}, {"bundleName": "10001", "path": "10001\\native\\9f\\9ff8eafd-266e-47d1-a3b0-f225b384b408.3f47f.png", "st": 1728659982.3043008}, {"bundleName": "10001", "path": "10001\\native\\a5\\a5ff4051-cb8d-4e89-9066-4032ea207130.386e5.png", "st": 1728659984.2964215}, {"bundleName": "10001", "path": "10001\\native\\ab\\abbbbea4-9ec9-4ef8-81c4-b960e764d9a7.a251e.png", "st": 1728659982.2937744}, {"bundleName": "10001", "path": "10001\\native\\ae\\aefaba6e-15d6-4ba9-9726-c784aca0c855.0aa18.mp3", "st": 1728635839.9702146}, {"bundleName": "10001", "path": "10001\\native\\af\\af2a018d-4c56-46a5-b8e1-a7511d7684ee.d2f9d.mp3", "st": 1728635839.971215}, {"bundleName": "10001", "path": "10001\\native\\b6\\b685ebb8-3006-4304-b4a0-4effaf965fd0.3db22.atlas", "st": 1728635839.9452147}, {"bundleName": "10001", "path": "10001\\native\\c2\\c2757a61-9311-4293-8dba-9840bbde3518.2e067.png", "st": 1728659984.3758914}, {"bundleName": "10001", "path": "10001\\native\\c9\\c9a6a7ce-51d5-4a02-b970-cd8a159bcf09.0052a.png", "st": 1728659982.490281}, {"bundleName": "10001", "path": "10001\\native\\d0\\d0aa775f-c336-46a6-b8ae-cdb584ad9e20.c5ba5.atlas", "st": 1728635839.9582148}, {"bundleName": "10001", "path": "10001\\native\\d7\\d79e83ec-2491-4098-aee9-43c85bfcdc46.df65f.atlas", "st": 1728635839.955215}, {"bundleName": "10001", "path": "10001\\native\\d8\\d8d3f901-4ce9-4034-b7d9-ee7b5bfb45de.715c3.png", "st": 1728659982.2737253}, {"bundleName": "10001", "path": "10001\\native\\da\\daeda4cf-f9b6-4ed0-9b1f-e05f619a3789.d686f.mp3", "st": 1728635839.9732146}, {"bundleName": "10001", "path": "10001\\native\\dc\\dc21c847-c3d5-472c-ba12-4419ff030510.78cb6.mp3", "st": 1728635839.9732146}, {"bundleName": "10001", "path": "10001\\native\\de\\de60b923-a4f5-4b02-82d7-94830f524f63.be837.png", "st": 1728659982.1804852}, {"bundleName": "10001", "path": "10001\\native\\e2\\e230cfab-fefb-412a-9e42-405b8806eefe.30304.mp3", "st": 1728635839.971215}, {"bundleName": "10001", "path": "10001\\native\\e5\\e528a7d2-dac0-4f43-b7e8-10ba813f7a44.f19c7.jpg", "st": 1728659982.3273418}, {"bundleName": "10001", "path": "10001\\native\\e8\\e8eafbb8-f595-41de-8d36-ae6807d6bc3b.b96bb.png", "st": 1728659984.2373204}, {"bundleName": "10001", "path": "10001\\native\\ee\\ee52b186-225a-4811-a7a2-846a7e219a3a.4950a.mp3", "st": 1728645942.5751133}, {"bundleName": "10001", "path": "10001\\native\\f2\\f29e1dc0-ab8b-4f61-81ef-092012c21e15.fc555.png", "st": 1728659981.8237336}, {"bundleName": "10001", "path": "10001\\native\\f2\\f2e6eeb4-10e6-48fc-ae33-5dad4c285097.40a64.png", "st": 1728659984.3558476}, {"bundleName": "10001", "path": "10001\\native\\fe\\fe6e6b19-bc5d-489f-b209-3a5d59696ae8.9d60e.png", "st": 1728659982.2852468}] \ No newline at end of file diff --git a/buildZip/config.json b/buildZip/config.json new file mode 100644 index 0000000..0650547 --- /dev/null +++ b/buildZip/config.json @@ -0,0 +1,14 @@ +[ + { + "platform":"android", + "version":"1.0.0", + "buildDir":"build\\{#}\\data\\assets\\", + "filters":["frame","internal","main"], + "only":["10001"], + "fileName":"assets", + "disName":"game_hot", + "suffix":"zip", + "maxFileSize":2.5, + "pkgName":"game" + } +] \ No newline at end of file diff --git a/buildZip/fileTools.py b/buildZip/fileTools.py new file mode 100644 index 0000000..28c33bb --- /dev/null +++ b/buildZip/fileTools.py @@ -0,0 +1,60 @@ +import hashlib +import json +import os + +#获取目录下的全部文件列表 +def get_all_filenames(parentPath,folder_path,isRootPath): + filenames = [] + contents = os.listdir(folder_path) + for content in contents: + path = os.path.join(folder_path, content) + if isRootPath == True: + path=path.replace("/","\\") + filenames.append(path) + else: + if os.path.isfile(path): + filePath=os.path.join(folder_path,content) + filePath=filePath.replace(parentPath+"\\","") + filePath=filePath.replace("/","\\") + filenames.append(filePath) + else: + subfolder_filenames = get_all_filenames(parentPath,path,isRootPath) + filenames.extend(subfolder_filenames) + return filenames + +#验证某个文件路径是否在文件list列表中 +def hasInList(fn,list): + for f in list: + if f in fn: + return True + return False + +#获取某个文件的MD5码 +def getHas(filePath): + pathArr = filePath.split(".") + if len(pathArr) > 2 and pathArr[2] != "json": + return pathArr[2] + return None + +# 根据路径创建一个md5字符串 +def create_md5(input_str): + md5 = hashlib.md5() # 创建一个md5对象 + md5.update(input_str.encode('utf-8')) # 使用utf-8编码 + return md5.hexdigest() # 返回十六进制的哈希值 + +#检查文件路径是否存在,如果不存在就创建一个目录 +def existsDir(path): + if not os.path.exists(path): + os.makedirs(path, exist_ok=True) +# 读取json文件 +def readJson(path): + if os.path.exists(path): + f=open(path,encoding="utf-8") + jsonobj = json.load(f) + f.close(); + return jsonobj +# 写json数据到本地 +def writeJson(path,content): + f=open(path,"w") + json.dump(content,f) + f.close() \ No newline at end of file diff --git a/buildZip/game_hot/10001/1.0.0/base/assets/10001.1.zip b/buildZip/game_hot/10001/1.0.0/base/assets/10001.1.zip new file mode 100644 index 0000000..d2c3bde Binary files /dev/null and b/buildZip/game_hot/10001/1.0.0/base/assets/10001.1.zip differ diff --git a/buildZip/game_hot/10001/1.0.0/base/assets/10001.2.zip b/buildZip/game_hot/10001/1.0.0/base/assets/10001.2.zip new file mode 100644 index 0000000..092ff67 Binary files /dev/null and b/buildZip/game_hot/10001/1.0.0/base/assets/10001.2.zip differ diff --git a/buildZip/game_hot/10001/1.0.0/base/assets/10001.3.zip b/buildZip/game_hot/10001/1.0.0/base/assets/10001.3.zip new file mode 100644 index 0000000..dd9b419 Binary files /dev/null and b/buildZip/game_hot/10001/1.0.0/base/assets/10001.3.zip differ diff --git a/buildZip/game_hot/10001/1.0.0/base/assets/10001.4.zip b/buildZip/game_hot/10001/1.0.0/base/assets/10001.4.zip new file mode 100644 index 0000000..6d78700 Binary files /dev/null and b/buildZip/game_hot/10001/1.0.0/base/assets/10001.4.zip differ diff --git a/buildZip/game_hot/10001/1.0.0/base/assets/10001.5.zip b/buildZip/game_hot/10001/1.0.0/base/assets/10001.5.zip new file mode 100644 index 0000000..0187558 Binary files /dev/null and b/buildZip/game_hot/10001/1.0.0/base/assets/10001.5.zip differ diff --git a/buildZip/game_hot/10001/1.0.0/base/config.json b/buildZip/game_hot/10001/1.0.0/base/config.json new file mode 100644 index 0000000..cbd8fda --- /dev/null +++ b/buildZip/game_hot/10001/1.0.0/base/config.json @@ -0,0 +1 @@ +{"gameId": "10001", "version": "1a47b", "list": ["10001.1", "10001.2", "10001.3", "10001.4", "10001.5"]} \ No newline at end of file diff --git a/buildZip/game_hot/10001/1.0.0/hot/assets/10001.1.zip b/buildZip/game_hot/10001/1.0.0/hot/assets/10001.1.zip new file mode 100644 index 0000000..d2c3bde Binary files /dev/null and b/buildZip/game_hot/10001/1.0.0/hot/assets/10001.1.zip differ diff --git a/buildZip/game_hot/10001/1.0.0/hot/assets/10001.2.zip b/buildZip/game_hot/10001/1.0.0/hot/assets/10001.2.zip new file mode 100644 index 0000000..72fd38b Binary files /dev/null and b/buildZip/game_hot/10001/1.0.0/hot/assets/10001.2.zip differ diff --git a/buildZip/game_hot/10001/1.0.0/hot/assets/10001.3.zip b/buildZip/game_hot/10001/1.0.0/hot/assets/10001.3.zip new file mode 100644 index 0000000..fc9c173 Binary files /dev/null and b/buildZip/game_hot/10001/1.0.0/hot/assets/10001.3.zip differ diff --git a/buildZip/game_hot/10001/1.0.0/hot/assets/10001.4.zip b/buildZip/game_hot/10001/1.0.0/hot/assets/10001.4.zip new file mode 100644 index 0000000..2b82a03 Binary files /dev/null and b/buildZip/game_hot/10001/1.0.0/hot/assets/10001.4.zip differ diff --git a/buildZip/game_hot/10001/1.0.0/hot/assets/10001.5.zip b/buildZip/game_hot/10001/1.0.0/hot/assets/10001.5.zip new file mode 100644 index 0000000..05fba09 Binary files /dev/null and b/buildZip/game_hot/10001/1.0.0/hot/assets/10001.5.zip differ diff --git a/buildZip/game_hot/10001/1.0.0/hot/config.json b/buildZip/game_hot/10001/1.0.0/hot/config.json new file mode 100644 index 0000000..cbd8fda --- /dev/null +++ b/buildZip/game_hot/10001/1.0.0/hot/config.json @@ -0,0 +1 @@ +{"gameId": "10001", "version": "1a47b", "list": ["10001.1", "10001.2", "10001.3", "10001.4", "10001.5"]} \ No newline at end of file diff --git a/buildZip/main.py b/buildZip/main.py new file mode 100644 index 0000000..e35777d --- /dev/null +++ b/buildZip/main.py @@ -0,0 +1,297 @@ +import json +import os +import zipfile +import fileTools +from zipTools import create_split_zip + +#加载配置 +config = fileTools.readJson("config.json") +#本地文件缓存 +local_version_list=[] + +def getPathItem(path,list): + if len(list) <= 0:return None + for file in list: + if file["path"] == path: + return file + return None +#文件是否别改变 +def isChanged(file): + path=targetDir+file["path"] + current_time = os.stat(path).st_mtime + return current_time > float(file["st"]) +#获取版本 +def getVer(ver): + verArr = ver.split(".") + index=len(verArr) -1 + verArr[index]=int(verArr[index]) + 1 + if verArr[index] >= 100 : + verArr[index]=0; + verArr[index-1]=int(verArr[index-1])+1 + if verArr[index-1] >= 100 : + verArr[index-1]=0; + verArr[index-2]=int(verArr[index-2])+1 + return f'{verArr[0]}.{verArr[1]}.{verArr[2]}' + +def getVerCode(ver): + verArr = ver.split(".") + count=0 + for i in range(0,len(verArr)): + count +=int(verArr[i]) + return count + +#处理配置对象 +def handleConfigObject(obj,dirpath): + cachePath=currentPath+"\\cache_files\\";#缓存当前版本变化量 + fileTools.existsDir(cachePath) + local_ver_path=cachePath+"files.json" + local_version={} + local_version["list"]=[] + local_version["version"]=obj["version"] + #加载本地版本缓存 + if os.path.exists(local_ver_path): + local_version = fileTools.readJson(local_ver_path) + else: + fileTools.writeJson(local_ver_path,local_version["list"]) + files = fileTools.get_all_filenames(dirpath,dirpath,False) + filters = obj["filters"] + versionList=[] + base_ver_list=[] + fversion=local_version["version"] + for file_path in files: + if not fileTools.hasInList(file_path,filters): + md5 = fileTools.getHas(file_path) + cur_file_path = file_path.replace(dirpath, "") + if md5 == None: + md5 = fileTools.create_md5(cur_file_path) + file_item=getPathItem(cur_file_path,local_version["list"]) + fileArr=cur_file_path.split("\\") + newFileObj={} + newFileObj["bundleName"]= fileArr[0] + newFileObj["path"]=cur_file_path + newFileObj["st"]=os.stat(file_path).st_mtime + base_ver_list.append(newFileObj) + def addObj(ver): + if file_item!= None: + file_item["st"]=os.stat(file_path).st_mtime + if ver == local_version["version"]: + ver=getVer(local_version["version"]) + local_version["version"]=ver + else: + local_version["list"].append(newFileObj) + #版本路径数据 + versionList.append(newFileObj) + if file_item == None or isChanged(file_item): + if len(obj["only"]) > 0: + if fileTools.hasInList(fileArr[0],obj["only"]): + addObj(fversion) + else: + addObj(fversion) + if len(versionList) <= 0 : + print("=======================暂无热更资源发布================================") + return + print("=======================开始发布资源================================") + verConfigPath=cur_version_path+local_version["version"] + zipFileHotPathDir=verConfigPath+"\\hot\\assets\\" + fileTools.existsDir(zipFileHotPathDir) + zipFileHotPath=zipFileHotPathDir+"\\"+obj["fileName"]+"."+obj["suffix"] + if os.path.exists(zipFileHotPath): + os.remove(zipFileHotPath) + zf = zipfile.ZipFile(zipFileHotPath, "w", zipfile.zlib.DEFLATED) + for tar in versionList: + print("bundleName-> "+tar["bundleName"]+"\t\t开始写入文件 --- > "+tar["path"]) + fullpath=targetDir+"\\"+tar["path"] + zf.write(fullpath,tar["path"]) + zf.close() + print("=======================开始对资源进行分包处理================================") + print(f'当前资源版本 -> {local_version["version"]}') + list = create_split_zip(zipFileHotPath,zipFileHotPathDir,1000 * 1000 * obj["maxFileSize"],obj["suffix"]) + new_config_list=[] + for fi in list: + newob={} + newob["name"]=obj["pkgName"] + newob["resName"]=fi + #newob["version"]=local_version["version"] + new_config_list.append(newob) + configPath=zipFileHotPathDir[:zipFileHotPathDir.find("\\assets")]+"\\config.json" + fileTools.writeJson(configPath,new_config_list) + #删除原有包 + if os.path.exists(zipFileHotPath): + os.remove(zipFileHotPath) + print("-------------------------分包完成-----------------------------------------") + zipFileBasePathDir=verConfigPath+"\\base\\assets\\" + fileTools.existsDir(zipFileBasePathDir) + zipFileBasePath=zipFileBasePathDir+"\\"+obj["fileName"]+"."+obj["suffix"] + if os.path.exists(zipFileBasePath): + os.remove(zipFileBasePath) + zf = zipfile.ZipFile(zipFileBasePath, "w", zipfile.zlib.DEFLATED) + for tar in base_ver_list: + print("bundleName-> "+tar["bundleName"]+"\t\t开始写入文件 --- > "+tar["path"]) + fullpath=targetDir+"\\"+tar["path"] + zf.write(fullpath,tar["path"]) + zf.close() + print("=======================开始对资源进行分包处理================================") + list = create_split_zip(zipFileBasePath,zipFileBasePathDir,1000 * 1000 * obj["maxFileSize"],obj["suffix"]) + new_config_list=[] + for fi in list: + newob={} + newob["name"]=obj["pkgName"] + newob["resName"]=fi + #newob["version"]=local_version["version"] + new_config_list.append(newob) + configPath=zipFileBasePathDir[:zipFileBasePathDir.find("\\assets")]+"\\config.json" + fileTools.writeJson(configPath,new_config_list) + #删除原有包 + if os.path.exists(zipFileBasePath): + os.remove(zipFileBasePath) + print("-------------------------开始写入分包配置----------------------------------") + print(f'当前资源版本 -> {local_version["version"]}') + #写入数据缓存 + fileTools.writeJson(local_ver_path,local_version) + +def handleGameObject(obj,dirpath): + cachePath=currentPath+"\\cache_files\\";#缓存当前版本变化量 + fileTools.existsDir(cachePath) + game_local_version_list=[] + game_bundle_ver_list={} + for gn in obj["only"]: + local_ver_path_dir=f'{cachePath}{gn}' + local_ver_path=f'{local_ver_path_dir}\\files.json' + local_bundle_ver_path=f'{local_ver_path_dir}\\bundle.ver.json' + fileTools.existsDir(local_ver_path_dir) + gameObj={} + gameObj["name"]=gn + gameObj["local_ver_path"]=local_ver_path + gameObj["cache_list"]=[] + gameObj["list"]=[] + gameObj["ver_list"]=[] + if os.path.exists(local_ver_path): + gameObj["cache_list"] = fileTools.readJson(local_ver_path) + else: + fileTools.writeJson(local_ver_path,gameObj["cache_list"]) + game_local_version_list.append(gameObj) + #bundle list + if os.path.exists(local_bundle_ver_path): + game_bundle_ver_list= fileTools.readJson(local_bundle_ver_path) + else: + fileTools.writeJson(local_bundle_ver_path,game_bundle_ver_list) + + def getGameItem(gn): + for fn in game_local_version_list: + if fn["name"] == gn : + return fn + return None + files = fileTools.get_all_filenames(dirpath,dirpath,False) + filters = obj["filters"] + gameVer={} + for file_path in files: + if not fileTools.hasInList(file_path,filters): + md5 = fileTools.getHas(file_path) + cur_file_path = file_path.replace(dirpath, "") + fileArr=cur_file_path.split("\\") + if fileTools.hasInList(fileArr[0],obj["only"]): + subGameObj=getGameItem(fileArr[0]) + if subGameObj != None: + file_item=getPathItem(cur_file_path,subGameObj["cache_list"]) + + newFileObj={} + newFileObj["bundleName"]= fileArr[0] + newFileObj["path"]=cur_file_path + newFileObj["st"]=os.stat(file_path).st_mtime + subGameObj["ver_list"].append(newFileObj) + if "config" in cur_file_path : + subGameObj["md5"]=md5 + if not fileArr[0] in game_bundle_ver_list: + game_bundle_ver_list[fileArr[0]]=obj["version"] + if file_item == None or isChanged(file_item): + def addObj(): + if file_item != None: + file_item["st"]=os.stat(file_path).st_mtime + if not fileArr[0] in gameVer: + gameVer[fileArr[0]]=game_bundle_ver_list[fileArr[0]] + game_bundle_ver_list[fileArr[0]]=getVer(gameVer[fileArr[0]]) + else: + gameObj["cache_list"].append(newFileObj) + + subGameObj["list"].append(newFileObj) + if len(obj["only"]) > 0: + if fileTools.hasInList(fileArr[0],obj["only"]): + addObj() + else: + addObj() + print("=======================开始发布资源================================") + for fn in game_local_version_list: + id=fn["name"] + verConfigPath=cur_version_path+id+"\\"+game_bundle_ver_list[id]+"\\" + if len(fn["list"]) <=0 : + print(f'======================={id}暂无资源发布============================') + continue; + zipFileHotPathDir=verConfigPath+"\\hot\\assets\\" + fileTools.existsDir(zipFileHotPathDir) + zipFileHotPath=zipFileHotPathDir+"\\"+id+"."+"."+obj["suffix"] + if os.path.exists(zipFileHotPath): + os.remove(zipFileHotPath) + zf = zipfile.ZipFile(zipFileHotPath, "w", zipfile.zlib.DEFLATED) + for tar in fn["list"]: + print("bundleName-> "+tar["bundleName"]+"\t\t开始写入文件 --- > "+tar["path"]) + fullpath=targetDir+"\\"+tar["path"] + zf.write(fullpath,tar["path"]) + zf.close() + print(f'=======================开始对资源【{id}】进行分包处理================================') + list = create_split_zip(zipFileHotPath,zipFileHotPathDir,1000 * 1000 * obj["maxFileSize"],obj["suffix"]) + configPath=zipFileHotPathDir[:zipFileHotPathDir.find("\\assets")]+"\\config.json" + configObj={} + configObj["gameId"]=id + configObj["version"]=fn["md5"] + configObj["list"]=list + fileTools.writeJson(configPath,configObj) + #删除原有包 + if os.path.exists(zipFileHotPath): + os.remove(zipFileHotPath) + #基础版本 + zipFileHotPathDir=verConfigPath+"\\base\\assets\\" + fileTools.existsDir(zipFileHotPathDir) + zipFileHotPath=zipFileHotPathDir+"\\"+id+"."+"."+obj["suffix"] + if os.path.exists(zipFileHotPath): + os.remove(zipFileHotPath) + zf = zipfile.ZipFile(zipFileHotPath, "w", zipfile.zlib.DEFLATED) + for tar in fn["ver_list"]: + print("bundleName-> "+tar["bundleName"]+"\t\t开始写入文件 --- > "+tar["path"]) + fullpath=targetDir+"\\"+tar["path"] + zf.write(fullpath,tar["path"]) + zf.close() + print(f'=======================开始对资源【{id}】进行分包处理================================') + + list = create_split_zip(zipFileHotPath,zipFileHotPathDir,1000 * 1000 * obj["maxFileSize"],obj["suffix"]) + configPath=zipFileHotPathDir[:zipFileHotPathDir.find("\\assets")]+"\\config.json" + configObj={} + configObj["gameId"]=id + configObj["version"]=fn["md5"] + configObj["list"]=list + fileTools.writeJson(configPath,configObj) + #删除原有包 + if os.path.exists(zipFileHotPath): + os.remove(zipFileHotPath) + #写入数据缓存 + fileTools.writeJson(fn["local_ver_path"],fn["cache_list"]) + #写入版本 + fileTools.writeJson(local_bundle_ver_path,game_bundle_ver_list) + print(f'当前资源版本 -> {game_bundle_ver_list[id]}') + +if __name__ == '__main__': + currentPath = os.getcwd().replace('\\', '\\') # 获取当前程序运行路径 + parentPath = os.path.dirname(currentPath) # 获取上一级目录 + for itemObj in config: + #处理打包文件目标目录 + targetDir = parentPath +"\\"+itemObj["buildDir"] + targetDir=targetDir.replace("{#}",itemObj["platform"]) + cur_version_path=currentPath+"\\"+itemObj["disName"]+"\\" + fileTools.existsDir(cur_version_path) + if itemObj["pkgName"] == "base": + handleConfigObject(itemObj,targetDir) + elif itemObj["pkgName"] == "game": + handleGameObject(itemObj,targetDir) + else: + print("没有找到处理handler") + + \ No newline at end of file diff --git a/buildZip/zipTools.py b/buildZip/zipTools.py new file mode 100644 index 0000000..a3b7f30 --- /dev/null +++ b/buildZip/zipTools.py @@ -0,0 +1,36 @@ + +import os +import zipfile + + +def get_file_name(path): + return os.path.splitext(os.path.basename(path))[0] +#将zip文件拆分成多个zip字文件 +def create_split_zip(src_zip_path, dst_dir, max_size,suffix="zip"): + cur_file_Name=get_file_name(src_zip_path) + files=[] + with zipfile.ZipFile(src_zip_path, 'r') as z: + file_list = z.infolist() + chunk_number = 1 + dst_zip = None + file_size=0 + for file_info in file_list: + file_data = z.read(file_info.filename) + file_size += file_info.compress_size + if file_size >= max_size : + if dst_zip: + dst_zip.close() + dst_zip=None + chunk_number+=1 + file_size=0 + if dst_zip == None : + fileName=f'{cur_file_Name}{chunk_number}' + files.append(fileName) + dst_zip_name = os.path.join(dst_dir, f'{fileName}.{suffix}') + if os.path.exists(dst_zip_name): + os.remove(dst_zip_name) + dst_zip = zipfile.ZipFile(dst_zip_name, 'w', zipfile.ZIP_DEFLATED) + dst_zip.writestr(file_info.filename, file_data) + if dst_zip != None : + dst_zip.close() + return files \ No newline at end of file