diff --git a/README.md b/README.md index 606464d..0837167 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ # You-Get Unofficial Build Executable -![platform](https://img.shields.io/badge/platform-windows-brightgreen) +![platform](https://img.shields.io/badge/platform-Windows-brightgreen?logo=windows) ![GitHub release](https://img.shields.io/github/v/release/LussacZheng/you-get.exe?include_prereleases&label=build) -[![GitHub All Releases](https://img.shields.io/github/downloads/LussacZheng/you-get.exe/total?color=green)](https://github.com/LussacZheng/you-get.exe/releases) +[![GitHub All Releases](https://img.shields.io/github/downloads/LussacZheng/you-get.exe/total?color=green&logo=github)](https://github.com/LussacZheng/you-get.exe/releases) Use [PyInstaller](https://github.com/pyinstaller/pyinstaller) to bundle [You-Get](https://github.com/soimort/you-get) into a single executable for Windows. diff --git a/README_cn.md b/README_cn.md index 08f19fe..0bf2366 100644 --- a/README_cn.md +++ b/README_cn.md @@ -2,9 +2,9 @@ # You-Get 非官方构建的可执行文件 -![platform](https://img.shields.io/badge/platform-windows-brightgreen) +![platform](https://img.shields.io/badge/platform-Windows-brightgreen?logo=windows) ![GitHub release](https://img.shields.io/github/v/release/LussacZheng/you-get.exe?include_prereleases&label=build) -[![GitHub All Releases](https://img.shields.io/github/downloads/LussacZheng/you-get.exe/total?color=green)](https://github.com/LussacZheng/you-get.exe/releases) +[![GitHub All Releases](https://img.shields.io/github/downloads/LussacZheng/you-get.exe/total?color=green&logo=github)](https://github.com/LussacZheng/you-get.exe/releases) 使用 [PyInstaller](https://github.com/pyinstaller/pyinstaller) 打包 [You-Get](https://github.com/soimort/you-get) 为一个独立的可执行文件 (Windows)。 diff --git a/bin/README.md b/bin/README.md new file mode 100644 index 0000000..15d4cac --- /dev/null +++ b/bin/README.md @@ -0,0 +1,19 @@ +## Source + +- `zip.exe` + + ```text + Version: v3.0 + SHA256: d73ef5858db9bb968da585546283dfab586ce11a218b0b223c0a5f0adcade7d4 + Source: https://sourceforge.net/projects/gnuwin32/files/zip/3.0/ + From: "zip-3.0-bin.zip" \bin\zip.exe + ``` + +- `bzip2.dll` + + ```text + Version: v1.0.5 + SHA256: da25db24809479051d980be5e186926dd53233a76dfe357a455387646befca76 + Source: https://sourceforge.net/projects/gnuwin32/files/bzip2/1.0.5/ + From: "bzip2-1.0.5-bin.zip" \bin\bzip2.dll + ``` diff --git a/bin/bzip2.dll b/bin/bzip2.dll new file mode 100644 index 0000000..174fd06 Binary files /dev/null and b/bin/bzip2.dll differ diff --git a/bin/zip.exe b/bin/zip.exe new file mode 100644 index 0000000..3165202 Binary files /dev/null and b/bin/zip.exe differ diff --git a/build.bat b/build.bat index afd6ea7..03ace24 100644 --- a/build.bat +++ b/build.bat @@ -1,15 +1,36 @@ @rem - Encoding:utf-8; Mode:Batch; Language:en; LineEndings:CRLF - :: You-Get Unofficial Build Executable for Windows :: Author: Lussac (https://blog.lussac.net) -:: Last updated: 2020-02-19 +:: Last updated: 2020-07-20 :: >>> Get updated from: https://github.com/LussacZheng/you-get.exe <<< :: >>> EDIT AT YOUR OWN RISK. <<< @echo off + +rem ================= STEP 0: Root ================= + + +:: Set the root directory +set "root=%~dp0" +set "root=%root:~0,-1%" +cd "%root%" + + +rem ================= STEP 1: Clean ================= + + if exist build\you-get\ rd /S /Q build\you-get -if exist dist\you-get.exe del /S /Q dist\you-get.exe >NUL 2>NUL -if exist dist\LICENSE.txt del /S /Q dist\LICENSE.txt >NUL 2>NUL +if exist dist\ ( + pushd dist + if exist you-get.exe del /S /Q you-get.exe >NUL 2>NUL + if exist LICENSE.txt del /S /Q LICENSE.txt >NUL 2>NUL + if exist README.md del /S /Q README.md >NUL 2>NUL + if exist README_cn.md del /S /Q README_cn.md >NUL 2>NUL + popd +) + +:: Step 2. Check if NOT exist repository\you-get\you-get ( echo. echo * Please run "devscripts\init.bat" first or clone the repository of "you-get". @@ -17,13 +38,19 @@ if NOT exist repository\you-get\you-get ( exit ) + +rem ================= STEP 3: Build ================= + + cd repository + :: First, move out the original `__init__.py` from "you_get.extractors", :: in order that we can recover everything after build. :: Then copy all the extractors from `repository\_extractors\`, with a new `__init__.py` :: which has imported these extractors, into the module "you_get.extractors" move you-get\src\you_get\extractors\__init__.py .\ > NUL xcopy _extractors\*.py you-get\src\you_get\extractors\ >NUL + pushd you-get echo. @@ -31,6 +58,7 @@ echo ============================================================ echo * pyinstaller "you-get" ... echo ------------------------------------------------------------ echo. + :: PyInstaller bundle command - START pyinstaller -F --path=src ^ --distpath ..\..\dist ^ @@ -43,14 +71,10 @@ pyinstaller -F --path=src ^ --hidden-import=you_get.util ^ you-get :: PyInstaller bundle command - END -echo. -echo ============================================================ -echo. - -xcopy LICENSE.txt ..\..\dist\ >NUL popd -:: Recover everything in you-get.git after build + +:: Recover everything in you-get.git after built for /f "delims=" %%i in ('dir /b /a-d _extractors') do ( del /Q you-get\src\you_get\extractors\%%i >NUL 2>NUL ) @@ -58,15 +82,71 @@ move __init__.py you-get\src\you_get\extractors\ > NUL cd ..\build if exist file_version_info.txt ( - pyi-set_version file_version_info.txt ..\dist\you-get.exe echo. echo ============================================================ echo. + pyi-set_version file_version_info.txt ..\dist\you-get.exe ) +cd .. +echo. +echo ============================================================ +echo. echo * Build logs saved in: "%~dp0build\you-get\" echo * Build executable saved to: "%~dp0dist\you-get.exe" -echo * Build complete. +echo * Build completed. + + +rem ================= STEP 4: Zip ================= + + +echo. +echo ============================================================ +echo * zip "you-get.zip" ... +echo ------------------------------------------------------------ +echo. + +:: copy the files to be zipped +xcopy /Y repository\you-get\LICENSE.txt dist\ >NUL +xcopy /Y README.md dist\ >NUL +xcopy /Y README_cn.md dist\ >NUL + +if NOT exist bin\zip.exe goto :no_zip_exe +if NOT exist bin\bzip2.dll goto :no_zip_exe + +:: Get the version of you-get, arch of executable, and build date tag +:: --> %_version%, %_arch%, %_date% +:: ==> %_zip_archive% +if exist build\file_version_info.txt ( + set "_info=file_version_info.txt" +) else ( set "_info=file_version_info.sample.txt" ) +for /f "tokens=4 delims='" %%i in ('type "build\%_info%" ^| find "FileVersion"') do ( set "_version=%%i" ) +for /f "tokens=5 delims='x" %%i in ('type "build\%_info%" ^| find "ProductVersion"') do ( set "_arch=%%i" ) +if "%_arch%"=="86" ( set "_arch=32" ) +for /f %%i in ('WMIC OS GET LocalDateTime ^| find "."') do ( set "_LDT=%%i" ) +set "_date=%_LDT:~2,2%%_LDT:~4,2%%_LDT:~6,2%" +set "_zip_archive=you-get-%_version%-win%_arch%_UB%_date%.zip" + +cd dist +..\bin\zip.exe %_zip_archive% you-get.exe LICENSE.txt README.md README_cn.md -z < LICENSE.txt + +echo. +echo * Zip archive file saved to: "%~dp0dist\%_zip_archive%" +echo * Zip completed. +echo. +echo ============================================================ +echo. +echo * All completed. +echo. +echo ============================================================ echo. pause +goto :eof + +:no_zip_exe +echo. +echo * Please download "zip.exe" and "bzip2.dll", and put them into "bin/". +pause > NUL +exit + diff --git a/build/file_version_info.sample.txt b/build/file_version_info.sample.txt index a2406b1..dbc3a0f 100644 --- a/build/file_version_info.sample.txt +++ b/build/file_version_info.sample.txt @@ -6,8 +6,8 @@ VSVersionInfo( ffi=FixedFileInfo( # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4) # Set not needed items to zero 0. - filevers=(0, 4, 1423, 0), - prodvers=(2020, 3, 24, 0), + filevers=(0, 4, 1456, 0), + prodvers=(2020, 7, 20, 0), # Contains a bitmask that specifies the valid bits 'flags'r mask=0x3f, # Contains a bitmask that specifies the Boolean attributes of the file. @@ -31,11 +31,13 @@ VSVersionInfo( u'040904B0', [StringStruct(u'Comments', u'Dumb downloader that scrapes the web'), StringStruct(u'FileDescription', u'Dumb downloader that scrapes the web'), - StringStruct(u'FileVersion', u'0.4.1423'), + # '0.4.1456' or '0.4.1456.ur' + StringStruct(u'FileVersion', u'0.4.1456'), StringStruct(u'OriginalFilename', u'you-get.exe'), StringStruct(u'LegalCopyright', u'Released on GitHub@LussacZheng/you-get.exe'), StringStruct(u'ProductName', u'You-Get Unofficial Build Executable for Windows'), - StringStruct(u'ProductVersion', u'UB200324_x64')]) + # 'UB200720_x64' or 'UB200720_x86' + StringStruct(u'ProductVersion', u'UB200720_x64')]) ]), VarFileInfo([VarStruct(u'Translation', [1033, 1200])]) ] diff --git a/devscripts/init.bat b/devscripts/init.bat index 8e4bb9f..7e35f5f 100644 --- a/devscripts/init.bat +++ b/devscripts/init.bat @@ -1,6 +1,9 @@ @rem - Encoding:utf-8; Mode:Batch; Language:en; LineEndings:CRLF - @echo off +:: Set the root directory +cd "%~dp0" + call use-proxy.bat cd ..\repository diff --git a/devscripts/update.bat b/devscripts/update.bat index c383ebb..e49d31e 100644 --- a/devscripts/update.bat +++ b/devscripts/update.bat @@ -1,6 +1,9 @@ @rem - Encoding:utf-8; Mode:Batch; Language:en; LineEndings:CRLF - @echo off +:: Set the root directory +cd "%~dp0" + call use-proxy.bat cd ..\repository