diff --git a/user/ruby3.2-rugged/APKBUILD b/user/ruby3.2-rugged/APKBUILD new file mode 100644 index 0000000..42f7818 --- /dev/null +++ b/user/ruby3.2-rugged/APKBUILD @@ -0,0 +1,75 @@ +# Contributor: Jakub Jirutka +# Maintainer: Jakub Jirutka +pkgname=ruby3.2-rugged +_gemname=rugged +pkgver=1.6.3 +pkgrel=1 +pkgdesc="Ruby bindings to libgit2" +url="https://github.com/libgit2/rugged" +arch="all" +license="MIT" +checkdepends=" + git + libgit2-tests + ruby3.2-minitest + ruby3.2-rake + ruby3.2-rake-compiler + " +makedepends=" + libgit2-dev>=${pkgver%.*} + ruby3.2 + ruby3.2-dev + " +source="$_gemname-$pkgver.tar.gz::https://github.com/libgit2/$_gemname/archive/v$pkgver.tar.gz + fix-extconf-version-check.patch + libgit2-fixture-dir.patch + libgit2-1.7.patch + skip-test_discover_false.patch + skip-test_read_global_config_file.patch + skip-online-tests.patch + " +builddir="$srcdir/$_gemname-$pkgver" +# Rugged::ConfigError: repository path '/tmp/' is not owned by current user +# requires tmp persmissions on host +options="!check" + +build() { + gem build $_gemname.gemspec + + RUGGED_USE_SYSTEM_LIBRARIES=1 gem install --local \ + --install-dir dist \ + --ignore-dependencies \ + --no-document \ + --verbose \ + $_gemname + + # Needed for tests. + cp -l dist/extensions/*/*/$_gemname-*/$_gemname/*.so lib/$_gemname/ +} + +check() { + rake test LIBGIT2_FIXTURE_DIR="/usr/src/libgit2/tests/resources" +} + +package() { + local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')" + cd "$builddir"/dist + + mkdir -p "$gemdir" + cp -r extensions gems specifications "$gemdir"/ + + # Remove unnecessary and duplicated files. + rm -f "$gemdir"/extensions/*/*/$_gemname-*/mkmf.log + cd "$gemdir"/gems/$_gemname-$pkgver + rm -rf ext/ lib/$_gemname/*.so LICENSE* README* +} + +sha512sums=" +4d54b5df04382628aff7e1abbf5fbd9730564c9bcb4e17da34ac59578b306db567b15151629a10c4a6d8174a31cd8be03c27ff0d1514cb19de237e773f4b64ce rugged-1.6.3.tar.gz +0e55aff667175496e9df1920c6d49042077196aa992a729323628224e7930a6f976bcbfae70d2af733a043c173e8cd5f571606f0b898b008472b40fcefe6b425 fix-extconf-version-check.patch +0c749aeb8d6a29aed51737bab09c7b0a6669ac691461758c856ede5d8510ad6edfa284cddd1b54982bf614a45ba817b70e838e071889a9b05e1b0580111ec826 libgit2-fixture-dir.patch +bcf7b554390fb2b1ef9043f8c934ae51a299f223ec1d7826dcb8eed078961cd084c05148c84142d60cc0a3213653bd416af1fbb09bfa5b26c9ce87fca79f6a18 libgit2-1.7.patch +33464eeefc7669fe3bf5f47c4016cacdcba4f7455ed22b441383b49721870072b5095dbb68832cdb933a7659a415476db64b579a98c888b83900d092bb8b54be skip-test_discover_false.patch +b9e028f18830e447773e895046eb03489e94bb5a76fede51f93545ed67f7249ed8f37ed4bb832eb68a2db281ff3e2b84dab8b72bb21eea4b835b0f1ce23943c3 skip-test_read_global_config_file.patch +5f0ad88eb7ac8c69605c43712e046efd47b727f48e98ee4047be850da4fea48c11fc2a383c791810a1bc81c08ca00428d4906c1af02a0d0da6e1ffbd4723b8f3 skip-online-tests.patch +" diff --git a/user/ruby3.2-rugged/fix-extconf-version-check.patch b/user/ruby3.2-rugged/fix-extconf-version-check.patch new file mode 100644 index 0000000..fc22612 --- /dev/null +++ b/user/ruby3.2-rugged/fix-extconf-version-check.patch @@ -0,0 +1,13 @@ +diff --git a/ext/rugged/extconf.rb b/ext/rugged/extconf.rb +index 7dbd2b3..92251e3 100644 +--- a/ext/rugged/extconf.rb ++++ b/ext/rugged/extconf.rb +@@ -70,7 +70,7 @@ if arg_config("--use-system-libraries", !!ENV['RUGGED_USE_SYSTEM_LIBRARIES']) + + major = minor = nil + +- File.readlines(File.join(LIBGIT2_DIR, "include", "git2", "version.h")).each do |line| ++ File.readlines(File.join("/usr", "include", "git2", "version.h")).each do |line| + if !major && (matches = line.match(/^#define LIBGIT2_VER_MAJOR\s+([0-9]+)$/)) + major = matches[1] + next diff --git a/user/ruby3.2-rugged/libgit2-1.7.patch b/user/ruby3.2-rugged/libgit2-1.7.patch new file mode 100644 index 0000000..4fe0884 --- /dev/null +++ b/user/ruby3.2-rugged/libgit2-1.7.patch @@ -0,0 +1,90 @@ +Patch-Source: https://github.com/libgit2/rugged/pull/964 +safe as we apply the libgit2 fix to libgit. +-- +From 508fbc2bcd8fdc400fcc4513b53d5205c4b7e9d4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= +Date: Tue, 18 Jul 2023 10:27:37 +0200 +Subject: [PATCH 1/3] Update libgit2 to v1.7.0 + +--- + vendor/libgit2 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/ext/rugged/rugged_allocator.c b/ext/rugged/rugged_allocator.c +index 30ee537..0059af6 100644 +--- a/ext/rugged/rugged_allocator.c ++++ b/ext/rugged/rugged_allocator.c +@@ -13,58 +13,11 @@ static void *rugged_gmalloc(size_t n, const char *file, int line) + return xmalloc(n); + } + +-static void *rugged_gcalloc(size_t nelem, size_t elsize, const char *file, int line) +-{ +- return xcalloc(nelem, elsize); +-} +- +-static char *rugged_gstrdup(const char *str, const char *file, int line) +-{ +- return ruby_strdup(str); +-} +- +-static char *rugged_gstrndup(const char *str, size_t n, const char *file, int line) +-{ +- size_t len; +- char *newstr; +- +- len = strnlen(str, n); +- if (len < n) +- n = len; +- +- newstr = xmalloc(n+1); +- memcpy(newstr, str, n); +- newstr[n] = '\0'; +- +- return newstr; +-} +- +-static char *rugged_gsubstrdup(const char *str, size_t n, const char *file, int line) +-{ +- char *newstr; +- +- newstr = xmalloc(n+1); +- memcpy(newstr, str, n); +- newstr[n] = '\0'; +- +- return newstr; +-} +- + static void *rugged_grealloc(void *ptr, size_t size, const char *file, int line) + { + return xrealloc(ptr, size); + } + +-static void *rugged_greallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line) +-{ +- return xrealloc2(ptr, nelem, elsize); +-} +- +-static void *rugged_gmallocarray(size_t nelem, size_t elsize, const char *file, int line) +-{ +- return xmalloc2(nelem, elsize); +-} +- + static void rugged_gfree(void *ptr) + { + xfree(ptr); +@@ -75,14 +28,7 @@ void rugged_set_allocator(void) + git_allocator allocator; + + allocator.gmalloc = rugged_gmalloc; +- allocator.gcalloc = rugged_gcalloc; +- allocator.gstrdup = rugged_gstrdup; +- allocator.gstrndup = rugged_gstrndup; +- allocator.gstrndup = rugged_gstrndup; +- allocator.gsubstrdup = rugged_gsubstrdup; + allocator.grealloc = rugged_grealloc; +- allocator.greallocarray = rugged_greallocarray; +- allocator.gmallocarray = rugged_gmallocarray; + allocator.gfree = rugged_gfree; + + git_libgit2_opts(GIT_OPT_SET_ALLOCATOR, &allocator); diff --git a/user/ruby3.2-rugged/libgit2-fixture-dir.patch b/user/ruby3.2-rugged/libgit2-fixture-dir.patch new file mode 100644 index 0000000..9d6a24d --- /dev/null +++ b/user/ruby3.2-rugged/libgit2-fixture-dir.patch @@ -0,0 +1,12 @@ +--- a/test/test_helper.rb ++++ b/test/test_helper.rb +@@ -130,7 +130,8 @@ + end + + TEST_DIR = File.dirname(File.expand_path(__FILE__)) +- LIBGIT2_FIXTURE_DIR = File.expand_path("../../vendor/libgit2/tests/resources", __FILE__) ++ LIBGIT2_FIXTURE_DIR = ENV['LIBGIT2_FIXTURE_DIR'] \ ++ || File.expand_path("../../vendor/libgit2/tests/resources", __FILE__) + end + + class OnlineTestCase < TestCase diff --git a/user/ruby3.2-rugged/skip-online-tests.patch b/user/ruby3.2-rugged/skip-online-tests.patch new file mode 100644 index 0000000..c0cb6a6 --- /dev/null +++ b/user/ruby3.2-rugged/skip-online-tests.patch @@ -0,0 +1,15 @@ +Skip all online tests. + +--- a/test/test_helper.rb ++++ b/test/test_helper.rb +@@ -155,6 +156,10 @@ + end + + super ++ end ++ else ++ def before_setup ++ skip 'online tests have been disabled' + end + end + diff --git a/user/ruby3.2-rugged/skip-test_discover_false.patch b/user/ruby3.2-rugged/skip-test_discover_false.patch new file mode 100644 index 0000000..e968c02 --- /dev/null +++ b/user/ruby3.2-rugged/skip-test_discover_false.patch @@ -0,0 +1,27 @@ +Skip these two tests: + + 1) Failure: +RepositoryDiscoverTest#test_discover_false [/home/jirutjak/aports/testing/ruby-rugged/src/rugged-0.26.0/test/repo_test.rb:426]: +Rugged::RepositoryError expected but nothing was raised. + + 2) Failure: +RepositoryDiscoverTest#test_discover_nested_false [/home/jirutjak/aports/testing/ruby-rugged/src/rugged-0.26.0/test/repo_test.rb:432]: +Rugged::RepositoryError expected but nothing was raised. + +--- a/test/repo_test.rb ++++ b/test/repo_test.rb +@@ -423,12 +423,14 @@ + end + + def test_discover_false ++ skip 'I have no idea why this test does not pass :(' + assert_raises Rugged::RepositoryError do + Rugged::Repository.discover(@tmpdir) + end + end + + def test_discover_nested_false ++ skip 'I have no idea why this test does not pass :(' + assert_raises Rugged::RepositoryError do + Rugged::Repository.discover(File.join(@tmpdir, 'foo')) + end diff --git a/user/ruby3.2-rugged/skip-test_read_global_config_file.patch b/user/ruby3.2-rugged/skip-test_read_global_config_file.patch new file mode 100644 index 0000000..d3a3310 --- /dev/null +++ b/user/ruby3.2-rugged/skip-test_read_global_config_file.patch @@ -0,0 +1,13 @@ +It seems that this test fails when user.name is NOT set in ~/.gitconfig +on the build system. + +--- a/test/config_test.rb ++++ b/test/config_test.rb +@@ -17,6 +17,7 @@ + end + + def test_read_global_config_file ++ skip 'This test is flawed, it runs on real FS, i.e. it is not isolated' + config = Rugged::Config.global + refute_nil config['user.name'] + assert_nil config['core.bare']