Skip to content
Snippets Groups Projects
Commit eca323da authored by Armin Mackensen's avatar Armin Mackensen
Browse files

setuplspscripts now create seperate temp file in linux subsystem

parent 10ee9cef
No related branches found
No related tags found
No related merge requests found
...@@ -2,14 +2,17 @@ import os ...@@ -2,14 +2,17 @@ import os
import getpass import getpass
from os import path from os import path
from pathlib import Path from pathlib import Path
import tempfile
import shutil
gitRepo = "https://git.se.informatik.uni-kiel.de/oceandsl/cp-dsl-replication" gitRepo = "https://git.se.informatik.uni-kiel.de/oceandsl/cp-dsl-replication"
nameOfRelease = "org.oceandsl.configuration.ide-1.3.0-SNAPSHOT-ls.jar" nameOfRelease = "org.oceandsl.configuration.ide-1.3.0-SNAPSHOT-ls.jar"
pathToJar = "/home/" + getpass.getuser() + "/bin/" + nameOfRelease pathToJar = "/home/" + getpass.getuser() + "/bin/" + nameOfRelease
tempdir = tempfile.mkdtemp(prefix="EmacsLSPSupport")
#get the newest oceandsl lsp #get the newest oceandsl lsp
os.system("sudo apt update && sudo apt -y install emacs") os.system("sudo apt update && sudo apt -y install emacs")
Path(path.expanduser("~/temp")).mkdir(parents=True, exist_ok=True) Path(path.expanduser(str(tempdir))).mkdir(parents=True, exist_ok=True)
Path(path.expanduser("~/bin")).mkdir(parents=True, exist_ok=True) Path(path.expanduser("~/bin")).mkdir(parents=True, exist_ok=True)
os.system("wget -O " + "~/bin/" + nameOfRelease + " " + gitRepo + "/-/raw/master/" + nameOfRelease) os.system("wget -O " + "~/bin/" + nameOfRelease + " " + gitRepo + "/-/raw/master/" + nameOfRelease)
...@@ -19,7 +22,7 @@ data = Path(path.expanduser("~/bin/oceandsl-mode.el")).read_text().replace("/hom ...@@ -19,7 +22,7 @@ data = Path(path.expanduser("~/bin/oceandsl-mode.el")).read_text().replace("/hom
Path(path.expanduser("~/bin/oceandsl-mode.el")).write_text(data) Path(path.expanduser("~/bin/oceandsl-mode.el")).write_text(data)
#get latest emacs init file #get latest emacs init file
os.system("wget -O ~/temp/init.el " + gitRepo + "/-/raw/master/init.el") os.system("wget -O " + str(tempdir) + "/init.el " + gitRepo + "/-/raw/master/init.el")
initfileConf = False initfileConf = False
#check if the user already has an init emacs file #check if the user already has an init emacs file
...@@ -27,7 +30,7 @@ if(os.path.exists(path.expanduser("~/.emacs.d/init.el"))): ...@@ -27,7 +30,7 @@ if(os.path.exists(path.expanduser("~/.emacs.d/init.el"))):
initfileConf = True initfileConf = True
os.system("cp ~/.emacs.d/init.el ~/.emacs.d/init.el.backup") os.system("cp ~/.emacs.d/init.el ~/.emacs.d/init.el.backup")
oldData = Path(path.expanduser("~/.emacs.d/init.el")).read_text() oldData = Path(path.expanduser("~/.emacs.d/init.el")).read_text()
newData = Path(path.expanduser("~/temp/init.el")).read_text() newData = Path(path.expanduser(str(tempdir) + "/init.el")).read_text()
if(not(oldData == newData or oldData in newData)): if(not(oldData == newData or oldData in newData)):
oldData = Path(path.expanduser("~/.emacs.d/init.el")).write_text(oldData + newData) oldData = Path(path.expanduser("~/.emacs.d/init.el")).write_text(oldData + newData)
...@@ -36,16 +39,16 @@ if(os.path.exists(path.expanduser("~/.emacs"))): ...@@ -36,16 +39,16 @@ if(os.path.exists(path.expanduser("~/.emacs"))):
initfileConf = True initfileConf = True
os.system("cp ~/.emacs ~/.emacs.backup") os.system("cp ~/.emacs ~/.emacs.backup")
oldData = Path(path.expanduser("~/.emacs")).read_text() oldData = Path(path.expanduser("~/.emacs")).read_text()
newData = Path(path.expanduser("~/temp/init.el")).read_text() newData = Path(path.expanduser(str(tempdir) + "/init.el")).read_text()
if(not(oldData == newData or oldData in newData)): if(not(oldData == newData or oldData in newData)):
oldData = Path(path.expanduser("~/.emacs")).write_text(oldData + newData) oldData = Path(path.expanduser("~/.emacs")).write_text(oldData + newData)
if(not initfileConf): if(not initfileConf):
Path(path.expanduser("~/.emacs.d")).mkdir(parents=True, exist_ok=True) Path(path.expanduser("~/.emacs.d")).mkdir(parents=True, exist_ok=True)
os.system("mv ~/temp/init.el ~/.emacs.d/init.el") os.system("mv " + str(tempdir) + "/init.el ~/.emacs.d/init.el")
os.system("emacs -nw") os.system("emacs -nw")
os.system("rm ~/temp -r") shutil.rmtree(tempdir)
...@@ -113,6 +113,8 @@ operating system may differ. ...@@ -113,6 +113,8 @@ operating system may differ.
### Installation ### Installation
We provide an Python-Script for an easy installation. Just download the `VimSetupScript.py` and run it with `python3 VimSetupScript`. We provide an Python-Script for an easy installation. Just download the `VimSetupScript.py` and run it with `python3 VimSetupScript`.
Be aware, that the script edit your `.vim` and `.vimrc` files. If they already exist the script will make a **backup** and tries to merge the file with the needed lines for LSP support.
Alternative manual installation: Alternative manual installation:
- Install the Vim LSP plugin from `https://github.com/prabirshrestha/vim-lsp` - Install the Vim LSP plugin from `https://github.com/prabirshrestha/vim-lsp`
...@@ -161,6 +163,8 @@ operating system may differ. ...@@ -161,6 +163,8 @@ operating system may differ.
We provide an Python-Script for an easy installation. Just download the `EmacsSetupScript.py` and run it with `python3 EmacsSetupScript`. We provide an Python-Script for an easy installation. Just download the `EmacsSetupScript.py` and run it with `python3 EmacsSetupScript`.
Be aware, that the script edit your `.emacs` and `.emacs.d/init.el` files. If they already exist the script will make a **backup** and tries to merge the file with the needed lines for LSP support.
Alternative manual installation: Alternative manual installation:
- Install `Emacs` with e.g. `sudo apt update && sudo apt install emacs` - Install `Emacs` with e.g. `sudo apt update && sudo apt install emacs`
- Run `Emacs` for the first time, so that it can create some standart folder, etc. - Run `Emacs` for the first time, so that it can create some standart folder, etc.
...@@ -375,4 +379,3 @@ steps are identical for the MITgcm setup. Differences will be noted below. ...@@ -375,4 +379,3 @@ steps are identical for the MITgcm setup. Differences will be noted below.
MITgcm can be imported in the same way. However, the MITgcm project contains MITgcm can be imported in the same way. However, the MITgcm project contains
multiple oconf files. The translate in different subdirectories under src-gen. multiple oconf files. The translate in different subdirectories under src-gen.
...@@ -2,30 +2,32 @@ import os ...@@ -2,30 +2,32 @@ import os
import getpass import getpass
from os import path from os import path
from pathlib import Path from pathlib import Path
import tempfile
import shutil
gitRepo = "https://git.se.informatik.uni-kiel.de/oceandsl/cp-dsl-replication" gitRepo = "https://git.se.informatik.uni-kiel.de/oceandsl/cp-dsl-replication"
nameOfRelease = "org.oceandsl.configuration.ide-1.3.0-SNAPSHOT-ls.jar" nameOfRelease = "org.oceandsl.configuration.ide-1.3.0-SNAPSHOT-ls.jar"
pathToJar = "/home/" + getpass.getuser() + "/bin/" + nameOfRelease pathToJar = "/home/" + getpass.getuser() + "/bin/" + nameOfRelease
tempdir = tempfile.mkdtemp(prefix="VimLSPSupport")
os.system("sudo apt update && sudo apt -y install vim") os.system("sudo apt update && sudo apt -y install vim")
Path(path.expanduser("~/temp")).mkdir(parents=True, exist_ok=True) Path(path.expanduser(str(tempdir))).mkdir(parents=True, exist_ok=True)
#print(path.expanduser("~/bin"))
Path(path.expanduser("~/bin")).mkdir(parents=True, exist_ok=True) Path(path.expanduser("~/bin")).mkdir(parents=True, exist_ok=True)
os.system("wget -O " + "~/bin/" + nameOfRelease + " " + gitRepo + "/-/raw/master/" + nameOfRelease) os.system("wget -O " + "~/bin/" + nameOfRelease + " " + gitRepo + "/-/raw/master/" + nameOfRelease)
os.system("wget -O ~/temp/example.vimrc " + gitRepo + "/-/raw/master/example.vimrc") os.system("wget -O " + str(tempdir) + "/example.vimrc " + gitRepo + "/-/raw/master/example.vimrc")
#if .vimrc already exists we either need to merge or it already exists then we don't need to do anything #if .vimrc already exists we either need to merge or it already exists then we don't need to do anything
if(os.path.exists(path.expanduser("~/.vimrc"))): if(os.path.exists(path.expanduser("~/.vimrc"))):
newData = Path(path.expanduser("~/temp/example.vimrc")).read_text().replace(nameOfRelease, pathToJar) newData = Path(path.expanduser(str(tempdir) + "/example.vimrc")).read_text().replace(nameOfRelease, pathToJar)
oldData = Path(path.expanduser("~/.vimrc")).read_text() oldData = Path(path.expanduser("~/.vimrc")).read_text()
os.system("cp ~/.vimrc ~/.vimrc.backup") os.system("cp ~/.vimrc ~/.vimrc.backup")
if(not(newData == oldData or newData in oldData)): if(not(newData == oldData or newData in oldData)):
os.system("sudo chown " + getpass.getuser() + " ~/.vimrc") os.system("sudo chown " + getpass.getuser() + " ~/.vimrc")
Path(path.expanduser("~/.vimrc")).write_text(oldData + newData) Path(path.expanduser("~/.vimrc")).write_text(oldData + newData)
else: else:
os.system("mv ~/temp/example.vimrc ~/.vimrc") os.system("mv " + str(tempdir) + "/example.vimrc ~/.vimrc")
os.system("sudo chown " + getpass.getuser() + " ~/.vimrc") os.system("sudo chown " + getpass.getuser() + " ~/.vimrc")
data = Path(path.expanduser("~/.vimrc")).read_text().replace(nameOfRelease, pathToJar) data = Path(path.expanduser("~/.vimrc")).read_text().replace(nameOfRelease, pathToJar)
Path(path.expanduser("~/.vimrc")).write_text(data) Path(path.expanduser("~/.vimrc")).write_text(data)
...@@ -36,14 +38,14 @@ Path(path.expanduser("~/.vim")).mkdir(parents=True, exist_ok=True) ...@@ -36,14 +38,14 @@ Path(path.expanduser("~/.vim")).mkdir(parents=True, exist_ok=True)
os.system("vim +slient +PlugInstall +qall") os.system("vim +slient +PlugInstall +qall")
os.system("wget -O ~/temp/filetype.vim " + gitRepo + "/-/raw/master/filetype.vim") os.system("wget -O " + str(tempdir) + "/filetype.vim " + gitRepo + "/-/raw/master/filetype.vim")
if(os.path.exists(path.expanduser("~/.vim/filetype.vim"))): if(os.path.exists(path.expanduser("~/.vim/filetype.vim"))):
newData = Path(path.expanduser("~/temp/filetype.vim")).read_text() newData = Path(path.expanduser(str(tempdir) + "/filetype.vim")).read_text()
oldData = Path(path.expanduser("~/.vim/filetype.vim")).read_text() oldData = Path(path.expanduser("~/.vim/filetype.vim")).read_text()
os.system("cp ~/.vim/filetype.vim ~/.vim/filetype.vim.backup") os.system("cp ~/.vim/filetype.vim ~/.vim/filetype.vim.backup")
if(not(newData == oldData or newData in oldData)): if(not(newData == oldData or newData in oldData)):
Path(path.expanduser("~/.vim/filetype.vim")).write_text(oldData + newData) Path(path.expanduser("~/.vim/filetype.vim")).write_text(oldData + newData)
else: else:
os.system("mv ~/temp/filetype.vim ~/.vim/filetype.vim") os.system("mv " + str(tempdir) + "/filetype.vim ~/.vim/filetype.vim")
os.system("rm ~/temp -r") shutil.rmtree(tempdir)
\ No newline at end of file \ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment