[PATCH 6/6] Ditch Python dependent make_rel_symlink with ln -sr

[email protected] Wed, 27 May 2026 15:29:03 +0300
Newsgroups gmane.comp.hardware.lirc
Message-ID <[email protected]>
From: Doron Behar <[email protected]>

---
 doc/Makefile.am           | 10 ++++----
 doc/make_rel_symlink.py   | 44 ---------------------------------
 tools/Makefile.am         | 13 +++++-----
 tools/make_rel_symlink.py | 52 ---------------------------------------
 4 files changed, 11 insertions(+), 108 deletions(-)
 delete mode 100644 doc/make_rel_symlink.py
 delete mode 100644 tools/make_rel_symlink.py

diff --git a/doc/Makefile.am b/doc/Makefile.am
index f376c1a5..99e7d6e8 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -6,7 +6,7 @@ CLEANFILES              = man/* html/* man-html/* driver-toc.xsl \
                           doxygen*warning* ext-driver-toc.xsl
 
 EXTRA_DIST              = Doxyfile manpage.xsl make-driver-toc.sh \
-                          make_rel_symlink.py index.html plugindocs.mk \
+                          index.html plugindocs.mk \
                           fix-urls.sh doxypypy.py py_filter
 
 if DEVEL
@@ -100,11 +100,11 @@ endif
 install-data-hook: install-apidocs
 	cd $(DESTDIR)$(websitedir)/api-docs; ln -sf html/index.html .
 	$(SED) -i '/class="footer"/,/p>/d' $(DESTDIR)$(plugindocsdir)/page.xsl
-	$(PYTHON) $(srcdir)/make_rel_symlink.py \
-	    $(DESTDIR)$(vardocsdir) $(DESTDIR)$(plugindocsdir)/var
-	$(PYTHON) $(srcdir)/make_rel_symlink.py \
+	cd $(DESTDIR)$(plugindocsdir); ln -sr \
+	    $(DESTDIR)$(vardocsdir) var
+	cd $(DESTDIR)$(website_htmldir); ln -sr \
 	    $(DESTDIR)$(vardocsdir)/index.html \
-	    $(DESTDIR)$(website_htmldir)/plugins-index.html
+	    plugins-index.html
 	cp $(srcdir)/plugindocs.mk $(DESTDIR)$(plugindocsdir)/Makefile
 	$(SED) -e 's|$(abs_srcdir)|$(datadocdir)|' \
 	       -e 's|$(abs_builddir)|$(docdir)/plugindocs|' \
diff --git a/doc/make_rel_symlink.py b/doc/make_rel_symlink.py
deleted file mode 100644
index 9b8fab02..00000000
--- a/doc/make_rel_symlink.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import os
-import os.path
-import sys
-import pdb
-import shutil
-
-def relative_ln_s( from_, to_ ):
-    """
-
-    This is just so dirty & boring: create a relative symlink, making the
-    to_ path relative to from_. No errorchecks. Both arguments must be
-    files, a destination directory doesn't work (I think). An existing
-    file in to_ will be removed.
-
-    """
-    prefix = os.path.commonprefix( [ to_, from_ ] )
-    if prefix == '':
-        prefix = '/'
-    source = from_.split(prefix )[ 1 ]
-    dest = to_.split(prefix)[1]
-    level = len(dest.split('/')) - 1
-    path =  ('../' * level) + source
-    return path
-
-USAGE = 'Usage: make_rel_symlink [-p]  <sourcefile> <destfile>'
-
-just_print = False;
-if sys.argv[1] == "-p":
-    just_print = True;
-    sys.argv = sys.argv[ 1:]
-
-if len(sys.argv) != 3:
-    print(USAGE)
-    sys.exit(1)
-
-link_path = relative_ln_s(sys.argv[1], sys.argv[2])
-if just_print:
-    print(link_path)
-else:
-    os.chdir( os.path.dirname( sys.argv[2]))
-    target = os.path.basename( sys.argv[2])
-    if os.path.exists( target ):
-        os.unlink( target)
-    os.symlink( link_path, target)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 96b17f87..dc0e4c71 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -79,7 +79,7 @@ endif
 
 dist_bin_SCRIPTS        += pronto2lirc irdb-get irtext2udp lirc-postinstall
 dist_sbin_SCRIPTS       = lircd-setup
-dist_noinst_SCRIPTS     = make_rel_symlink.py check_configs.py
+dist_noinst_SCRIPTS     = check_configs.py
 
 libpython               = $(libdir)/python$(PYTHON_VERSION)
 
@@ -115,13 +115,12 @@ install-data-hook:
 	cd $(DESTDIR)/$(setupdir);  \
 	    $(SED) -i '1s|python3[0-9\.]*|$(PYTHON)|' \
 	        $(notdir $(dist_setup_SCRIPTS))
-	$(PYTHON) $(srcdir)/make_rel_symlink.py \
-	    $(DESTDIR)/$(setupdir)/lirc-setup \
-	    $(DESTDIR)/$(bindir)/lirc-setup
+	cd $(DESTDIR)/$(bindir); \
+	    ln -sr \
+	    	$(DESTDIR)/$(setupdir)/lirc-setup
 	rm -rf $(DESTDIR)/$(setupdir)/configs
-	$(PYTHON) $(srcdir)/make_rel_symlink.py \
-	    $(DESTDIR)/$(pkgdatadir)/configs \
-	        $(DESTDIR)/$(setupdir)/configs
+	cd $(DESTDIR)/$(setupdir); \
+	    ln -sr $(DESTDIR)/$(pkgdatadir)/configs
 
 uninstall-hook:
 	rm -f $(DESTDIR)/$(bindir)/lirc-setup \
diff --git a/tools/make_rel_symlink.py b/tools/make_rel_symlink.py
deleted file mode 100644
index cb1e6b5f..00000000
--- a/tools/make_rel_symlink.py
+++ /dev/null
@@ -1,52 +0,0 @@
-import os
-import os.path
-import sys
-import shutil
-
-def relative_ln_s( from_, to_ ):
-    """
-
-    This is just so dirty & boring: create a relative symlink, making the
-    to_ path relative to from_. No errorchecks. Both arguments must be
-    files, a destination directory doesn't work (I think). An existing
-    file in to_ will be removed.
-
-    """
-    prefix = os.path.commonprefix( [ to_, from_ ] )
-    if prefix == '':
-        prefix = '/'
-    source = from_.split( prefix )[ 1 ]
-    dest   = to_.split( prefix )[ 1 ]
-    level = len( dest.split( '/' ) ) - 1
-    path =  ( '../' * level ) + source
-    return path
-
-USAGE = 'Usage: make_rel_symlink [-p]  <sourcefile> <destfile>'
-
-just_print = False;
-if sys.argv[1] == "-p":
-    just_print = True;
-    sys.argv = sys.argv[ 1:]
-
-if len( sys.argv ) != 3:
-    print(USAGE)
-    sys.exit( 1 )
-
-if  os.path.isdir(  sys.argv[2] ):
-    print("Removing link target dir:" +  sys.argv[2])
-    if os.path.islink(sys.argv[2]):
-        os.unlink(sys.argv[2])
-    else:
-        shutil.rmtree(sys.argv[2])
-
-link_path = relative_ln_s( sys.argv[1], sys.argv[2] )
-if just_print:
-    print(link_path)
-else:
-    os.chdir( os.path.dirname( sys.argv[2]))
-    target = os.path.basename( sys.argv[2])
-    if os.path.exists( target ):
-        os.unlink( target)
-    os.symlink( link_path, target)
-
-
-- 
2.54.0