-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenbin.pl
executable file
·51 lines (44 loc) · 1.33 KB
/
genbin.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl -w
# Copyright (c) 2024 Dry Ark LLC
use strict;
use FindBin qw($RealBin);
use lib 'mod';
use Util qw/files_in_dir find_in_dir_x/;
my $libabs = "$RealBin/lib";
my $binabs = "$RealBin/bin";
for my $pkgDir ( files_in_dir( "pkgs" ) ) {
next if( $pkgDir =~ m/~$/ );
my $full = "pkgs/$pkgDir";
next if( ! -d $full );
handle_dir( $full );
}
sub handle_dir {
my $dir = shift;
for my $versionDir ( files_in_dir( "./$dir" ) ) {
if( $versionDir =~ m/^[0-9\.\_]+$/ ) {
#print "$dir/$file\n";
my $bindir = "$dir/$versionDir/bin";
handle_bindir( $bindir ) if( -e $bindir );
}
}
}
sub handle_bindir {
my $bindir = shift;
for my $bin ( find_in_dir_x( $bindir, "x", 0 ) ) {
my $rel = $bin->{rel};
my $symlink = "bin/$rel";
unlink $symlink if( -e $symlink );
my $dest = "../" . $bin->{full};
if( $rel eq 'python3' ) {
symlink( $dest, "bin/python3-real" );
open( my $fh, ">bin/python3" );
print $fh "#!/bin/bash\n".
"export PYTHONHOME=$libabs/pythonHome\n".
"exec $binabs/python3-real \"\$\@\"\n";
close( $fh );
chmod 0755, "bin/python3";
next;
}
symlink( $dest, $symlink );
}
}