diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 240e0be..8f05a87 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -12,7 +12,7 @@ jobs:
build:
strategy:
matrix:
- os: [ubuntu-latest, macos-latest]
+ os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
@@ -25,6 +25,12 @@ jobs:
sudo apt-get update
sudo apt-get install -y libpcsclite-dev libcurl4-openssl-dev gcc make cmake gcc-mingw-w64 g++-mingw-w64 unzip
+ - name: Setup Cygwin
+ if: runner.os == 'Windows'
+ uses: egor-tensin/setup-cygwin@v4
+ with:
+ packages: cmake gcc-g++ make zip wget
+
- name: Build for Linux
if: runner.os == 'Linux'
run: |
@@ -33,12 +39,20 @@ jobs:
tar -czvf lpac-linux-x86_64.tar.gz -C output .
shell: bash
- - name: Build for Windows
+ - name: Build for Windows(MinGW)
if: runner.os == 'Linux'
run: |
mkdir build-mingw && cd build-mingw && cmake -DLINUX_MINGW32=ON .. && make -j$(nproc)
- wget https://curl.se/windows/dl-8.4.0_6/curl-8.4.0_6-win64-mingw.zip -O curl.zip && unzip curl.zip && mv curl-8.4.0_6-win64-mingw/bin/libcurl-x64.dll output/libcurl.dll
- zip -r -j lpac-windows-x86_64.zip output/*
+ wget https://curl.se/windows/dl-8.5.0_3/curl-8.4.0_6-win64-mingw.zip -O curl.zip && unzip curl.zip && mv curl-8.5.0_3-win64-mingw/bin/libcurl-x64.dll output/libcurl.dll
+ zip -r -j lpac-windows-x86_64-mingw.zip output/*
+
+ - name: Build for Windows(Cygwin)
+ if: runner.os == 'Windows'
+ run: |
+ mkdir build-cygwin && cd build-cygwin && cmake -DLINUX_MINGW32=ON -DCYGWIN=ON .. && make
+ wget https://curl.se/windows/dl-8.5.0_3/curl-8.5.0_3-win64-mingw.zip -O curl.zip && unzip curl.zip && mv curl-8.5.0_3-win64-mingw/bin/libcurl-x64.dll output/libcurl.dll
+ cp C:\tools\cygwin\bin\cygwin1.dll output
+ zip -r -j lpac-windows-x86_64-cygwin.zip output/*
- name: Build for macOS
if: runner.os == 'macOS'
@@ -53,7 +67,8 @@ jobs:
with:
name: build-artifacts
path: |
- build-mingw/lpac-windows-x86_64.zip
+ build-mingw/lpac-windows-x86_64-mingw.zip
+ build-cygwin/lpac-windows-x86_64-cygwin.zip
build/lpac-linux-x86_64.tar.gz
build/lpac-macos-universal.zip
@@ -62,6 +77,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v')
with:
files: |
- build-mingw/lpac-windows-x86_64.zip
+ build-mingw/lpac-windows-x86_64-mingw.zip
+ build-cygwin/lpac-windows-x86_64-cygwin.zip
build/lpac-linux-x86_64.tar.gz
build/lpac-macos-universal.zip
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5666870..2972b5d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,18 +8,23 @@ endif()
if(LINUX_MINGW32)
set(CMAKE_SYSTEM_NAME Windows)
- set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
+ if(CYGWIN)
+ message(STATUS "Building for Cygwin")
+ add_definitions(-DHAVE_TIMEGM=1)
+ else()
+ set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
- set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
- set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
- set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
- set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
+ set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
+ set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
+ set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
+ set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
- set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
+ set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
- set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
- set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
- set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+ endif()
endif()
cmake_minimum_required (VERSION 3.8)
diff --git a/README.md b/README.md
index 5cf9af6..e2ce9c6 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,11 @@ lpac 是一个跨平台的本地 Profile 代理程序。致力于成为兼容性
下载地址:
[Github Release](https://github.com/estkme-group/lpac/releases/latest)
-加入我们的 [Telegram 群组](https://t.me/estkme)进行讨论!
+关于 Release 的预构建分发:
+- macOS 理论上需要 12 以后版本,无法运行请自行编译
+- Linux 基于 Ubuntu 22.04 构建,需要安装 pcscd libpcsclite 依赖。无法运行请自行编译
+
+加入我们的 [Telegram 群组](https://t.me/estkme) 进行讨论!
特性:
- 支持激活码(Activate Code)和确认码(Confirm Code)
@@ -24,7 +28,7 @@ lpac 是一个跨平台的本地 Profile 代理程序。致力于成为兼容性
- [目录](#目录)
- [编译](#编译)
- [使用](#使用)
- - [Linux pcscd](#linux-pcscd)
+ - [Linux 依赖](#linux-依赖)
- [库说明](#库说明)
- [CLI](#cli)
- [返回值](#返回值)
@@ -75,6 +79,8 @@ make
Windows
+使用 MinGW 编译的 lpac 存在无法发送通知的 bug,如果不需要用到该功能可以忽略。如有需要可尝试使用 Cygwin 编译
+
- 在 Linux 上编译
```bash
@@ -99,12 +105,27 @@ cmake -DLINUX_MINGW32=ON .. && ninja
wget https://curl.se/windows/dl-8.4.0_6/curl-8.4.0_6-win64-mingw.zip -O curl.zip && unzip curl.zip && mv curl-8.4.0_6-win64-mingw/bin/libcurl-x64.dll output/libcurl.dll
```
编译后的二进制在 output 目录内.
+
+- 在 Windows 上编译(Cygwin)
+
+安装好 `gcc-core` `gcc-g++` `make` `cmake` `unzip` `wget`
+
+```bash
+git clone --depth=1 https://github.com/estkme-group/lpac
+cd lpac && mkdir build && cd build
+cmake -DLINUX_MINGW32=ON -DCYGWIN=ON .. && make
+# 下载 libcurl
+wget https://curl.se/windows/dl-8.4.0_6/curl-8.4.0_6-win64-mingw.zip -O curl.zip && unzip curl.zip && mv curl-8.4.0_6-win64-mingw/bin/libcurl-x64.dll output/libcurl.dll
+```
+编译后的二进制在 output 目录内.
+
+在 Cygwin shell 外运行程序需要把 `cygwin1.dll` 放置一份于程序目录下。对于默认路径安装的 Cygwin 这个文件应该位于 `C:\cygwin64\bin\cygwin1.dll`
## 使用
-### Linux pcscd
+### Linux 依赖
在 Linux 下访问 PCSC 读卡器需要安装 `pcscd` 并启动。
```bash
@@ -112,6 +133,8 @@ sudo apt install pcscd
sudo systemctl start pcscd
```
+`libpcsclite` 也需要安装
+
### 库说明
默认会使用 `libapduinterface` APDU 库和 `libhttpinterface` HTTP 库,请提前重命名以选择需要使用的库。或者通过 `APDU_INTERFACE` 和 `HTTP_INTERFACE` 环境变量告诉 lpac 使用的 APDU 库和 HTTP 库。库文件在 lpac 程序目录下,根据系统不同,后缀为 `dll`, `so`, `dylib`
@@ -131,10 +154,10 @@ HTTP:
Windows(使用PowerShell)
- ```
- $env:APDU_INTERFACE=".\libapduinterface_pcsc.dll"
- $env:HTTP_INTERFACE=".\libhttpinterface_curl.dll"
- ```
+```
+$env:APDU_INTERFACE=".\libapduinterface_pcsc.dll"
+$env:HTTP_INTERFACE=".\libhttpinterface_curl.dll"
+```
@@ -142,10 +165,10 @@ HTTP:
Linux
- ```
- export APDU_INTERFACE=./libapduinterface_pcsc.so
- export HTTP_INTERFACE=./libhttpinterface_curl.so
- ```
+```
+export APDU_INTERFACE=./libapduinterface_pcsc.so
+export HTTP_INTERFACE=./libhttpinterface_curl.so
+```
@@ -153,10 +176,10 @@ HTTP:
macOS
- ```
- export APDU_INTERFACE=./libapduinterface_pcsc.dylib
- export HTTP_INTERFACE=./libhttpinterface_curl.dylib
- ```
+```
+export APDU_INTERFACE=./libapduinterface_pcsc.dylib
+export HTTP_INTERFACE=./libhttpinterface_curl.dylib
+```
diff --git a/README_en.md b/README_en.md
index f7da640..64b7c88 100644
--- a/README_en.md
+++ b/README_en.md
@@ -2,25 +2,34 @@
[中文](README.md)
-LPAC is a cross platform local profile agent program. Committed to becoming the most compatible, powerful, and concise LPA program.
+LPAC is a cross platform local profile agent program.
+
+Features:
+- Support Activate Code and **Confirm Code**
+- Support custom IMEI sent to server
+- Support esim Discovery(Push)
+- Notification manage
+- Lookup eUICC chip info
+- etc
Download:
[Github Release](https://github.com/estkme-group/lpac/releases/latest)
-Join our [Telegram Group](https://t.me/estkme)to discuss!
+lpac is dynamic-linked, Release is built by Github action, if you can't run it you need to compile by yourself
+
+Join our [Telegram Group](https://t.me/estkme) to discuss!
# Usage
-## Linux pcscd
+## Linux dependency
You need to install `pcscd` and keep its daemon running to access pcsc smart card reader.
```bash
sudo apt install pcscd
sudo systemctl start pcscd
```
-## GUI Frontend
+`libpcsclite` is alse needed
-- [lpa-agent](https://github.com/estkme-group/lpa-agent): Web based lpac frontend
# Compile
@@ -40,6 +49,24 @@ WIP
## Windows
+Due to a [bug in asn1c](https://github.com/vlm/asn1c/issues/196), the MinGW version of lpac cannot send notification successfully. Building with Cygwin seems to avoid it.
+
+Windows need prebuilt libcurl.dll, you can replace the download link to newest curl version.
+
+- Build on Windows(Cygwin)
+
+With `gcc-core` `gcc-g++` `make` `cmake` `unzip` `wget` installed
+
+```bash
+git clone --depth=1 https://github.com/estkme-group/lpac
+cd lpac && mkdir build && cd build
+cmake -DLINUX_MINGW32=ON -DCYGWIN=ON .. && make
+# Download libcurl
+wget https://curl.se/windows/dl-8.4.0_6/curl-8.4.0_6-win64-mingw.zip -O curl.zip && unzip curl.zip && mv curl-8.4.0_6-win64-mingw/bin/libcurl-x64.dll output/libcurl.dll
+```
+To run it outside Cygwin shell, you need copy `cygwin1.dll` to the program folder to distribute.
+`cygwin1.dll` is located in `C:\cygwin64\bin\cygwin1.dll` (Default Cygwin installation location)
+
- Build on Linux(MINGW)
```bash
diff --git a/euicc/asn1c/CMakeLists.txt b/euicc/asn1c/CMakeLists.txt
index 1c05b9a..ce7594d 100644
--- a/euicc/asn1c/CMakeLists.txt
+++ b/euicc/asn1c/CMakeLists.txt
@@ -4,7 +4,7 @@ add_library (euiccasn1 STATIC ${LIB_EUICC_ASN1_SRCS})
target_compile_definitions(euiccasn1 PRIVATE HAVE_CONFIG_H)
option(LINUX_MINGW32 "Build for windows on Linux" OFF)
-if(LINUX_MINGW32)
+if(LINUX_MINGW32 AND NOT CYGWIN)
add_subdirectory(mingw32)
target_link_libraries(euiccasn1 euiccasn1mingw32)
endif()
diff --git a/interface/apdu/CMakeLists.txt b/interface/apdu/CMakeLists.txt
index 999d385..ae76836 100644
--- a/interface/apdu/CMakeLists.txt
+++ b/interface/apdu/CMakeLists.txt
@@ -5,7 +5,7 @@ target_link_libraries(apduinterface_pcsc cjson-static)
set_target_properties(apduinterface_pcsc PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/output")
set_target_properties(apduinterface_pcsc PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/output")
-if(LINUX_MINGW32)
+if(LINUX_MINGW32 OR CYGWIN)
target_link_libraries(apduinterface_pcsc winscard)
elseif (APPLE)
target_link_libraries(apduinterface_pcsc "-framework PCSC")
diff --git a/interface/apdu/pcsc.c b/interface/apdu/pcsc.c
index 68b3362..6b8d71d 100644
--- a/interface/apdu/pcsc.c
+++ b/interface/apdu/pcsc.c
@@ -5,6 +5,9 @@
#ifdef __MINGW32__
#include
+#elif defined(__CYGWIN__)
+#include "/usr/include/w32api/winscard.h"
+#include "/usr/include/w32api/wtypes.h"
#else
#include
#include
diff --git a/interface/http/curl.c b/interface/http/curl.c
index 09bb8ce..117e645 100644
--- a/interface/http/curl.c
+++ b/interface/http/curl.c
@@ -147,6 +147,8 @@ EUICC_SHARED_EXPORT int libhttpinterface_init(struct euicc_http_interface *ifstr
{
#if defined(__MINGW32__)
libcurl_path = "libcurl.dll";
+#elif defined(__CYGWIN__)
+ libcurl_path = "libcurl.dll";
#elif defined(__APPLE__)
libcurl_path = "libcurl.4.dylib";
#else
diff --git a/src/dlsym_interface.c b/src/dlsym_interface.c
index 0b6ded3..934e16d 100644
--- a/src/dlsym_interface.c
+++ b/src/dlsym_interface.c
@@ -12,6 +12,8 @@
#if defined(__MINGW32__)
#define INTERFACELIB_POSTFIX "dll"
+#elif defined(__CYGWIN__)
+#define INTERFACELIB_POSTFIX "dll"
#elif defined(__APPLE__)
#define INTERFACELIB_POSTFIX "dylib"
#else