mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 02:38:03 +00:00 
			
		
		
		
	Fix perl use of 'use lib'
The 'use lib' logic happens in the pre-compile stage, so one cannot use normal 'if' logic to use a particular INC. Instead, just make sure that best dir is added to 'use lib' last since it prepends to INC.
This commit is contained in:
		| @@ -17,13 +17,12 @@ package main; | ||||
|  | ||||
| # Un-buffer output | ||||
| $| = 1; | ||||
|  # this is pedantic necessity for the following use statements | ||||
| if ( $cwd =~ q(.*LANforge-Server\scripts$)) { | ||||
|    use lib '/home/lanforge/scripts' | ||||
| } | ||||
| else { | ||||
|    use lib '/home/lanforge/scripts'; | ||||
| } | ||||
|  | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use List::Util qw(first); | ||||
| use LANforge::Endpoint; | ||||
| use LANforge::Utils; | ||||
|   | ||||
| @@ -9,12 +9,12 @@ if (defined $ENV{DEBUG}) { | ||||
| } | ||||
| use Time::HiRes qw(usleep ualarm gettimeofday stat lstat utime); | ||||
| #use Time::Format qw/%time/; | ||||
| if ( -f "./LANforge/Utils.pm" ) { | ||||
|    use lib '.'; | ||||
| } | ||||
| elsif ( -f "/home/lanforge/scripts/LANforge/Utils.pm" ) { | ||||
|    use lib "/home/lanforge/scripts/LANforge"; | ||||
| } | ||||
|  | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use LANforge::Utils; | ||||
| use Net::Telnet (); | ||||
| use Getopt::Long; | ||||
|   | ||||
| @@ -17,6 +17,8 @@ use LWP::UserAgent; | ||||
| use Data::Dumper; | ||||
| use JSON; | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "../"; | ||||
| use lib "./"; | ||||
| use LANforge::JsonUtils qw(logg err json_request get_links_from get_thru json_post get_port_names flatten_list); | ||||
|  | ||||
| package main; | ||||
|   | ||||
| @@ -16,6 +16,8 @@ use LWP::UserAgent; | ||||
| use Data::Dumper; | ||||
| use JSON; | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "../"; | ||||
| use lib "./"; | ||||
| use LANforge::JsonUtils qw(logg err json_request get_links_from get_thru json_post get_port_names); | ||||
|  | ||||
| package main; | ||||
|   | ||||
| @@ -23,6 +23,8 @@ use Time::HiRes qw(usleep nanosleep); | ||||
|  | ||||
| use Proc::Background; | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "../"; | ||||
| use lib "./"; | ||||
| use LANforge::JsonUtils qw(logg err json_request get_links_from get_thru json_post get_port_names); | ||||
|  | ||||
| package main; | ||||
|   | ||||
| @@ -17,6 +17,8 @@ use Data::Dumper; | ||||
| use JSON; | ||||
| use Linux::Inotify2; | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "../"; | ||||
| use lib "./"; | ||||
| use LANforge::JsonUtils qw(logg err json_request get_links_from get_thru json_post get_port_names); | ||||
|  | ||||
| package main; | ||||
|   | ||||
| @@ -17,6 +17,8 @@ use Data::Dumper; | ||||
| use Time::HiRes qw(usleep); | ||||
| use JSON; | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "../"; | ||||
| use lib "./"; | ||||
| use LANforge::JsonUtils qw(logg err json_request get_links_from get_thru json_post get_port_names flatten_list); | ||||
|  | ||||
| package main; | ||||
|   | ||||
| @@ -17,6 +17,8 @@ use Data::Dumper; | ||||
| use Time::HiRes qw(usleep); | ||||
| use JSON; | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "../"; | ||||
| use lib "./"; | ||||
| use LANforge::JsonUtils qw(logg err json_request get_links_from get_thru json_post get_port_names flatten_list); | ||||
|  | ||||
| package main; | ||||
|   | ||||
| @@ -17,6 +17,8 @@ use LWP::UserAgent; | ||||
| use Data::Dumper; | ||||
| use JSON; | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "../"; | ||||
| use lib "./"; | ||||
| use LANforge::JsonUtils qw(logg err json_request get_links_from get_thru json_post get_port_names flatten_list); | ||||
|  | ||||
| package main; | ||||
|   | ||||
| @@ -17,6 +17,8 @@ use LWP::UserAgent; | ||||
| use Data::Dumper; | ||||
| use JSON; | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "../"; | ||||
| use lib "./"; | ||||
| use LANforge::JsonUtils qw(logg err json_request get_links_from get_thru json_post get_port_names); | ||||
|  | ||||
| package main; | ||||
|   | ||||
| @@ -17,6 +17,8 @@ use LWP::UserAgent; | ||||
| use Data::Dumper; | ||||
| use JSON; | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "../"; | ||||
| use lib "./"; | ||||
| use LANforge::JsonUtils qw(logg err json_request get_links_from get_thru json_post get_port_names flatten_list); | ||||
|  | ||||
| package main; | ||||
|   | ||||
| @@ -17,6 +17,8 @@ use LWP::UserAgent; | ||||
| use Data::Dumper; | ||||
| use JSON; | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "../"; | ||||
| use lib "./"; | ||||
| use LANforge::JsonUtils qw(err logg xpand json_request); | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -14,12 +14,12 @@ $SIG{ __DIE__  } = sub { Carp::confess( @_ ) }; | ||||
| $SIG{ __WARN__ } = sub { Carp::confess( @_ ) }; | ||||
| # Un-buffer output | ||||
| $| = 1; | ||||
| if (-f "LANforge/Endpoint.pm" ) { | ||||
|   use lib "./"; | ||||
| } | ||||
| else { | ||||
|   use lib '/home/lanforge/scripts'; | ||||
| } | ||||
|  | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use LANforge::Endpoint; | ||||
| use LANforge::Port; | ||||
| use LANforge::Utils; | ||||
|   | ||||
| @@ -10,12 +10,12 @@ use Data::Dumper; | ||||
|  | ||||
| # Un-buffer output | ||||
| $| = 1; | ||||
| if ( -f "LANforge/Endpoint.pm" ) { | ||||
|   use lib "./"; | ||||
| } | ||||
| else { | ||||
|   use lib '/home/lanforge/scripts'; | ||||
| } | ||||
|  | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use LANforge::Endpoint; | ||||
| use LANforge::Port; | ||||
| use LANforge::Utils; | ||||
|   | ||||
| @@ -74,13 +74,11 @@ $| = 1; | ||||
| use Cwd qw(getcwd); | ||||
| my $cwd = getcwd(); | ||||
|  | ||||
|  # this is pedantic necessity for the following use statements | ||||
| if ( $cwd =~ q(.*LANforge-Server\scripts$)) { | ||||
|    use lib '/home/lanforge/scripts' | ||||
| } | ||||
| else { | ||||
|    use lib '/home/lanforge/scripts'; | ||||
| } | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use List::Util qw(first); | ||||
| use LANforge::Endpoint; | ||||
| use LANforge::Port; | ||||
|   | ||||
| @@ -13,7 +13,12 @@ use Carp; | ||||
|  | ||||
| # Un-buffer output | ||||
| $| = 1; | ||||
|  | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use LANforge::Endpoint; | ||||
| use LANforge::Port; | ||||
| use LANforge::Utils; | ||||
|   | ||||
| @@ -6,7 +6,12 @@ $SIG{ __DIE__ } = sub { Carp::confess( @_ ) }; | ||||
|  | ||||
| # Un-buffer output | ||||
| $| = 1; | ||||
|  | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use LANforge::Endpoint; | ||||
| use LANforge::Port; | ||||
| use LANforge::Utils; | ||||
|   | ||||
| @@ -11,7 +11,12 @@ use warnings; | ||||
|  | ||||
| # Un-buffer output | ||||
| $| = 1; | ||||
|  | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use LANforge::Endpoint; | ||||
| use LANforge::Port; | ||||
| use LANforge::Utils; | ||||
|   | ||||
| @@ -15,12 +15,12 @@ $SIG{ __WARN__ } = sub { Carp::confess( @_ ) }; | ||||
|  | ||||
| # Un-buffer output | ||||
| $| = 1; | ||||
| if (-f "LANforge/Endpoint.pm" ) { | ||||
|    use lib "./"; | ||||
| } | ||||
| else { | ||||
|   use lib '/home/lanforge/scripts'; | ||||
| } | ||||
|  | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use LANforge::Endpoint; | ||||
| use LANforge::Port; | ||||
| use LANforge::Utils; | ||||
|   | ||||
| @@ -33,7 +33,12 @@ $SIG{ __WARN__ }  = sub { Carp::confess( @_ )}; | ||||
| use Getopt::Long; | ||||
| use Cwd qw(getcwd); | ||||
| my $cwd = getcwd(); | ||||
|  | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use List::Util qw(first); | ||||
| use LANforge::Endpoint; | ||||
| use LANforge::Port; | ||||
|   | ||||
							
								
								
									
										13
									
								
								lf_ice.pl
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								lf_ice.pl
									
									
									
									
									
								
							| @@ -16,14 +16,11 @@ $SIG{ __WARN__ } = sub { Carp::confess( @_ ) }; | ||||
