Skip to content

Commit b73b2bb

Browse files
committed
[cmake/FindLibAcquire.cmake] Upgrade deps - After 2 years they merged my https://github.com/kuba--/zip/pull/212 so just use their master ; upgrade miniz also ; [acquire/acquire_wininet.h] Use (void) to indicate function takes no param ; [README.md] Update with build intricacies ; improve grammar ; add to "See also"
1 parent a62b5a1 commit b73b2bb

File tree

3 files changed

+38
-22
lines changed

3 files changed

+38
-22
lines changed

README.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ libacquire
77

88
The core for your package manager, minus the dependency graph components. Features: **download**, **verify**, and **extract**.
99

10-
By default—for HTTP, HTTPS, and FTP—this uses `libfetch` on FreeBSD; `wininet` on Windows; and `libcurl` everywhere else. Override with `-DUSE_LIBCURL` or `-DUSE_LIBFETCH`.
10+
By default—for HTTP, HTTPS, and FTP—this uses `libfetch` on FreeBSD; `wininet` on Windows; and `libcurl` everywhere else. Override with `-DUSE_LIBCURL` or `-DUSE_LIBFETCH`.
1111

1212
By default—for MD5, SHA256, SHA512—this uses `wincrypt` on Windows; and `OpenSSL` everywhere else. _Note that on macOS this uses the builtin `CommonCrypto/CommonDigest.h` header, and on OpenBSD it uses `LibreSSL`; however in both of these cases it's the OpenSSL API with different headers._ Override with `-DUSE_OPENSSL`.
1313

1414
By default—for crc32c—this uses `rhash` if available (also giving access to: CRC32, MD4, MD5, SHA1, SHA256, SHA512, SHA3, AICH, ED2K, DC++ TTH, BitTorrent BTIH, Tiger, GOST R 34.11-94, GOST R 34.11-2012, RIPEMD-160, HAS-160, EDON-R, and Whirlpool); otherwise uses included crc32c implementation. Override with `-DUSE_CRC32C`.
1515

16-
By default—for decompression—this uses `compressapi.h` on Windows; then, in order of precedence tries: libarchive, zlib, or downloads miniz.
16+
By default—for decompression—this uses `compressapi.h` on Windows; then, in order of precedence tries: libarchive; zlib; or downloads miniz.
1717

1818
Supports:
1919

@@ -36,7 +36,7 @@ Supports:
3636

3737
Dynamically links to shared libraries, defaulting to what's already installed on your OS by default.
3838

39-
If your OS doesn't have the dependency, an optimised dependency free version will be `add_library`'d and depended upon.
39+
If your OS doesn't have the dependency, an optimised dependency-free version will be `add_library`'d and depended upon.
4040

4141
*† default on that OS*
4242

