#!/usr/bin/env perl use strict; use warnings; use Path::Tiny; use File::pushd qw/pushd/; my $destdir = Path::Tiny->tempdir; my $recuento_inner = $destdir->child('recuento'); print $recuento_inner.''; $recuento_inner->mkpath; my $resources = $recuento_inner->child('resources'); $resources->mkpath; copy_recursive('/home/sergio/recuento_root/usr/bin/recuento{,_{launcher,installer}_windows}.exe', $recuento_inner); copy_recursive('/home/sergio/recuento_root/usr/bin/rsvg-convert.exe', $recuento_inner); copy_recursive('/home/sergio/recuento_root/usr/bin/rsvg-convert.exe', $destdir); copy_recursive('/home/sergio/recuento_root/usr/bin/*.{dll,DLL}', $destdir); copy_recursive('/home/sergio/recuento_root/usr/bin/*.{dll,DLL}', $recuento_inner); copy_recursive('/usr/lib/gcc/x86_64-w64-mingw32/11.3.0/libgcc_s_seh-1.dll', $destdir); copy_recursive('/usr/lib/gcc/x86_64-w64-mingw32/11.3.0/libgcc_s_seh-1.dll', $recuento_inner); copy_recursive('/usr/x86_64-w64-mingw32/usr/bin/libwinpthread-1.dll', $destdir); copy_recursive('/usr/x86_64-w64-mingw32/usr/bin/libwinpthread-1.dll', $recuento_inner); copy_recursive('/usr/lib/gcc/x86_64-w64-mingw32/11.3.0/libstdc++-6.dll', $destdir); copy_recursive('/usr/lib/gcc/x86_64-w64-mingw32/11.3.0/libstdc++-6.dll', $recuento_inner); copy_recursive('/home/sergio/recuento_root/usr/share/recuento/', $resources); move_launcher ($recuento_inner, $destdir); #make_config ($recuento_inner); make_share ($destdir); compress_7z($destdir); create_executable(); sub create_executable { my $zip = path('recuento.7z'); my $executable = path('recuento.exe'); open my $fh, '-|', qw@cat /usr/x86_64-w64-mingw32/usr/bin/7zS2.sfx.exe@, $zip; binmode $fh, ':raw'; my $executable_contents = join '', <$fh>; $executable->spew($executable_contents); } sub make_share { my $recuento = shift; my $share_fonts = $recuento->child('share', 'fonts'); my $share_icons = $recuento->child('share', 'icons'); my $share_schemas = $recuento->child('share', 'glib-2.0', 'schemas'); $share_schemas->mkpath; $share_fonts->mkpath; $share_icons->mkpath; copy_recursive('/home/sergio/recuento_root/usr/share/icons/Adwaita', $share_icons.''); copy_recursive('/home/sergio/recuento_root/usr/share/glib-2.0/schemas/*', $share_schemas.''); } sub make_config { my $recuento = shift; my $etc_gtk = $recuento->child('etc', 'gtk-4.0'); $etc_gtk->mkpath; $etc_gtk->child('settings.ini')->spew(<<'EOF'); [Settings] gtk-font-name=Segoe UI 100 EOF } sub move_launcher { my $recuento_inner = shift; my $recuento = shift; my $filename = 'Recuento.exe'; system 'cp', $recuento_inner->child('recuento_launcher_windows.exe'), $recuento->child($filename); } sub copy_recursive { my $source = shift; my $dest = shift; return !!0+system 'cp', '-Lr', glob($source), $dest; } sub compress_7z { my $destdir = shift; my $zip_output = path($0)->parent->child('recuento.7z')->absolute; $zip_output->remove if -e $zip_output; my $pushd = pushd $destdir; system qw/7z a -t7z -m0=LZMA2:d64k:fb32 -ms=8m -mmt=4 -mx=1 -r /,$zip_output, '.'; }