commit:     736541eab91711d7f5fc0f3b49395bb1e2d5bbf4
Author:     Lucio Sauer <watermanpaint <AT> posteo <DOT> net>
AuthorDate: Sun Jul  2 20:17:12 2023 +0000
Commit:     Viorel Munteanu <ceamac <AT> gentoo <DOT> org>
CommitDate: Sun Jul  2 20:17:12 2023 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=736541ea

dev-libs/lsbcrypt: fix to install the built lib

* Drop superfluous eclasses
* Add the public-domain license
* Patch tests to abort on failure
* Actually install the compiled lib in src_install

Signed-off-by: Lucio Sauer <watermanpaint <AT> posteo.net>

 dev-libs/lsbcrypt/Manifest                    |  1 +
 dev-libs/lsbcrypt/files/1.0.0-fix-tests.patch | 55 +++++++++++++++++++++++++++
 dev-libs/lsbcrypt/lsbcrypt-1.0.0-r1.ebuild    | 28 ++++++++++++++
 3 files changed, 84 insertions(+)

diff --git a/dev-libs/lsbcrypt/Manifest b/dev-libs/lsbcrypt/Manifest
new file mode 100644
index 000000000..40e6aed58
--- /dev/null
+++ b/dev-libs/lsbcrypt/Manifest
@@ -0,0 +1 @@
+DIST lsbcrypt-1.0.0.gh.tar.gz 35444 BLAKE2B 
b179a4d117aa90520f91432feecae0c94bda91024a349c6b3efc88aa8fedd9f0e9ba285fb2d0b5b45ec6ee28189a118f1785c7afd3375b64cbdb0f6ed392339b
 SHA512 
7304acb02031fe2d7aaa667179b0539b30570750676c8474ea662a5505cf1b9f09d29e2927d15996fa1ee5c181f9c9aea54137b48252f82430b75a3d5e36d80b

diff --git a/dev-libs/lsbcrypt/files/1.0.0-fix-tests.patch 
b/dev-libs/lsbcrypt/files/1.0.0-fix-tests.patch
new file mode 100644
index 000000000..364dd3fd0
--- /dev/null
+++ b/dev-libs/lsbcrypt/files/1.0.0-fix-tests.patch
@@ -0,0 +1,55 @@
+Extend pre-computed hash{1,2} by 3 bytes each to BCRYPT_HASHSIZE = 64 bytes.
+bcrypt_hashpw expects the second and third argument to have room for at least
+many characters.
+Though this is probably not an issue in production, I have contacted upstream
+about it on 2023-07-02 at <i...@litespeedtech.com>.
+
+Additionally, abort execution of test runner on failure for "die" to trigger.
+
+Signed-off-by: Lucio Sauer <watermanpa...@posteo.net>
+diff --git a/bcrypt.c b/bcrypt.c
+index bd8722b..0c230f2 100644
+--- a/bcrypt.c
++++ b/bcrypt.c
+@@ -155,8 +155,8 @@ int main(void)
+       int ret;
+ 
+       const char pass[] = "hi,mom";
+-      const char hash1[] = 
"$2a$10$VEVmGHy4F4XQMJ3eOZJAUeb.MedU0W10pTPCuf53eHdKJPiSE8sMK";
+-      const char hash2[] = 
"$2a$10$3F0BVk5t8/aoS.3ddaB3l.fxg5qvafQ9NybxcpXLzMeAt.nVWn.NO";
++      const char hash1[] = 
"$2a$10$VEVmGHy4F4XQMJ3eOZJAUeb.MedU0W10pTPCuf53eHdKJPiSE8sMK\0\0\0";
++      const char hash2[] = 
"$2a$10$3F0BVk5t8/aoS.3ddaB3l.fxg5qvafQ9NybxcpXLzMeAt.nVWn.NO\0\0\0";
+ 
+       ret = bcrypt_gensalt(12, salt);
+       assert(ret == 0);
+@@ -171,22 +171,26 @@ int main(void)
+ 
+       ret = bcrypt_hashpw(pass, hash1, hash);
+       assert(ret == 0);
+-      printf("First hash check: %s\n", (strcmp(hash1, hash) == 
0)?"OK":"FAIL");
++      assert(strcmp(hash1, hash) == 0);
++      printf("First hash check: OK\n");
+       ret = bcrypt_hashpw(pass, hash2, hash);
+       assert(ret == 0);
+-      printf("Second hash check: %s\n", (strcmp(hash2, hash) == 
0)?"OK":"FAIL");
++      assert(strcmp(hash2, hash) == 0);
++      printf("Second hash check: OK\n");
+ 
+       before = clock();
+       ret = (bcrypt_checkpw(pass, hash1) == 0);
+       after = clock();
+-      printf("First hash check with bcrypt_checkpw: %s\n", ret?"OK":"FAIL");
++      assert(ret == 1);
++      printf("First hash check with bcrypt_checkpw: OK\n");
+       printf("Time taken: %f seconds\n",
+              (double)(after - before) / CLOCKS_PER_SEC);
+ 
+       before = clock();
+       ret = (bcrypt_checkpw(pass, hash2) == 0);
+       after = clock();
+-      printf("Second hash check with bcrypt_checkpw: %s\n", ret?"OK":"FAIL");
++      assert(ret == 1);
++      printf("Second hash check with bcrypt_checkpw: OK\n");
+       printf("Time taken: %f seconds\n",
+              (double)(after - before) / CLOCKS_PER_SEC);
+ 

diff --git a/dev-libs/lsbcrypt/lsbcrypt-1.0.0-r1.ebuild 
b/dev-libs/lsbcrypt/lsbcrypt-1.0.0-r1.ebuild
new file mode 100644
index 000000000..c25c6972d
--- /dev/null
+++ b/dev-libs/lsbcrypt/lsbcrypt-1.0.0-r1.ebuild
@@ -0,0 +1,28 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+COMMIT="55ff64349dec3012cfbbb1c4f92d4dbd46920213"
+DESCRIPTION="libcrypt wrapper for LiteSpeedTech"
+HOMEPAGE="https://github.com/litespeedtech/libbcrypt/";
+SRC_URI="https://github.com/litespeedtech/libbcrypt/archive/${COMMIT}.tar.gz 
-> ${P}.gh.tar.gz"
+LICENSE="CC0-1.0 public-domain"
+SLOT="0"
+KEYWORDS="~amd64"
+
+S="${WORKDIR}/libbcrypt-${COMMIT}"
+
+PATCHES=(
+       "${FILESDIR}"/${PV}-fix-tests.patch
+)
+
+src_test() {
+       default
+       ./bcrypt_test || die "Tests failed!"
+}
+
+src_install() {
+       newlib.a bcrypt.a libbcrypt.a
+       einstalldocs
+}

Reply via email to