https://gitlab.gnome.org/GNOME/libgit2-glib/-/merge_requests/37

From 1659bb3a124c935848203828304c9efe943258db Mon Sep 17 00:00:00 2001
From: Matt Turner <mattst88@gmail.com>
Date: Thu, 13 Apr 2023 17:36:52 -0400
Subject: [PATCH] meson: Use install_symlink

New in v0.61.0, the install_symlink function lets us install symlinks
directly from Meson, allowing us to remove the meson_vapi_link.py
script.
---
 meson.build        | 10 ++++++++--
 meson_vapi_link.py | 27 ---------------------------
 2 files changed, 8 insertions(+), 29 deletions(-)
 delete mode 100755 meson_vapi_link.py

diff --git a/meson.build b/meson.build
index 8f30cda..5598e19 100644
--- a/meson.build
+++ b/meson.build
@@ -3,7 +3,7 @@ project(
   version: '1.1.0',
   default_options: 'buildtype=debugoptimized',
   license: 'LGPL2+',
-  meson_version: '>= 0.50.0',
+  meson_version: '>= 0.61.0',
 )
 
 libgit2_glib_version = meson.project_version()
@@ -136,7 +136,13 @@ if enable_vapi
   assert(enable_gir, 'vapi support was requested, but introspection support is mandatory.')
   assert(add_languages('vala', required: false), 'vapi support was requested, but vala not found.')
 
-  meson.add_install_script('meson_vapi_link.py', libgit2_glib_datadir)
+  foreach ext : ['vapi', 'deps']
+    install_symlink(
+      'ggit-1.0.' + ext,
+      install_dir: libgit2_glib_prefix / libgit2_glib_datadir / 'vala' / 'vapi',
+      pointing_to: 'libgit2-glib-1.0.' + ext,
+    )
+  endforeach
 endif
 
 # Check for libgit2 ssh support
diff --git a/meson_vapi_link.py b/meson_vapi_link.py
deleted file mode 100755
index 20afe0c..0000000
--- a/meson_vapi_link.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env python3
-
-import os
-import shutil
-import sys
-
-prefix = os.environ['MESON_INSTALL_DESTDIR_PREFIX'] if os.environ.get('DESTDIR') else os.environ['MESON_INSTALL_PREFIX']
-
-datadir = os.path.join(prefix, sys.argv[1])
-
-vapidir = os.path.join(datadir, 'vala', 'vapi')
-os.chdir(vapidir)
-
-# FIXME: meson will not track the creation of these files
-#        https://github.com/mesonbuild/meson/blob/master/mesonbuild/scripts/uninstall.py#L39
-old = 'ggit-1.0'
-new = 'libgit2-glib-1.0'
-
-for ext in ['vapi', 'deps']:
-  src = '{}.{}'.format(new, ext)
-  dest = '{}.{}'.format(old, ext)
-  try:
-      os.symlink(src, dest)
-  except FileExistsError:
-      pass
-  except OSError:
-      shutil.copy(src, dest)
-- 
2.39.2

