File: sylpheed-switcher

package info (click to toggle)
sylpheed-claws 1.0.5-5.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 20,684 kB
  • ctags: 14,192
  • sloc: ansic: 128,552; sh: 9,615; makefile: 1,741; yacc: 1,740; perl: 1,664; python: 212; lex: 200; sed: 16
file content (148 lines) | stat: -rwxr-xr-x 5,403 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl

#  * Copyright  2001 Paul Mangan <claws@thewildbeast.co.uk>
#  *
#  * This file is free software; you can redistribute it and/or modify it
#  * under the terms of the GNU General Public License as published by
#  * the Free Software Foundation; either version 2 of the License, or
#  * (at your option) any later version.
#  *
#  * This program is distributed in the hope that it will be useful, but
#  * WITHOUT ANY WARRANTY; without even the implied warranty of
#  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  * General Public License for more details.
#  *
#  * You should have received a copy of the GNU General Public License
#  * along with this program; if not, write to the Free Software
#  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#  *

#	Script Name: The Nasnas
#	Script Version: 0.4

######################################################
######################################################
###						   ###
###  FOR USAGE INSTRUCTIONS RUN THIS SCRIPT WITH   ###
###  THE FOLLOWING OPTION:			   ###
###						   ###
###  ./sylpheed-switcher --help		     	   ###
###						   ###
######################################################
######################################################

use File::Path;
use Getopt::Long;

my $sylpheed    = 0;
my $claws       = 0;
my $sylphpath   = '';
my $clawspath   = '';
my $debug	= 0;
my $YouWantHelp = 0;

GetOptions("main"         => \$sylpheed,
           "claws"        => \$claws,
	   "main-path=s"  => \$sylphpath,
	   "claws-path=s" => \$clawspath,
           "debug"	  => \$debug,
	   "help"         => \$YouWantHelp);

chdir; ## use $HOME for the working directory

unless (-e ".sylpheed") {  ## check for the .sylpheed directory
	print "Your '.sylpheed' directory is missing. This probably means that ";
        print "you have never run sylpheed before.\n";
        print "Before running sylpheed-switcher run sylpheed normally at least once.\n";
        exit;
}

open (SYLSWIT, "<.sylpheed-switcher"); ## read the config file
	@conf_file = <SYLSWIT>;
close SYLSWIT;

if ($sylphpath && $clawspath) {  ## this is the initial set-up part
## write the config file
	$PATH_INFO = "$clawspath\n$sylphpath";
	open (CONFFILE, ">.sylpheed-switcher");
	print CONFFILE $PATH_INFO;
	close CONFFILE;
## it appears that you'd run this script before, but the config file was missing
	$DIR_CHECK = opendir(CHECKDIR, ".sylpheed-claws");
	closedir(CHECKDIR);
	if ($DIR_CHECK == 1) {
		print "\nNow you can run either the main branch or the claws\n";
		print "branch by using one of the following options:\n\n";
		print "./sylpheed-switcher --main\n./sylpheed-switcher --claws\n\n";
		exit;
	}
## copy the directory tree
	system "cp -R .sylpheed .sylpheed-main";
	system "cp -R .sylpheed .sylpheed-claws";
## when setting-up is done print a little message
	print "\nNow you can run either the main branch or the claws\n";
	print "branch by using one of the following options:\n\n";
	print "./sylpheed-switcher --main\n./sylpheed-switcher --claws\n\n";
	exit;
}
## the --help option stuff
if ($YouWantHelp) {
	print "\n The SYLPHEED<->CLAWS SWITCHER\n\n";
	print "If you are running this script for the first time you will need \n";
	print "to set up the configuration. Here is an example, adjust the paths\n";
	print "to suit your set-up, but remember you need the full path with the\n";
	print "executable included:\n";
	print "./sylpheed-switcher --main-path=/usr/local/bin/sylpheed --claws-path=/usr/bin/sylpheed\n\n";
	print "When you have done the initial set-up, you run either the main branch\n";
	print "or the claws branch by using one of the following switches:\n\n";
	print "./sylpheed-switcher --main\n./sylpheed-switcher --claws\n\n";
        print "Add --debug to run sylpheed in debug mode\n\n";
	exit;
}
## if the config file doesn't exist...
if (!@conf_file) {
	print "Use the following set-up options first, or --help for more info:\n";
	print "--claws-path=PATH   # path to (and including) the claws sylpheed executable\n";
	print "--main-path=PATH    # path to (and including) the main sylpheed executable\n";
	exit;
}
## check that the chosen execuatble exists
## get rid of the old symbolic link, make a new one, and run the required executable
if ($claws) {
        chomp $conf_file[0];
	unless (-e $conf_file[0]) {
		print "\n$conf_file[0] does not exist\n\n";
		exit;
	}
	rmtree(".sylpheed");
	symlink(".sylpheed-claws",".sylpheed");
        if ($debug eq 1) {
		exec "$conf_file[0] --debug";
        } else {
        	exec "$conf_file[0]";
        }
	exit;
} elsif ($sylpheed) {
        chomp $conf_file[1];
	unless (-e $conf_file[1]) {
		print "\n$conf_file[1] does not exist\n\n";
		exit;
	}
	rmtree(".sylpheed");
	symlink(".sylpheed-main",".sylpheed");
        if ($debug eq 1) {
        	exec "$conf_file[1] --debug";
        } else {
		exec "$conf_file[1]";
        }
	exit;
} elsif (!$claws && !$sylpheed && @conf_file) {  		## you've got the config file but haven't said
	print "\nUse one of the following switches:\n";		## which version you want to run
	print " --main		# to run sylpheed main\n";
	print " --claws	# to run sylpheed claws\n";
	print " --help		# to view the help message\n";
        print "Optionally, you can also use:\n";
        print " --debug 	# to run in debug mode [optional]\n\n";
	exit;
}
###############################