summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 3d9d4a2def093315f585ac39b39f17b974976665 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Maintainer mattf <matheusfillipeag@gmail.com>

pkgname=curl-impersonate-chrome
pkgver=r24.051ccfd
_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)

# WORKAROUND The default /etc/makepkg.conf shipped by arch comes with -Werror=format which can't be 
# overriden otherwise and wont let boringssl compile
options=("!buildflags")

BORING_SSL_COMMIT=3a667d10e94186fd503966f5638e134fe9fb4080
BORING_SSL_URL="https://github.com/google/boringssl/archive/${BORING_SSL_COMMIT}.zip"
BORING_SSL_DIR="boringssl-${BORING_SSL_COMMIT}"
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)"
}

patch_boringssl () {
  cd ${srcdir}
  cp ${browser_dir}/patches/boringssl-*.patch ${BORING_SSL_DIR}
  cd ${BORING_SSL_DIR}
  for p in $(ls boringssl-*.patch); do patch -p1 < $p; done
}

build_boringssl () {
  cd ${srcdir}
  cd ${BORING_SSL_DIR}
  mkdir -p build 
  cd build
  cmake -DCMAKE_POSITION_INDEPENDENT_CODE=on -GNinja ..
  ninja
  cd ${srcdir}
  mkdir -p ${BORING_SSL_DIR}/build/lib
  ln -sf ../crypto/libcrypto.a ${BORING_SSL_DIR}/build/lib/libcrypto.a
  ln -sf ../ssl/libssl.a ${BORING_SSL_DIR}/build/lib/libssl.a
  cp -R ${BORING_SSL_DIR}/include ${BORING_SSL_DIR}/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 --with-pic --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}/${BORING_SSL_DIR}/build --enable-static --disable-shared --with-nghttp2=${srcdir}/${NGHTTP2_VERSION}/build LIBS="-pthread" CFLAGS="-I${srcdir}/${BORING_SSL_DIR}/build -I${srcdir}/${NGHTTP2_VERSION}/build" USE_CURL_SSLKEYLOGFILE=true
  make
  mkdir -p out
  cp src/curl out/curl-impersonate
  cp ${srcdir}/${browser_dir}/curl_* out/
  chmod +x out/*
}

prepare () {
  patch_boringssl
  patch_nghttp2
  patch_curl
}

build () {
  build_boringssl
  build_nghttp2
  build_curl
}

package () {
  cd ${CURL_VERSION}/out
  sed -i "s/\$dir\/curl-impersonate/${pkgname}/g" curl_*
  install -Dm755 curl-impersonate "${pkgdir}/usr/bin/${pkgname}"
  install -Dm755 curl_* "${pkgdir}/usr/bin/"
}