| # Un-buffer output | ||||
| $| = 1; | ||||
|  | ||||
| if ( -d "./LANforge" ) { | ||||
|    use lib "."; | ||||
|    use lib "./LANforge"; | ||||
| } | ||||
| elsif ( -d "/home/lanforge/scripts/LANforge") { | ||||
|    use lib "/home/lanforge/scripts"; | ||||
|    use lib "/home/lanforge/scripts/LANforge"; | ||||
| } | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use LANforge::Endpoint; | ||||
| use LANforge::Port; | ||||
| use LANforge::Utils; | ||||
|   | ||||
							
								
								
									
										12
									
								
								lf_icemod.pl
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								lf_icemod.pl
									
									
									
									
									
								
							| @@ -19,14 +19,10 @@ our $Q = q("); | ||||
| # Un-buffer output | ||||
| $| = 1; | ||||
|  | ||||
| if ( -d "./LANforge" ) { | ||||
|    use lib "."; | ||||
|    use lib "./LANforge"; | ||||
| } | ||||
| elsif ( -d "/home/lanforge/scripts/LANforge" ) { | ||||
|    use lib "/home/lanforge/scripts"; | ||||
|    use lib "/home/lanforge/scripts/LANforge"; | ||||
| } | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use LANforge::Endpoint; | ||||
| use LANforge::Port; | ||||
|   | ||||
| @@ -11,7 +11,12 @@ use strict; | ||||
| use warnings; | ||||
| use Carp; | ||||
| $| = 1;# Un-buffer output | ||||
|  | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use Getopt::Long; | ||||
| use LANforge::Endpoint; | ||||
| use LANforge::Port; | ||||
|   | ||||
| @@ -23,7 +23,11 @@ use diagnostics; | ||||
| # Un-buffer output | ||||
| $| = 1; | ||||
|  | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use LANforge::Endpoint; | ||||
| use LANforge::Port; | ||||
| use LANforge::Utils; | ||||
|   | ||||
| @@ -32,16 +32,11 @@ $| = 1; | ||||
| use Cwd qw(getcwd); | ||||
| my $cwd = getcwd(); | ||||
|  | ||||
|  # this is pedantic necessity for the following use statements | ||||
| if ( -f "LANforge/Endpoint.pm" ) { | ||||
|    use lib "./"; | ||||
| } | ||||
| elsif ( $cwd =~ q(.*LANforge-Server\scripts$)) { | ||||
|    use lib '/home/lanforge/scripts' | ||||
| } | ||||
| else { | ||||
|    use lib '/home/lanforge/scripts'; | ||||
| } | ||||
| # use lib prepends to @INC, so put lower priority first | ||||
| # This is before run-time, so cannot condition this with normal 'if' logic. | ||||
| use lib '/home/lanforge/scripts'; | ||||
| use lib "./"; | ||||
|  | ||||
| use LANforge::Endpoint; | ||||
| use LANforge::Port; | ||||
| use LANforge::Utils; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Ben Greear
					Ben Greear