build tlsclient with oasis linux
be0baThis patch allows you to build my fork of moody’s excellent tlsclient on Oasis Linux, as an integrated part of the distribution.
The downfall is, it will likely require a full rebuild, and it also absolutely requires a C++ compiler. The rebuild requirement comes because I had to change the linker rule to use the C++ compiler because BoringSSL believes in C++, so everything will get relinked. This has the unfortunate side-effect that everything will also be linked against libstdc++.
You get what you pay for.
diff --git a/ninja.lua b/ninja.lua
index d5e34093..b402f878 100644
--- a/ninja.lua
+++ b/ninja.lua
@@ -243,6 +243,7 @@ function toolchain(tc)
set('ar', tc.ar or (tc.platform and tc.platform..'-ar') or 'ar')
set('as', tc.as or (tc.platform and tc.platform..'-as') or 'as')
set('cc', tc.cc or (tc.platform and tc.platform..'-cc') or 'cc')
+ set('cxx', tc.cxx or (tc.platform and tc.platform..'-c++') or 'c++')
set('ld', tc.ld or (tc.platform and tc.platform..'-ld') or 'ld')
set('objcopy', tc.objcopy or (tc.platform and tc.platform..'-objcopy') or 'objcopy')
set('mc', tc.mc or 'false')
@@ -283,6 +284,10 @@ function cc(src, deps, args)
return compile('cc', src, deps, args)
end
+function cxx(src, deps, args)
+ return compile('cxx', src, deps, args)
+end
+
function objects(srcs, deps, args)
local objs, nobjs = {}, 0
local rules = {
@@ -292,6 +297,7 @@ function objects(srcs, deps, args)
cc='cc',
cpp='cc',
asm='nasm',
+ cc='cxx',
}
local fn
if type(srcs) == 'string' then
diff --git a/pkg/tlsclient/gen.lua b/pkg/tlsclient/gen.lua
new file mode 100644
index 00000000..979aae9e
--- /dev/null
+++ b/pkg/tlsclient/gen.lua
@@ -0,0 +1,522 @@
+cflags{
+ '-Wall',
+ '-Wno-missing-braces',
+ '-Wno-parentheses',
+ '-ggdb',
+ '-fPIC',
+ '-DOPENSSL_NO_ASM',
+ '-D_THREAD_SAFE',
+ '-I$srcdir',
+ '-I$srcdir/include',
+ '-I$srcdir/third_party/boringssl/src/include',
+}
+
+lib('libauthsrv.a', [[
+ libauthsrv/(authpak.c
+ passtokey.c
+ form1.c
+ hkdf_x_plan9.c
+ convT2M.c
+ convM2T.c
+ convM2A.c
+ convA2M.c
+ _asgetticket.c
+ _asrdresp.c
+ _asrequest.c
+ convM2PR.c
+ convM2TR.c
+ convPR2M.c
+ convTR2M.c
+ _asgetpakkey.c
+ _asgetresp.c)
+ ]]
+)
+lib('libmp.a', [[
+ libmp/(
+ betomp.c
+ cnfield.c
+ crt.c
+ gmfield.c
+ letomp.c
+ mpadd.c
+ mpaux.c
+ mpcmp.c
+ mpdigdiv.c
+ mpdiv.c
+ mpexp.c
+ mpextendedgcd.c
+ mpfactorial.c
+ mpfield.c
+ mpfmt.c
+ mpinvert.c
+ mpleft.c
+ mplogic.c
+ mpmod.c
+ mpmodop.c
+ mpmul.c
+ mpnrand.c
+ mprand.c
+ mpright.c
+ mpsel.c
+ mpsub.c
+ mptobe.c
+ mptober.c
+ mptoi.c
+ mptole.c
+ mptolel.c
+ mptoui.c
+ mptouv.c
+ mptov.c
+ mpvecadd.c
+ mpveccmp.c
+ mpvecdigmuladd.c
+ mpvecsub.c
+ mpvectscmp.c
+ strtomp.c)
+ ]]
+)
+lib('libc.a', [[
+ libc/(
+ u16.c
+ mallocz.c
+ u32.c
+ u64.c
+ genrandom.c
+ sysfatal.c
+ fmt.c
+ fmtfd.c
+ fmtfdflush.c
+ fmtlock.c
+ fmtprint.c
+ fmtquote.c
+ fmtrune.c
+ fmtstr.c
+ fmtvprint.c
+ vseprint.c
+ dofmt.c
+ dorfmt.c
+ encodefmt.c
+ fcallfmt.c
+ fltfmt.c
+ rune.c
+ runefmtstr.c
+ runeseprint.c
+ runesmprint.c
+ runesnprint.c
+ runesprint.c
+ runestrchr.c
+ runestrlen.c
+ runestrstr.c
+ runetype.c
+ runevseprint.c
+ runevsmprint.c
+ runevsnprint.c
+ seprint.c
+ smprint.c
+ snprint.c
+ sprint.c
+ strecpy.c
+ strtod.c
+ strtoll.c
+ tokenize.c
+ utfecpy.c
+ utflen.c
+ utfnlen.c
+ utfrrune.c
+ utfrune.c
+ utfutf.c
+ vfprint.c
+ vsmprint.c
+ vsnprint.c
+ nan64.c
+ atexit.c
+ charstod.c
+ cleanname.c
+ convD2M.c
+ convM2D.c
+ convM2S.c
+ convS2M.c
+ ctime.c
+ crypt.c
+ dirfstat.c
+ dirfwstat.c
+ dirmodefmt.c
+ dirstat.c
+ dirwstat.c
+ fprint.c
+ getfields.c
+ getpid.c
+ netmkaddr.c
+ nsec.c
+ pow10.c
+ pushssl.c
+ pushtls.c
+ read9pmsg.c
+ readn.c
+ truerand.c
+ print.c
+ write.c
+ tas.c
+ werrstr.c)
+ ]]
+)
+lib('libsec.a', [[
+ libsec/(
+ aes.c
+ aesni.c
+ aesCBC.c
+ aesCFB.c
+ aesOFB.c
+ aes_gcm.c
+ aes_xts.c
+ blowfish.c
+ ccpoly.c
+ chacha.c
+ chachablock.c
+ curve25519.c
+ curve25519_dh.c
+ decodepem.c
+ des.c
+ des3CBC.c
+ des3ECB.c
+ desCBC.c
+ desECB.c
+ desmodes.c
+ dh.c
+ dsaalloc.c
+ dsagen.c
+ dsaprimes.c
+ dsaprivtopub.c
+ dsasign.c
+ dsaverify.c
+ ecc.c
+ jacobian.c
+ egalloc.c
+ egdecrypt.c
+ egencrypt.c
+ eggen.c
+ egprivtopub.c
+ egsign.c
+ egverify.c
+ fastrand.c
+ genprime.c
+ genrandom.c
+ gensafeprime.c
+ genstrongprime.c
+ hkdf.c
+ hmac.c
+ md4.c
+ md5.c
+ md5pickle.c
+ nfastrand.c
+ pbkdf2.c
+ poly1305.c
+ prng.c
+ probably_prime.c
+ rc4.c
+ ripemd.c
+ rsaalloc.c
+ rsadecrypt.c
+ rsaencrypt.c
+ rsafill.c
+ rsagen.c
+ rsaprivtopub.c
+ salsa.c
+ scrypt.c
+ secp256k1.c
+ secp256r1.c
+ secp384r1.c
+ sha1.c
+ sha1pickle.c
+ sha2_128.c
+ sha2_64.c
+ sha1block.c
+ sha2block128.c
+ sha2block64.c
+ smallprimes.c
+ tsmemcmp.c
+ x509.c
+ p_sha256.c)
+ ]]
+)
+lib('libcrypto.a', [[
+ third_party/boringssl/(
+ err_data.c
+ src/crypto/asn1/a_bitstr.c
+ src/crypto/asn1/a_bool.c
+ src/crypto/asn1/a_d2i_fp.c
+ src/crypto/asn1/a_dup.c
+ src/crypto/asn1/a_enum.c
+ src/crypto/asn1/a_gentm.c
+ src/crypto/asn1/a_i2d_fp.c
+ src/crypto/asn1/a_int.c
+ src/crypto/asn1/a_mbstr.c
+ src/crypto/asn1/a_object.c
+ src/crypto/asn1/a_octet.c
+ src/crypto/asn1/a_print.c
+ src/crypto/asn1/a_strex.c
+ src/crypto/asn1/a_strnid.c
+ src/crypto/asn1/a_time.c
+ src/crypto/asn1/a_type.c
+ src/crypto/asn1/a_utctm.c
+ src/crypto/asn1/a_utf8.c
+ src/crypto/asn1/asn1_lib.c
+ src/crypto/asn1/asn1_par.c
+ src/crypto/asn1/asn_pack.c
+ src/crypto/asn1/f_int.c
+ src/crypto/asn1/f_string.c
+ src/crypto/asn1/tasn_dec.c
+ src/crypto/asn1/tasn_enc.c
+ src/crypto/asn1/tasn_fre.c
+ src/crypto/asn1/tasn_new.c
+ src/crypto/asn1/tasn_typ.c
+ src/crypto/asn1/tasn_utl.c
+ src/crypto/asn1/time_support.c
+ src/crypto/base64/base64.c
+ src/crypto/bio/bio.c
+ src/crypto/bio/bio_mem.c
+ src/crypto/bio/connect.c
+ src/crypto/bio/fd.c
+ src/crypto/bio/file.c
+ src/crypto/bio/hexdump.c
+ src/crypto/bio/pair.c
+ src/crypto/bio/printf.c
+ src/crypto/bio/socket.c
+ src/crypto/bio/socket_helper.c
+ src/crypto/blake2/blake2.c
+ src/crypto/bn_extra/bn_asn1.c
+ src/crypto/bn_extra/convert.c
+ src/crypto/buf/buf.c
+ src/crypto/bytestring/asn1_compat.c
+ src/crypto/bytestring/ber.c
+ src/crypto/bytestring/cbb.c
+ src/crypto/bytestring/cbs.c
+ src/crypto/bytestring/unicode.c
+ src/crypto/chacha/chacha.c
+ src/crypto/cipher_extra/cipher_extra.c
+ src/crypto/cipher_extra/derive_key.c
+ src/crypto/cipher_extra/e_aesccm.c
+ src/crypto/cipher_extra/e_aesctrhmac.c
+ src/crypto/cipher_extra/e_aesgcmsiv.c
+ src/crypto/cipher_extra/e_chacha20poly1305.c
+ src/crypto/cipher_extra/e_null.c
+ src/crypto/cipher_extra/e_rc2.c
+ src/crypto/cipher_extra/e_rc4.c
+ src/crypto/cipher_extra/e_tls.c
+ src/crypto/cipher_extra/tls_cbc.c
+ src/crypto/cmac/cmac.c
+ src/crypto/conf/conf.c
+ src/crypto/cpu-aarch64-fuchsia.c
+ src/crypto/cpu-aarch64-linux.c
+ src/crypto/cpu-aarch64-win.c
+ src/crypto/cpu-arm-linux.c
+ src/crypto/cpu-arm.c
+ src/crypto/cpu-intel.c
+ src/crypto/cpu-ppc64le.c
+ src/crypto/crypto.c
+ src/crypto/curve25519/curve25519.c
+ src/crypto/curve25519/spake25519.c
+ src/crypto/dh_extra/dh_asn1.c
+ src/crypto/dh_extra/params.c
+ src/crypto/digest_extra/digest_extra.c
+ src/crypto/dsa/dsa.c
+ src/crypto/dsa/dsa_asn1.c
+ src/crypto/ec_extra/ec_asn1.c
+ src/crypto/ec_extra/ec_derive.c
+ src/crypto/ec_extra/hash_to_curve.c
+ src/crypto/ecdh_extra/ecdh_extra.c
+ src/crypto/ecdsa_extra/ecdsa_asn1.c
+ src/crypto/engine/engine.c
+ src/crypto/err/err.c
+ src/crypto/evp/digestsign.c
+ src/crypto/evp/evp.c
+ src/crypto/evp/evp_asn1.c
+ src/crypto/evp/evp_ctx.c
+ src/crypto/evp/p_dsa_asn1.c
+ src/crypto/evp/p_ec.c
+ src/crypto/evp/p_ec_asn1.c
+ src/crypto/evp/p_ed25519.c
+ src/crypto/evp/p_ed25519_asn1.c
+ src/crypto/evp/p_rsa.c
+ src/crypto/evp/p_rsa_asn1.c
+ src/crypto/evp/p_x25519.c
+ src/crypto/evp/p_x25519_asn1.c
+ src/crypto/evp/pbkdf.c
+ src/crypto/evp/print.c
+ src/crypto/evp/scrypt.c
+ src/crypto/evp/sign.c
+ src/crypto/ex_data.c
+ src/crypto/fipsmodule/bcm.c
+ src/crypto/fipsmodule/fips_shared_support.c
+ src/crypto/hkdf/hkdf.c
+ src/crypto/hpke/hpke.c
+ src/crypto/hrss/hrss.c
+ src/crypto/lhash/lhash.c
+ src/crypto/mem.c
+ src/crypto/obj/obj.c
+ src/crypto/obj/obj_xref.c
+ src/crypto/pem/pem_all.c
+ src/crypto/pem/pem_info.c
+ src/crypto/pem/pem_lib.c
+ src/crypto/pem/pem_oth.c
+ src/crypto/pem/pem_pk8.c
+ src/crypto/pem/pem_pkey.c
+ src/crypto/pem/pem_x509.c
+ src/crypto/pem/pem_xaux.c
+ src/crypto/pkcs7/pkcs7.c
+ src/crypto/pkcs7/pkcs7_x509.c
+ src/crypto/pkcs8/p5_pbev2.c
+ src/crypto/pkcs8/pkcs8.c
+ src/crypto/pkcs8/pkcs8_x509.c
+ src/crypto/poly1305/poly1305.c
+ src/crypto/poly1305/poly1305_arm.c
+ src/crypto/poly1305/poly1305_vec.c
+ src/crypto/pool/pool.c
+ src/crypto/rand_extra/deterministic.c
+ src/crypto/rand_extra/forkunsafe.c
+ src/crypto/rand_extra/fuchsia.c
+ src/crypto/rand_extra/passive.c
+ src/crypto/rand_extra/rand_extra.c
+ src/crypto/rand_extra/windows.c
+ src/crypto/rc4/rc4.c
+ src/crypto/refcount_c11.c
+ src/crypto/refcount_lock.c
+ src/crypto/rsa_extra/rsa_asn1.c
+ src/crypto/rsa_extra/rsa_print.c
+ src/crypto/siphash/siphash.c
+ src/crypto/stack/stack.c
+ src/crypto/thread.c
+ src/crypto/thread_none.c
+ src/crypto/thread_pthread.c
+ src/crypto/thread_win.c
+ src/crypto/trust_token/pmbtoken.c
+ src/crypto/trust_token/trust_token.c
+ src/crypto/trust_token/voprf.c
+ src/crypto/x509/a_digest.c
+ src/crypto/x509/a_sign.c
+ src/crypto/x509/a_verify.c
+ src/crypto/x509/algorithm.c
+ src/crypto/x509/asn1_gen.c
+ src/crypto/x509/by_dir.c
+ src/crypto/x509/by_file.c
+ src/crypto/x509/i2d_pr.c
+ src/crypto/x509/name_print.c
+ src/crypto/x509/rsa_pss.c
+ src/crypto/x509/t_crl.c
+ src/crypto/x509/t_req.c
+ src/crypto/x509/t_x509.c
+ src/crypto/x509/t_x509a.c
+ src/crypto/x509/x509.c
+ src/crypto/x509/x509_att.c
+ src/crypto/x509/x509_cmp.c
+ src/crypto/x509/x509_d2.c
+ src/crypto/x509/x509_def.c
+ src/crypto/x509/x509_ext.c
+ src/crypto/x509/x509_lu.c
+ src/crypto/x509/x509_obj.c
+ src/crypto/x509/x509_req.c
+ src/crypto/x509/x509_set.c
+ src/crypto/x509/x509_trs.c
+ src/crypto/x509/x509_txt.c
+ src/crypto/x509/x509_v3.c
+ src/crypto/x509/x509_vfy.c
+ src/crypto/x509/x509_vpm.c
+ src/crypto/x509/x509cset.c
+ src/crypto/x509/x509name.c
+ src/crypto/x509/x509rset.c
+ src/crypto/x509/x509spki.c
+ src/crypto/x509/x_algor.c
+ src/crypto/x509/x_all.c
+ src/crypto/x509/x_attrib.c
+ src/crypto/x509/x_crl.c
+ src/crypto/x509/x_exten.c
+ src/crypto/x509/x_info.c
+ src/crypto/x509/x_name.c
+ src/crypto/x509/x_pkey.c
+ src/crypto/x509/x_pubkey.c
+ src/crypto/x509/x_req.c
+ src/crypto/x509/x_sig.c
+ src/crypto/x509/x_spki.c
+ src/crypto/x509/x_val.c
+ src/crypto/x509/x_x509.c
+ src/crypto/x509/x_x509a.c
+ src/crypto/x509v3/pcy_cache.c
+ src/crypto/x509v3/pcy_data.c
+ src/crypto/x509v3/pcy_lib.c
+ src/crypto/x509v3/pcy_map.c
+ src/crypto/x509v3/pcy_node.c
+ src/crypto/x509v3/pcy_tree.c
+ src/crypto/x509v3/v3_akey.c
+ src/crypto/x509v3/v3_akeya.c
+ src/crypto/x509v3/v3_alt.c
+ src/crypto/x509v3/v3_bcons.c
+ src/crypto/x509v3/v3_bitst.c
+ src/crypto/x509v3/v3_conf.c
+ src/crypto/x509v3/v3_cpols.c
+ src/crypto/x509v3/v3_crld.c
+ src/crypto/x509v3/v3_enum.c
+ src/crypto/x509v3/v3_extku.c
+ src/crypto/x509v3/v3_genn.c
+ src/crypto/x509v3/v3_ia5.c
+ src/crypto/x509v3/v3_info.c
+ src/crypto/x509v3/v3_int.c
+ src/crypto/x509v3/v3_lib.c
+ src/crypto/x509v3/v3_ncons.c
+ src/crypto/x509v3/v3_ocsp.c
+ src/crypto/x509v3/v3_pci.c
+ src/crypto/x509v3/v3_pcia.c
+ src/crypto/x509v3/v3_pcons.c
+ src/crypto/x509v3/v3_pmaps.c
+ src/crypto/x509v3/v3_prn.c
+ src/crypto/x509v3/v3_purp.c
+ src/crypto/x509v3/v3_skey.c
+ src/crypto/x509v3/v3_utl.c)
+ ]]
+)
+lib('libssl.a', [[
+ third_party/boringssl/(
+ src/ssl/bio_ssl.cc
+ src/ssl/d1_both.cc
+ src/ssl/d1_lib.cc
+ src/ssl/d1_pkt.cc
+ src/ssl/d1_srtp.cc
+ src/ssl/dtls_method.cc
+ src/ssl/dtls_record.cc
+ src/ssl/encrypted_client_hello.cc
+ src/ssl/extensions.cc
+ src/ssl/handoff.cc
+ src/ssl/handshake.cc
+ src/ssl/handshake_client.cc
+ src/ssl/handshake_server.cc
+ src/ssl/s3_both.cc
+ src/ssl/s3_lib.cc
+ src/ssl/s3_pkt.cc
+ src/ssl/ssl_aead_ctx.cc
+ src/ssl/ssl_asn1.cc
+ src/ssl/ssl_buffer.cc
+ src/ssl/ssl_cert.cc
+ src/ssl/ssl_cipher.cc
+ src/ssl/ssl_file.cc
+ src/ssl/ssl_key_share.cc
+ src/ssl/ssl_lib.cc
+ src/ssl/ssl_privkey.cc
+ src/ssl/ssl_session.cc
+ src/ssl/ssl_stat.cc
+ src/ssl/ssl_transcript.cc
+ src/ssl/ssl_versions.cc
+ src/ssl/ssl_x509.cc
+ src/ssl/t1_enc.cc
+ src/ssl/tls13_both.cc
+ src/ssl/tls13_client.cc
+ src/ssl/tls13_enc.cc
+ src/ssl/tls13_server.cc
+ src/ssl/tls_method.cc
+ src/ssl/tls_record.cc)
+ ]]
+)
+
+exe('tlsclient', 'cpu.c p9any.c libauthsrv.a libmp.a libc.a libsec.a libcrypto.a libssl.a')
+
+file('bin/tlsclient', '755', '$outdir/tlsclient')
+
+fetch 'curl'
diff --git a/pkg/tlsclient/sha256 b/pkg/tlsclient/sha256
new file mode 100644
index 00000000..59ba24b3
--- /dev/null
+++ b/pkg/tlsclient/sha256
@@ -0,0 +1 @@
+eeb635b1b1580cf3e9d3ad30d2f468f2e34a382ca3bf1ff3d255f63ce6cdf231 snap-36fd714f7addd87e6d87c695e949852e7c34fb80.tar.gz
diff --git a/pkg/tlsclient/url b/pkg/tlsclient/url
new file mode 100644
index 00000000..265e925e
--- /dev/null
+++ b/pkg/tlsclient/url
@@ -0,0 +1,2 @@
+output = "snap-36fd714f7addd87e6d87c695e949852e7c34fb80.tar.gz"
+url = "https://tcp80.org/git/grobe0ba/tlsclient/36fd714f7addd87e6d87c695e949852e7c34fb80/snap.tar.gz"
diff --git a/pkg/tlsclient/ver b/pkg/tlsclient/ver
new file mode 100644
index 00000000..6271a9a7
--- /dev/null
+++ b/pkg/tlsclient/ver
@@ -0,0 +1 @@
+36fd714f7addd87e6d87c695e949852e7c34fb80
diff --git a/rules.ninja b/rules.ninja
index 9f7cfcaa..79cceb33 100644
--- a/rules.ninja
+++ b/rules.ninja
@@ -9,6 +9,12 @@ rule cc
deps = gcc
description = CC $out
+rule cxx
+ command = $cxx -MD -MF $out.d $cflags -c -o $out $in
+ depfile = $out.d
+ deps = gcc
+ description = CXX $out
+
rule cpp
command = $cc -MD -MF $out.d $cflags -E -P -o $out $in
depfile = $out.d
@@ -20,7 +26,7 @@ rule as
description = AS $out
rule link
- command = $cc $ldflags -o $out $in $ldlibs
+ command = $cxx $ldflags -o $out -Wl,--start-group $in -Wl,--end-group
description = LINK $out
rule ar
diff --git a/sets.lua b/sets.lua
index 793e3ce7..e475dc47 100644
--- a/sets.lua
+++ b/sets.lua
@@ -87,4 +87,7 @@ return {
'velox',
'xkeyboard-config',
},
+ tlsclient={
+ 'tlsclient'
+ }
}