-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathinstall.bat
More file actions
executable file
·91 lines (76 loc) · 2.34 KB
/
install.bat
File metadata and controls
executable file
·91 lines (76 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
@echo off
setlocal enabledelayedexpansion
echo.
echo =========================================
echo cpdf - The PDF Compressor (Windows)
echo INSTALLATION
echo =========================================
echo.
:: GitHub repository
set "GITHUB_REPO=hkdb/cpdf"
:: Detect architecture
set "ARCH=x86_64"
if "%PROCESSOR_ARCHITECTURE%"=="ARM64" set "ARCH=arm64"
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set "ARCH=x86_64"
echo [*] Detected architecture: %ARCH%
echo.
:: Set install directory
set "INSTALL_DIR=%USERPROFILE%\.local\bin"
:: Create install directory if it doesn't exist
if not exist "%INSTALL_DIR%" (
echo [*] Creating %INSTALL_DIR%...
mkdir "%INSTALL_DIR%"
if errorlevel 1 (
echo [X] Failed to create install directory
exit /b 1
)
)
:: Check for local binary first
set "SCRIPT_DIR=%~dp0"
set "LOCAL_BINARY=%SCRIPT_DIR%dist\cpdf.exe"
if exist "%LOCAL_BINARY%" (
echo [+] Found locally compiled binary
copy /Y "%LOCAL_BINARY%" "%INSTALL_DIR%\cpdf.exe" >nul
if errorlevel 1 (
echo [X] Failed to copy binary
exit /b 1
)
goto :installed
)
:: Download from GitHub releases
set "BINARY_NAME=cpdf-windows-%ARCH%.exe"
set "DOWNLOAD_URL=https://github.com/%GITHUB_REPO%/releases/latest/download/%BINARY_NAME%"
echo [*] Downloading %BINARY_NAME% from GitHub releases...
echo.
:: Try PowerShell to download
powershell -Command "& {Invoke-WebRequest -Uri '%DOWNLOAD_URL%' -OutFile '%INSTALL_DIR%\cpdf.exe' -UseBasicParsing}" 2>nul
if errorlevel 1 (
echo [X] Failed to download cpdf from GitHub
echo [!] URL: %DOWNLOAD_URL%
exit /b 1
)
:installed
echo.
echo [+] cpdf installed successfully to %INSTALL_DIR%\cpdf.exe
echo.
echo [!] Make sure %INSTALL_DIR% is in your PATH environment variable.
echo.
echo To add to PATH temporarily:
echo set PATH=%%PATH%%;%INSTALL_DIR%
echo.
echo To add to PATH permanently, run as Administrator:
echo setx PATH "%%PATH%%;%INSTALL_DIR%"
echo.
:: Check if ghostscript is available
where gs >nul 2>&1
if errorlevel 1 (
echo [!] WARNING: Ghostscript (gs) not found in PATH.
echo cpdf requires Ghostscript to work.
echo Download from: https://ghostscript.com/releases/gsdnld.html
echo.
)
echo =========================================
echo COMPLETED
echo =========================================
echo.
endlocal