summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 2cb30dad7a3b8ad6c2677beffb50ace4c71f953b (plain)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
# Maintainer mattf <matheusfillipeag@gmail.com>

pkgname=curl-impersonate-chrome
pkgver=r34.b1081c5
_gitname=curl-impersonate
pkgrel=1
pkgdesc="A special compilation of curl that makes it impersonate Chrome"
url="https://github.com/lwthiker/curl-impersonate"
license=('MIT')
arch=('x86_64')
md5sums=('SKIP')
makedepends=(git gcc cmake go ninja unzip zlib autoconf automake libtool patch)
depends=(brotli nss)
provides=(curl-impersonate-chrome)

BORING_SSL_COMMIT=3a667d10e94186fd503966f5638e134fe9fb4080
BORING_SSL_URL="https://github.com/google/boringssl/archive/${BORING_SSL_COMMIT}.zip"
NGHTTP2_VERSION=nghttp2-1.46.0
NGHTTP2_URL=https://github.com/nghttp2/nghttp2/releases/download/v1.46.0/nghttp2-1.46.0.tar.bz2
CURL_VERSION=curl-7.81.0
CURL_URL="https://curl.se/download/${CURL_VERSION}.tar.xz"

source=(
  "git+$url"
  "boringssl.zip::${BORING_SSL_URL}"
  "${NGHTTP2_VERSION}.tar.bz2::${NGHTTP2_URL}"
  "${CURL_VERSION}.tar.xz::${CURL_URL}"
)
md5sums=('SKIP'
         'afaf515861012f435653fab96cae2a5f'
         'de2aaa48ae0bf9713da3a9bfc3f1629f'
         '41954fa09f879fccb57d88be23fe8606')

browser_dir=${_gitname}/chrome


pkgver() {
  cd ${_gitname}
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build_boringssl () {
  cd ${srcdir}
  cd boringssl
  mkdir -p build && cd build
  cmake -DCMAKE_POSITION_INDEPENDENT_CODE=on -GNinja ..
  ninja
  cd ${srcdir}
  mkdir -p boringssl/build/lib
  ln -sf ../crypto/libcrypto.a boringssl/build/lib/libcrypto.a
  ln -sf ../ssl/libssl.a boringssl/build/lib/libssl.a
  cp -R boringssl/include boringssl/build
}

patch_nghttp2 () {
  cd ${srcdir}
  cp ${browser_dir}/patches/libnghttp2-*.patch ${NGHTTP2_VERSION}/
  cd ${NGHTTP2_VERSION}
  for p in $(ls libnghttp2-*.patch); do patch -p1 < $p; done
  autoreconf -i && automake && autoconf
}

build_nghttp2 () {
  cd ${srcdir}
  cd ${NGHTTP2_VERSION}
  ./configure --prefix ${srcdir}/${NGHTTP2_VERSION}/build
  make
  make install
}

patch_curl () {
  cd ${srcdir}
  cp ${browser_dir}/patches/curl-*.patch ${CURL_VERSION}/
  cd ${CURL_VERSION}
  for p in $(ls curl-*.patch); do patch -p1 < $p; done
  autoreconf -fi
}

build_curl () {
  cd ${srcdir}
  cd ${CURL_VERSION}
  ./configure --with-openssl=${srcdir}/boringssl/build --enable-static --disable-shared --with-nghttp2=${srcdir}/${NGHTTP2_VERSION}/build LIBS="-pthread" CFLAGS="-I${srcdir}/boringssl/build -I${srcdir}/${NGHTTP2_VERSION}/build" USE_CURL_SSLKEYLOGFILE=true
  make
  mkdir -p out
  cp src/curl out/curl-impersonate
  chmod +x out/*
}

prepare () {
  mv boringssl-${BORING_SSL_COMMIT} boringssl
  patch_nghttp2
  patch_curl
}

build () {
  build_boringssl
  build_nghttp2
  build_curl
}

package () {
  cd ${CURL_VERSION}
  install -Dm755 out/curl-impersonate "${pkgdir}/usr/bin/${pkgname}"
}