#1029498 gem2deb should simplify the copy and symlink of assets

Package:
gem2deb
Source:
gem2deb
Description:
Debian Ruby packaging suite
Submitter:
Pirate Praveen
Date:
2023-01-23 11:57:04 UTC
Severity:
normal
#1029498#5
Date:
2023-01-23 11:52:22 UTC
From:
To:
Currently for many ruby packages (rails engines) that ships a
javascript asset, we have to manually copy the asset before build and
replace it with a symlink after install. It'd be nice if gem2deb can
automate these manual steps with a mapping file. This will create a
much cleaner rules file and avoid repetition.

How about debian/ruby-foo.assets, which will have relative paths for
source and destination, an example below

jquery-atwho/jquery.atwho.js
lib/assets/javascripts/jquery.atwho/jquery.atwho.js

Source can be relative to /usr/share/javascript/ or absolute path and
destination can be relative to package directory.

Currently in rules I have,

execute_before_dh_auto_build:
 cp /usr/share/javascript/jquery-atwho/jquery.atwho.js
$(CURDIR)/lib/assets/javascripts/jquery.atwho/jquery.atwho.js
 cp /usr/share/javascript/caret.js/jquery.caret.js
$(CURDIR)/lib/assets/javascripts/jquery.atwho/jquery.caret.js

execute_after_dh_install:
 debian/symlink-js

and
 cat debian/symlink-js
#!/bin/sh
version=$(dpkg-parsechangelog -S version |cut -d'+' -f1)
ln -sf /usr/share/javascript/jquery-atwho/jquery.atwho.js
debian/ruby-jquery-atwho-rails/usr/share/rubygems-integration/all/gems/jquery-atwho-rails-${version}/lib/assets/javascripts/jquery.atwho/jquery.atwho.js
ln -sf /usr/share/javascript/caret.js/jquery.caret.js
debian/ruby-jquery-atwho-rails/usr/share/rubygems-integration/all/gems/jquery-atwho-rails-${version}/lib/assets/javascripts/jquery.atwho/jquery.caret.js