mirror of https://github.com/EdgeVPNio/tools.git
Add simple sync
parent
3ec85f558a
commit
c6a736a59d
7
evt
7
evt
|
@ -20,16 +20,11 @@
|
|||
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
#SOFTWARE.
|
||||
|
||||
PY=python3.8
|
||||
case $1 in
|
||||
sync)
|
||||
source venv/bin/activate
|
||||
$PY ./scripts/Sync.py
|
||||
;;
|
||||
setup)
|
||||
./setup-evt.sh
|
||||
;;
|
||||
*)
|
||||
./evio-tools.sh "$@"
|
||||
./scripts/evio-tools-v20.7.2 "$@"
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
import stat
|
||||
|
||||
import git
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('../')
|
||||
from scripts.tool_config import MAPPING as mapping
|
||||
from os import path
|
||||
|
||||
|
||||
class Link:
|
||||
sym_link = "./ev-tools.sh"
|
||||
def __init__(self):
|
||||
self.evio_repo = None
|
||||
self.tools_repo = None
|
||||
self.dir_path = None
|
||||
self.dir_path_tools = None
|
||||
|
||||
@staticmethod
|
||||
def sync_branch(self):
|
||||
"""
|
||||
Syncing the correct script with EVT script if there is no version given by user.
|
||||
"""
|
||||
self.get_repository()
|
||||
try:
|
||||
if mapping.get(str(self.evio_repo.active_branch)) is not None and \
|
||||
mapping.get(str(self.evio_repo.active_branch)).get(
|
||||
str(self.evio_repo.active_branch.commit)) is not None:
|
||||
file_to_link = mapping[str(self.evio_repo.active_branch)][""]
|
||||
elif mapping[str(self.evio_repo.active_branch)] is not None:
|
||||
file_to_link = mapping[str(self.evio_repo.active_branch)]["default"]
|
||||
except KeyError:
|
||||
file_to_link = mapping["default"]
|
||||
if path.exists(Link.sym_link):
|
||||
os.remove(Link.sym_link)
|
||||
os.symlink("./scripts/" + file_to_link, Link.sym_link)
|
||||
os.chmod("./scripts/" + file_to_link, 0o775)
|
||||
|
||||
def sync(self, version):
|
||||
"""
|
||||
Syncing the correct script with EVT script if there is a version given by user.
|
||||
"""
|
||||
if version is None:
|
||||
self.sync_branch(self)
|
||||
else:
|
||||
self.get_repository()
|
||||
if mapping.get(version).get(str(self.evio_repo.tags[0].commit)) is not None:
|
||||
file_to_link = mapping[str(self.evio_repo.active_branch)][self.evio_repo.tags[0].commit]
|
||||
else:
|
||||
file_to_link = mapping[version]["default"]
|
||||
|
||||
def get_repository(self):
|
||||
"""
|
||||
Get the active branch name of the Evio and Tools repo.
|
||||
"""
|
||||
# present_dir = os.getcwd()[0:3]
|
||||
# for root, subdirs, files in os.walk(present_dir):
|
||||
# for d in subdirs:
|
||||
# if d == "evio":
|
||||
# self.dir_path = os.path.join(root, d)
|
||||
pwd = os.getcwd()[0:]
|
||||
os.chdir(os.getenv("HOME") + "/workspace/EdgeVPNio")
|
||||
if path.exists("evio"):
|
||||
self.dir_path = os.getcwd()[0:]
|
||||
else:
|
||||
self.dir_path = os.getcwd()[0:]
|
||||
git.Git(self.dir_path).clone("https://github.com/EdgeVPNio/evio.git")
|
||||
|
||||
self.evio_repo = git.Repo(str(self.dir_path) + "/evio")
|
||||
#print("Evio Branch name:" + str(self.evio_repo.active_branch))
|
||||
self.dir_path_tools = "~/workspace/EdgeVPNio/tools"
|
||||
self.tools_repo = git.Repo(self.dir_path_tools)
|
||||
#print("Tools Branch name:" + str(self.tools_repo.active_branch))
|
||||
os.chdir(str(pwd))
|
||||
|
||||
def main(self):
|
||||
self.sync("20.7.2")
|
||||
|
||||
if __name__ == "__main__":
|
||||
link = Link()
|
||||
link.main()
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
# EVIO_REPO=https://github.com/EdgeVPNio/evio.git
|
||||
# EXT_REPO=https://github.com/EdgeVPNio/external.git
|
||||
# TOOLS_REPO=https://github.com/EdgeVPNio/tools.git
|
||||
# PORTAL_REPO=https://github.com/EdgeVPNio/portal.git
|
||||
EVIO_REPO=https://github.com/EdgeVPNio/evio.git
|
||||
EXT_REPO=https://github.com/EdgeVPNio/external.git
|
||||
TOOLS_REPO=https://github.com/EdgeVPNio/tools.git
|
||||
PORTAL_REPO=https://github.com/EdgeVPNio/portal.git
|
||||
PY=python3.8
|
||||
WorkspaceRoot=$(readlink -e ../..)
|
||||
|
||||
|
@ -34,6 +34,26 @@ function display_env
|
|||
echo TOOLS_DIR=$TOOLS_DIR
|
||||
}
|
||||
|
||||
function update_repo
|
||||
{
|
||||
rv=$(git -C $1 rev-parse --is-inside-work-tree)
|
||||
if [ $rv == "true" -o $rv == "false" ]; then
|
||||
git -C $1 pull $2
|
||||
else
|
||||
mkdir -p $1
|
||||
git -C $1 clone $2
|
||||
fi
|
||||
}
|
||||
|
||||
function sync_repos
|
||||
{
|
||||
update_repo $EVIO_DIR $EVIO_REPO
|
||||
update_repo $EXT_DIR $EXT_REPO
|
||||
update_repo $TOOLS_DIR $TOOLS_REPO
|
||||
update_repo $PORTAL_DIR $PORTAL_REPO
|
||||
|
||||
}
|
||||
|
||||
function make_debpak
|
||||
{
|
||||
wd=$(pwd)
|
||||
|
@ -232,7 +252,7 @@ function do_build_debian_arm_release
|
|||
source venv/bin/activate
|
||||
case $1 in
|
||||
sync)
|
||||
$PY ./scripts/Sync.py
|
||||
sync_repos
|
||||
;;
|
||||
testbed)
|
||||
install_testbed_deps
|
||||
|
|
|
@ -1,15 +1,6 @@
|
|||
MAPPING = {
|
||||
"master": {
|
||||
"default": "evio-tools-v20.7.2"
|
||||
},
|
||||
"20.7.2": {
|
||||
"default": "evio-tools-v20.7.2"
|
||||
},
|
||||
"default": "evio-tools-v20.7.2"
|
||||
}
|
||||
|
||||
MAJOR_VER = 20
|
||||
MINOR_VER = 11
|
||||
REVISION_VER = 0
|
||||
CONTROL_VER = 6
|
||||
OFFICIAL = False
|
||||
|
||||
|
|
Loading…
Reference in New Issue