Guest User

Untitled

a guest
Mar 12th, 2018
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.43 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use Cwd;
  3. my $script_root = getcwd;
  4. my $emacs_root = cd_emacs_root();
  5. my $cl_root = cd_cl_root();
  6.  
  7. my %operations = (
  8.  
  9. 'help' => 'help',
  10. 'emacs' => 'emacs',
  11. 'cdr' => 'cdr',
  12. 'cl' => 'cl',
  13. 'setup-imap' => 'setup_imap',
  14. 'setup-jabber' => 'setup_jabber',
  15. 'setup-maxima' => 'setup_maxima',
  16. 'setup-emms-mpd' => 'setup_emms_mpd',
  17. 'setup-lisp-environment' => 'setup_cl_environment',
  18. 'setup-perl' => 'setup_perl',
  19. 'setup-python' => 'setup_python',
  20. 'setup-audio-desktop' => 'setup_audio_desktop',
  21. 'setup-blog' => 'setup_blog',
  22. 'setup-erc' => 'setup_erc',
  23. 'setup-rss' => 'setup_rss'
  24. );
  25.  
  26.  
  27. my $op = $operations{$ARGV[0]};
  28. if ( scalar(@ARGV) == 0 ) {
  29. help();
  30. }
  31. else {
  32. &$op();
  33. }
  34.  
  35. sub help {
  36. print "cdr - the rest of emacs";
  37. print "\n\t" . $_ foreach keys %operations;
  38. print "\n";
  39. }
  40.  
  41. sub emacs {
  42. if ( $ARGV[1] eq 'recompile' ) {
  43. emacs_compile();
  44. }
  45. elsif ( $ARGV[1] eq 'update') {
  46. emacs_update();
  47. emacs_compile();
  48. }
  49. elsif ( $ARGV[1] eq 'updateonly') {
  50. emacs_update();
  51. }
  52.  
  53. else {
  54. chdir($emacs_root); chdir('../');
  55. if ( -e 'emacs') { system('rm -rf emacs') };
  56. system('cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/emacs co emacs');
  57. emacs_compile();
  58. cdr();
  59. }
  60. }
  61.  
  62. sub emacs_compile {
  63. chdir($emacs_root); chdir('../emacs');
  64. system('./configure --prefix=/opt/emacs --with-gtk --enable-font-backend --with-xft --with-freetype --with-xpm');
  65. system('make clean && make bootstrap');
  66. chdir('lisp');
  67. system('make recompile EMACS=../src/emacs');
  68. chdir('..');
  69. system('sudo make install');
  70. system('sudo make clean');
  71. }
  72.  
  73. sub emacs_update {
  74. chdir($emacs_root);
  75. if ( -e '../emacs' ) {
  76. chdir('../emacs');
  77. print "Updating emacs sources ...\n";
  78. system('cvs -nq update');
  79. }
  80. else {
  81. print "Cant find default emacs location. Specify location."
  82. }
  83. }
  84.  
  85. sub cdr {
  86. if ( -l "~/.emacs" ) {
  87. system("cp -a ~/.emacs ~/.emacs-backup");
  88. system("rm ~/.emacs");
  89. }
  90. else {
  91. system("mv ~/.emacs ~/.emacs-backup");
  92. }
  93. system("sudo rm /usr/local/bin/cdr");
  94. system("sudo ln -s '$script_root/cdr' /usr/local/bin/cdr");
  95. system("ln -s $emacs_root/init/de-emacs.el ~/.emacs");
  96. system("sudo ln -s '$script_root/cdr' /usr/local/bin/cdr");
  97. }
  98.  
  99. sub cdr_update {
  100. print "\nPulling git repository ...\n";
  101. }
  102.  
  103. sub cdr_configure {
  104.  
  105. }
  106.  
  107. sub cl {
  108. mkdir("../cl");
  109. if ( -e "../cl/clbuild") {
  110. print "\nclbuild already exists";
  111. }
  112. else {
  113. system("cp -av clbuild/ ../cl/");
  114. }
  115. if ( $ARGV[1] eq 'nosbcl' ) {
  116. print "Doing basic setup ..";
  117. }
  118. else {
  119. cl_sbcl();
  120. }
  121. chdir($emacs_root);
  122. system("ln -s $emacs_root/dotfiles/sbcl/sbclrc ~/.sbclrc");
  123. system("ln -s $emacs_root/dotfiles/sbcl/swank.lisp ~/.swank.lisp");
  124. print "\n Do a M-x swank, connect and happy hacking\n";
  125. }
  126.  
  127.  
  128.  
  129. sub cl_sbcl {
  130. chdir("$cl_root/clbuild");
  131. system('./clbuild buildsbcl');
  132. }
  133.  
  134.  
  135. sub setup_imap {
  136. my $imap = prompt("IMAP Server", "imap.gmail.com");
  137. my $port = prompt("Port(993)", "143");
  138. my $username = prompt("Username", "");
  139. my $password = prompt("Password", "");
  140. # write to ~/.authinfo
  141. }
  142.  
  143. sub setup_jabber {
  144.  
  145. }
  146.  
  147. sub setup_maxima {
  148.  
  149. }
  150.  
  151. sub setup_mpd {
  152.  
  153. }
  154.  
  155. sub cd_emacs_root {
  156. chdir($script_root);
  157. chdir("../");
  158. return getcwd;
  159. };
  160.  
  161. sub cd_cl_root {
  162. chdir($emacs_root);
  163. chdir("../cl");
  164. return getcwd;
  165. };
  166.  
  167.  
  168.  
  169.  
  170. sub prompt {
  171. local($prompt_string,$default_value) = @_;
  172. if ($defaultValue) {
  173. print $prompt_string, "[", $default_value, "]: ";
  174. } else {
  175. print $prompt_string, ": ";
  176. }
  177.  
  178. $| = 1;
  179. $_ = <STDIN>;
  180. chomp;
  181. if ("$default_value") {
  182. return $_ ? $_ : $default_value; # return $_ if it has a value
  183. } else {
  184. return $_;
  185. }
  186. }
Add Comment
Please, Sign In to add comment