@@ -72,7 +72,8 @@ If your OS doesn't have the dependency, an optimised dependency free version wil
7272
| [miniz](https://github.com/richgel999/miniz) with [zip](https://github.com/kuba--/zip) API | `USE_MINIZ` | All that miniz + zip supports; default † fallback
7373

7474
### Checksum
75-
Note that most checksum libraries are crypto libraries so working with these APIs isn't required for libacquire:
75+
76+
Note that most checksum libraries are crypto libraries, so working with these APIs isn't required for libacquire:
7677

7778
| API | Package enable flag | OS support |
7879
----------------------------------------------------------------| ------------------- |---------------------------------|
@@ -83,8 +84,8 @@ Note that most checksum libraries are crypto libraries so working with these API
8384

8485
`Dockerfile`s are provided for convenience, try them out, e.g., by running:
8586
```sh
86-
docker build . -f alpine.Dockerfile --tag libacquire
87-
docker run libacquire
87+
docker build . -f alpine.Dockerfile --tag libacquire:alpine_latest
88+
docker run libacquire:alpine_latest
8889
```
8990

9091
## Shell script equivalent (UNIX with `grep`, `curl`, and `tar`)
@@ -139,11 +140,23 @@ Want different options for libcurl, OpenSSL, or any of the other dependencies? -
139140
### Build
140141

141142
```bash
142-
mkdir build && cd build
143-
cmake ..
144-
cmake --build .
143+
$ mkdir build && cd build
144+
$ cmake ..
145+
$ cmake --build .
145146
```
146147

148+
(alternatively to system search, you can also use vcpkg by explicitly overriding `-DCMAKE_TOOLCHAIN_FILE`)
149+
150+
### Build intricacies
151+
152+
Care is taken, starting with:
153+
- header only modular functionality in separate .h files
154+
155+
…these are created:
156+
- amalgamation header with all header content added to one;
157+
- separate .h and .c files to enable common use-cases;
158+
- amalgamation header with just prototypes, .c content expected to be contained in a shared library.
159+
147160
### CLI interface
148161

149162
Generated with `docopt`, use `python -m pip install docopt-c` then:
@@ -154,6 +167,10 @@ $ python -m docopt_c '.docopt' -o 'libacquire/acquire/cli'
154167
## See also
155168

156169
- https://github.com/SamuelMarks/curl-simple-https
170+
- https://github.com/SamuelMarks/cdd-c
171+
- https://verMan.io
172+
- https://github.com/offscale/postgres-version-manager-go
173+
- ["version-manager-rs" suffixed](https://github.com/orgs/offscale/repositories?q=-version-manager-rs&language=rust) and [verman-schema-rs]
157174

158175
---
159176

acquire/acquire_wininet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extern "C" {
3535

3636
#ifndef DOWNLOAD_DIR_IMPL
3737
#define DOWNLOAD_DIR_IMPL
38-
const char *get_download_dir() { return TMPDIR "//.downloads"; }
38+
const char *get_download_dir(void) { return TMPDIR "//.downloads"; }
3939
#endif /* !DOWNLOAD_DIR_IMPL */
4040

4141
int download(const char *url, enum Checksum checksum, const char *hash,

cmake/FindLibAcquire.cmake

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,36 +125,35 @@ message(STATUS "crypt LIBACQUIRE_LIBRARIES = ${LIBACQUIRE_LIBRARIES}")
125125
#########################
126126

127127
macro (download_extract_miniz download_dir)
128-
set(MINIZ_VERSION "2.2.0")
128+
set(MINIZ_VERSION "3.0.2")
129129
set(MINIZ_BASENAME "miniz-${MINIZ_VERSION}.zip")
130130
get_filename_component(MINIZ_BASENAME_NO_EXT "${MINIZ_BASENAME}" NAME_WLE)
131131
set(MINIZ_ZIP_FILE "${download_dir}/${MINIZ_BASENAME}")
132132
if (NOT EXISTS "${MINIZ_ZIP_FILE}")
133133
file(DOWNLOAD
134134
"https://github.com/richgel999/miniz/releases/download/${MINIZ_VERSION}/miniz-${MINIZ_VERSION}.zip"
135135
"${MINIZ_ZIP_FILE}"
136-
EXPECTED_HASH "SHA256=e4aa5078999c7f7466fa6b8f9848e39ddfff9a4bafc50215764aebe1f13b3841")
137-
#file(ARCHIVE_EXTRACT INPUT "${MINIZ_ZIP_FILE}"
138-
# DESTINATION "${download_dir}")
136+
EXPECTED_HASH "SHA256=ada38db0b703a56d3dd6d57bf84a9c5d664921d870d8fea4db153979fb5332c5")
137+
file(ARCHIVE_EXTRACT INPUT "${MINIZ_ZIP_FILE}"
138+
DESTINATION "${download_dir}")
139139
endif (NOT EXISTS "${MINIZ_ZIP_FILE}")
140140

141141
if (NOT EXISTS "${download_dir}/zip.h")
142+
set(KUBA_ZIP_VER "d7a2252")
142143
file(DOWNLOAD
143-
"https://raw.githubusercontent.com/kuba--/zip/5b3f387/src/zip.h"
144+
"https://raw.githubusercontent.com/kuba--/zip/${KUBA_ZIP_VER}/src/zip.h"
144145
"${download_dir}/zip.h"
145-
EXPECTED_HASH "SHA256=f2f9ecb2a5c9d9fa489c278c011aedb4752567b17d41912b57eb148f05774e4e")
146+
EXPECTED_HASH "SHA256=3dda9a244fe05a8f003477a6e1dfb6844071d003773ab18a7708b860d8896506")
146147

147-
# My C89 compatible PR
148148
file(DOWNLOAD
149-
"https://raw.githubusercontent.com/kuba--/zip/42dc4ce/src/zip.c"
149+
"https://raw.githubusercontent.com/kuba--/zip/${KUBA_ZIP_VER}/src/zip.c"
150150
"${download_dir}/zip.c"
151-
EXPECTED_HASH "SHA256=ceafe6f3a7788697eb639ccc17788f2d9618ff6a573b96a6fb9db044eb19a7b7")
151+
EXPECTED_HASH "SHA256=cec3b7ef189510255b3b2b80dcfa7fe767c26e01dd14ec0cf0fbf1940e7e86c7")
152152

153-
# Looks like they changed miniz, but are still on 2.2.0
154153
file(DOWNLOAD
155-
"https://raw.githubusercontent.com/kuba--/zip/5b3f387/src/miniz.h"
154+
"https://raw.githubusercontent.com/kuba--/zip/${KUBA_ZIP_VER}/src/miniz.h"
156155
"${download_dir}/miniz.h"
157-
EXPECTED_HASH "SHA256=ce02b94490b7a24cc24d2426869a04239ff47dd29d133f9a57625afc0f4a0e87")
156+
EXPECTED_HASH "SHA256=6f2b1d7d368fecadf21ddf330634dabb250e505834fe1b76394aa5834e6e0869")
158157
endif (NOT EXISTS "${download_dir}/zip.h")
159158

160159
file(TO_NATIVE_PATH "${MINIZ_ZIP_FILE}" MINIZ_ZIP_FILE)

0 commit comments

Comments
 (0)