File: install

package info (click to toggle)
fvwmconf 0.19-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 808 kB
  • ctags: 406
  • sloc: perl: 6,191; makefile: 47; sh: 2
file content (207 lines) | stat: -rwxr-xr-x 5,622 bytes parent folder | download | duplicates (2)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/usr/bin/perl
# run this script in directory ~/.fvwmconf
sub do_sys;

# YOU MAY WANT TO EDIT THE THREE LINES DESCRIBED BELOW
#--------------------------------------------------------------------------
# directory to put all fvwmconf support files (not user files)
# The file FvwmConf is the module which is called by fvwm2 .
# It goes in a different directory. The directory given here 
# contains support files which will be called by FvwmConf .
# The most common , best options are given first. Leave all but the
# one you choose commented out.
# The file FvwmConf.in will be edited to reflect this choice and 
# FvwmConf will be written.

#$SITE_LIB_B = '/usr/local/lib';
$SITE_LIB_B = '/usr/lib';

# you probably dont need to change this, you just change the above .
$SITE_LIB = $SITE_LIB_B . '/fvwmconf';
# $SITE_LIB = '/userdir/.fvwmconf';

#  directory for fvwm2 modules
# This is a directory where your fvwm2 modules  are commonly stored.
# This directory (with the /fvwm2 appended) must either be a standard
# path for fvmw2 modules or it must appear in the module path line in
# your .fvwm2rc file .
# The directory 'fvwm2' will be appended.
# uncomment the appropriate one, and comment out all the others,
# or add you own. The best, most common options are listed first.

#$SITE_MOD_D = '/usr/local/lib/X11';
$SITE_MOD_D = '/usr/lib/X11';


# Man page directory
#$MANINST = '/usr/local/man';
$MANINST = '/usr/man';

#---------------------------------------------------------------------------


# Don't change this. This says to look at the above directory under fvmw2
$SITE_MOD = $SITE_MOD_D .  '/fvwm2';
# $SITE_MOD = '/userdir/.fvwmconf';

#---- Don't need to change anything below here.



@PATHS = split /:/,$ENV{PATH};

# find where perl and fvwm2 are
sub find_programs {
    my @progs = (
		 'perl','fvwm2'
		 );	
    my($pr,$pa,$f) ;
    foreach $pr (@progs) {
	$f = 0;
	foreach $pa (@PATHS,perl_config_paths()) {
	    if (-e "$pa/$pr" ) {
		$WHERE{$pr} = "$pa/$pr";
		print "$pa/$pr\n";
		$f = 1;
		last;
	    }
	}
    }
}

# ripped off from perl configuration script
# This is overkill since they would not get this far without perl in path
sub perl_config_paths {
    my ($paths);
    $paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin';
    $paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin";
    $paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin";
    $paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin";
    $paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb";
    $paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin";
    return grep( -e, split( /\s+/,$paths));
}


find_programs();

# removed cp -rvf because flags don't work on Sun
$CP = 'cp -r ';

$com = $ARGV[0];

if ($com eq 'rc') {
    if ( -e "$ENV{HOME}/.fvwm2rc.hold" ) {
	die "You already have a .fvwm2rc.hold . You must save it to ".
	    "another name before running this script.";
    }
    if (-e "$ENV{HOME}/.fvwm2rc"  ) {
	system("/bin/mv -f ~/.fvwm2rc ~/.fvwm2rc.hold");
	die "Can't move .fvwm2rc" unless -e "$ENV{HOME}/.fvwm2rc.hold";
	print STDERR "Moved .fvwm2rc to .fvwm2rc.hold\n";
    }
    else { 
	print STDERR "No exisiting .fvwm2rc file found.\n";
    }
    
    open HAND, "<.fvwm2rc.example";
    
    @lines = <HAND>;
    close HAND;

    if (-e "$ENV{HOME}/.fvwm2rc") {die ".fvwm2rc is still there"};
    open OHAND, ">$ENV{HOME}/.fvwm2rc"  || die "Can't open .fvwm2rc for writing";
    foreach $one (@lines) {
	$one =~ s/USERHOME/$ENV{HOME}/;
	print OHAND $one;
    }
    close OHAND;
    print STDERR "New .fvwm2rc created at $ENV{HOME}/.fvwm2rc\n";
}
  
elsif ($com eq 'build' or not defined $com) {

    @binperl = ('changexpm', 'makegiftoxpm', 'mygiftoxpm');
#  Change a few lines in FvwmConf.in -> FvwmConf 
    foreach $outf ( 'FvwmConf' ,@binperl) {
	$inf= $outf . '.in';
	if ( -e $inf) {
            if (not open IHAND, "<$inf") {
		warn "Can't open $inf !";
		next;
	    }
	    print STDERR "Opened $inf\n";
	    @lines = <IHAND>;
	    close IHAND;
	    open OHAND, ">$outf" or die "Can't write to $outf";
	    foreach (@lines) {
		if (/^#INSTLIB/) {
		    print OHAND;
		    print OHAND "use lib '$SITE_LIB/lib';\n";
		}
		elsif (/^#VINSTLIB/ ) {
		       print OHAND;
		       print OHAND "\$instlibdir = '$SITE_LIB';";
		   }
		elsif (m,#!/usr/bin/perl,) {
		       if (exists $WHERE{perl} ) {
			   print OHAND "#!$WHERE{perl}\n" ;
		       }
		       else {
			   print OHAND;
		       }
		   }
		else {
		    print OHAND;
		}
	    }
	    close OHAND;  
	    print STDERR "Wrote $outf\n";
	    do_sys("chmod +x $outf");
	    
	}
	else {
	    die "I can't find FvwmConf.in ! \n It should be in the distribution";
	}
	
    }
    foreach (@binperl ) {
	do_sys "mv $_ bin/$_";
    }
}


if (not  defined $com) {
    do_sys("mkdir $SITE_LIB") unless -e $SITE_LIB;
    die "*** $SITE_LIB is not a directory" unless -d  $SITE_LIB;
    do_sys("mkdir $SITE_MOD_D") unless -e $SITE_MOD_D;
    do_sys("mkdir $SITE_MOD") unless -e $SITE_MOD;
    die "*** $SITE_MOD is not a directory" unless -d  $SITE_MOD;
    do_sys("$CP ./lib $SITE_LIB");
    do_sys("$CP ./bin $SITE_LIB");
    do_sys("$CP ./help $SITE_LIB");
    do_sys("$CP ./confimages $SITE_LIB");
    do_sys("$CP ./user $SITE_LIB");
    do_sys("$CP ./FvwmConf $SITE_MOD");
    do_sys "$CP ./man/man1/* $MANINST/man1";
    do_sys( "cd $MANINST/man1; ln -s FvwmConf.1x fvwmconf.1x");
}

#else {
#    print STDERR "Usage: 'install site' or 'install rc'\n";
#}

sub do_sys {
    my $string = shift;
    print STDERR "$string\n";
    system "$string";
}