Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
1d70339f72 | |||
e3a8d32557 | |||
e1a8280e01 | |||
a605da450f | |||
94f79962c4 | |||
9086c073a1 | |||
d362d47889 | |||
f90e5bc535 | |||
badbafc4bf | |||
e916efde7b | |||
11e39de3bd |
45
README.rst
45
README.rst
@@ -3,6 +3,12 @@ Lutin
|
||||
|
||||
`island` is a generic source downloader and syncronizer is a FREE software tool.
|
||||
|
||||
It is compatible with basic format of repo-git manifest. This project is created to be easyest to read with simple interface
|
||||
(no internal git usage, but user level git usage) The main point to create the "fork" is the non-support of repo of relativity
|
||||
in submodule of git (submodule reference with ../xxx.git) This point is really important when you want to have a rellocable
|
||||
manifest and project with submodule. The simpl eexample is the atria-soft / generic-library / musicdsp that are availlable on
|
||||
github, gitlab, bitbucket and personal server.
|
||||
|
||||
|
||||
.. image:: https://badge.fury.io/py/island.png
|
||||
:target: https://pypi.python.org/pypi/island
|
||||
@@ -61,6 +67,45 @@ Install pip on MacOs:
|
||||
|
||||
sudo easy_install pip
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Select a manifest:
|
||||
|
||||
island init http://github.com/atria-soft/manifest.git
|
||||
|
||||
Download and synchronize the sources:
|
||||
|
||||
island sync
|
||||
|
||||
Select all branch availlable in the worktree: (checkout origin/dev in dev branch and track it, do nothing if the branch does not exist)
|
||||
|
||||
island checkout dev
|
||||
|
||||
Show the status of the workspace
|
||||
|
||||
island status
|
||||
|
||||
TODO list
|
||||
---------
|
||||
|
||||
- When sync checkout the new manifest
|
||||
- status: show how many time late we are on the branch
|
||||
- sync: filter the apply of this cmd
|
||||
- create snapshot
|
||||
- use a snapshot
|
||||
- commit all change in a single commit name and date
|
||||
- push all change in the origin branch
|
||||
- stash/unstash all change
|
||||
- permit to set the pasword when requested by git
|
||||
- sync: show download progress
|
||||
- support single project mirror
|
||||
- support submodule mirror
|
||||
- support project upstream
|
||||
- support submodule add upstream
|
||||
- push modilfication in all late mirorr (force mode optionnal) ==> for automatic server synchronisation in 4 lines
|
||||
- a good documation of the format and the usage
|
||||
- parallele download / sync / push ...
|
||||
|
||||
License (MPL v2.0)
|
||||
---------------------
|
||||
|
@@ -220,8 +220,8 @@ if action_to_do not in list_actions:
|
||||
|
||||
# todo : Remove this
|
||||
if action_to_do != "init" \
|
||||
and os.path.exists("." + env.get_system_base_name()) == False:
|
||||
debug.error("Can not execute a island cmd if we have not initialize a config: '" + str("." + env.get_system_base_name()) + "'")
|
||||
and os.path.exists(env.get_island_path()) == False:
|
||||
debug.error("Can not execute a island cmd if we have not initialize a config: '" + str("." + env.get_system_base_name()) + "' in upper 6 parent path")
|
||||
exit(-1)
|
||||
|
||||
|
||||
|
153
island/actions/islandAction_checkout.py
Normal file
153
island/actions/islandAction_checkout.py
Normal file
@@ -0,0 +1,153 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
|
||||
from island import debug
|
||||
from island import tools
|
||||
from island import env
|
||||
from island import config
|
||||
from island import multiprocess
|
||||
from island import manifest
|
||||
import os
|
||||
|
||||
|
||||
def help():
|
||||
return "plop"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def execute(arguments):
|
||||
debug.info("execute:")
|
||||
for elem in arguments:
|
||||
debug.info(" '" + str(elem.get_arg()) + "'")
|
||||
if len(arguments) != 1:
|
||||
debug.error("checkout: missing argument to select the new branch ...")
|
||||
branch_to_checkout = ""
|
||||
for elem in arguments:
|
||||
if elem.get_option_name() == "":
|
||||
if branch_to_checkout != "":
|
||||
debug.error("checkout branch already set : '" + branch_to_checkout + "' !!! '" + elem.get_arg() + "'")
|
||||
branch_to_checkout = elem.get_arg()
|
||||
else:
|
||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||
|
||||
# check if .XXX exist (create it if needed)
|
||||
if os.path.exists(env.get_island_path()) == False \
|
||||
or os.path.exists(env.get_island_path_config()) == False \
|
||||
or os.path.exists(env.get_island_path_manifest()) == False:
|
||||
debug.error("System already init have an error: missing data: '" + str(env.get_island_path()) + "'")
|
||||
|
||||
configuration = config.Config()
|
||||
|
||||
# update the local configuration file:
|
||||
configuration.set_branch(branch_to_checkout)
|
||||
configuration.store()
|
||||
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == False:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
debug.info("checkout of: " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
debug.verbose("checkout : " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name))
|
||||
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == False:
|
||||
debug.warning("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> repository does not exist ...")
|
||||
continue
|
||||
|
||||
# check if the repository is modify
|
||||
cmd = "git diff --quiet"
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret_diff = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
# get local branch
|
||||
cmd = "git branch"
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret_branch = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
|
||||
# get tracking branch
|
||||
cmd = "git rev-parse --abbrev-ref --symbolic-full-name @{u}"
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret_track = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
|
||||
is_modify = True
|
||||
if ret_diff[0] == 0:
|
||||
is_modify = False
|
||||
|
||||
if is_modify == True:
|
||||
debug.warning("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> modify data can not checkout new branch")
|
||||
continue
|
||||
|
||||
list_branch = ret_branch[1].split('\n')
|
||||
list_branch2 = []
|
||||
select_branch = ""
|
||||
for elem_branch in list_branch:
|
||||
list_branch2.append(elem_branch[2:])
|
||||
if elem_branch[:2] == "* ":
|
||||
select_branch = elem_branch[2:]
|
||||
|
||||
|
||||
# check if we are on the good branch:
|
||||
if branch_to_checkout == select_branch:
|
||||
debug.info("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> No change already on good branch")
|
||||
continue
|
||||
|
||||
# check if we have already checkout the branch before
|
||||
debug.verbose(" check : " + branch_to_checkout + " in " + str(list_branch2))
|
||||
if branch_to_checkout in list_branch2:
|
||||
cmd = "git checkout " + branch_to_checkout
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
if ret[0] != 0 \
|
||||
and ret[1] != "" \
|
||||
and ret != False:
|
||||
debug.info("'" + str(ret) + "'")
|
||||
debug.error("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> Can not checkout to the correct branch")
|
||||
continue
|
||||
debug.info("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> switch branch")
|
||||
# TODO : Check the number of commit to the origin/XXX branch ....
|
||||
continue
|
||||
|
||||
# Check if the remote branch exist ...
|
||||
cmd = "git branch -a"
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret_branch_all = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
list_branch_all = ret_branch_all[1].split('\n')
|
||||
exist = False
|
||||
for elem_branch in list_branch_all:
|
||||
debug.verbose(" check : '" + elem_branch + "' == '" + " remotes/" + elem.select_remote["name"] + "/" + branch_to_checkout + "'")
|
||||
if elem_branch == " remotes/" + elem.select_remote["name"] + "/" + branch_to_checkout:
|
||||
exist = True
|
||||
debug.info(" ==> find ...")
|
||||
break
|
||||
if exist == False:
|
||||
debug.info("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> NO remote branch")
|
||||
continue
|
||||
|
||||
# checkout the new branch:
|
||||
cmd = "git checkout --quiet " + elem.select_remote["name"] + "/" + branch_to_checkout + " -b " + branch_to_checkout
|
||||
# + " --track " + elem.select_remote["name"] + "/" + branch_to_checkout
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
if ret[1] != "" \
|
||||
and ret != False:
|
||||
debug.info("'" + str(ret) + "'")
|
||||
debug.error("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> Can not checkout to the correct branch")
|
||||
continue
|
||||
debug.info("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> create new branch")
|
||||
continue
|
||||
|
||||
|
||||
|
75
island/actions/islandAction_fetch.py
Normal file
75
island/actions/islandAction_fetch.py
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
|
||||
from island import debug
|
||||
from island import tools
|
||||
from island import env
|
||||
from island import config
|
||||
from island import multiprocess
|
||||
from island import manifest
|
||||
import os
|
||||
|
||||
|
||||
def help():
|
||||
return "plop"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def execute(arguments):
|
||||
debug.info("execute:")
|
||||
for elem in arguments:
|
||||
debug.info(" '" + str(elem.get_arg()) + "'")
|
||||
if len(arguments) != 0:
|
||||
debug.error("Sync have not parameter")
|
||||
|
||||
# check if .XXX exist (create it if needed)
|
||||
if os.path.exists(env.get_island_path()) == False \
|
||||
or os.path.exists(env.get_island_path_config()) == False \
|
||||
or os.path.exists(env.get_island_path_manifest()) == False:
|
||||
debug.error("System already init have an error: missing data: '" + str(env.get_island_path()) + "'")
|
||||
|
||||
|
||||
configuration = config.Config()
|
||||
|
||||
debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
|
||||
# update manifest
|
||||
cmd = "git fetch --all"
|
||||
multiprocess.run_command_direct(cmd, cwd=env.get_island_path_manifest())
|
||||
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == False:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
debug.info("fetch : " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
debug.info("fetch : " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name))
|
||||
#debug.debug("elem : " + str(elem))
|
||||
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == False:
|
||||
debug.error("can not fetch project that not exist")
|
||||
continue
|
||||
|
||||
if os.path.exists(os.path.join(git_repo_path,".git")) == False:
|
||||
# path already exist but it is not used to as a git repo ==> this is an error
|
||||
debug.error("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart")
|
||||
|
||||
# simply update the repository ...
|
||||
debug.verbose("Fetching project: ")
|
||||
# fetch the repository
|
||||
cmd = "git fetch " + elem.select_remote["name"]
|
||||
debug.verbose("execute : " + cmd)
|
||||
multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||
|
@@ -11,6 +11,7 @@
|
||||
from island import debug
|
||||
from island import tools
|
||||
from island import env
|
||||
from island import config
|
||||
from island import multiprocess
|
||||
import os
|
||||
|
||||
@@ -57,8 +58,11 @@ def execute(arguments):
|
||||
# check if the git of the manifest if availlable
|
||||
|
||||
# create the file configuration:
|
||||
data = "repo=" + address_manifest + "\nbranch=" + branch + "\nfile=" + manifest_name
|
||||
tools.file_write_data(env.get_island_path_config(), data)
|
||||
conf = config.Config()
|
||||
conf.set_manifest(address_manifest)
|
||||
conf.set_branch(branch)
|
||||
conf.set_manifest_name(manifest_name)
|
||||
conf.store()
|
||||
|
||||
#clone the manifest repository
|
||||
cmd = "git clone " + address_manifest + " --branch " + branch + " " + env.get_island_path_manifest()
|
||||
|
@@ -12,6 +12,7 @@ from island import debug
|
||||
from island import tools
|
||||
from island import env
|
||||
from island import multiprocess
|
||||
from island import config
|
||||
from island import manifest
|
||||
import os
|
||||
|
||||
@@ -28,7 +29,7 @@ def execute(arguments):
|
||||
for elem in arguments:
|
||||
debug.info(" '" + str(elem.get_arg()) + "'")
|
||||
if len(arguments) != 0:
|
||||
debug.error("Sync have not parameter")
|
||||
debug.error("status have not parameter")
|
||||
|
||||
# check if .XXX exist (create it if needed)
|
||||
if os.path.exists(env.get_island_path()) == False \
|
||||
@@ -36,9 +37,9 @@ def execute(arguments):
|
||||
or os.path.exists(env.get_island_path_manifest()) == False:
|
||||
debug.error("System already init have an error: missing data: '" + str(env.get_island_path()) + "'")
|
||||
|
||||
configuration = manifest.load_config()
|
||||
configuration = config.Config()
|
||||
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration["file"])
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == False:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
@@ -90,8 +91,31 @@ def execute(arguments):
|
||||
|
||||
debug.verbose("select branch = '" + select_branch + "' is modify : " + str(is_modify) + " track: '" + str(ret_track[1]) + "'")
|
||||
|
||||
cmd = "git rev-list " + select_branch
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret_current_branch_sha1 = multiprocess.run_command(cmd, cwd=git_repo_path)[1].split('\n')
|
||||
cmd = "git rev-list " + ret_track[1]
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret_track_branch_sha1 = multiprocess.run_command(cmd, cwd=git_repo_path)[1].split('\n')
|
||||
# remove all identical sha1 ==> not needed for this
|
||||
in_forward = 0
|
||||
for elem_sha1 in ret_current_branch_sha1:
|
||||
if elem_sha1 not in ret_track_branch_sha1:
|
||||
in_forward += 1
|
||||
in_behind = 0
|
||||
for elem_sha1 in ret_track_branch_sha1:
|
||||
if elem_sha1 not in ret_current_branch_sha1:
|
||||
in_behind += 1
|
||||
|
||||
behind_forward_comment = ""
|
||||
if in_forward != 0:
|
||||
behind_forward_comment += "forward=" + str(in_forward)
|
||||
if in_behind != 0:
|
||||
behind_forward_comment += "behind=" + str(in_behind)
|
||||
if behind_forward_comment != "":
|
||||
behind_forward_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t[" + behind_forward_comment + "]"
|
||||
#debug.info("" + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + ret_track[1] + " -> " + elem.select_remote["name"] + "/" + elem.branch + ")")
|
||||
debug.info("" + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + ret_track[1] + ")")
|
||||
debug.info("" + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + ret_track[1] + ")" + behind_forward_comment)
|
||||
if is_modify == True:
|
||||
cmd = "git status --short"
|
||||
debug.verbose("execute : " + cmd)
|
||||
|
@@ -11,6 +11,7 @@
|
||||
from island import debug
|
||||
from island import tools
|
||||
from island import env
|
||||
from island import config
|
||||
from island import multiprocess
|
||||
from island import manifest
|
||||
import os
|
||||
@@ -37,14 +38,14 @@ def execute(arguments):
|
||||
debug.error("System already init have an error: missing data: '" + str(env.get_island_path()) + "'")
|
||||
|
||||
|
||||
configuration = manifest.load_config()
|
||||
configuration = config.Config()
|
||||
|
||||
debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
|
||||
# update manifest
|
||||
cmd = "git fetch --all"
|
||||
multiprocess.run_command_direct(cmd, cwd=env.get_island_path_manifest())
|
||||
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration["file"])
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == False:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
@@ -69,9 +70,21 @@ def execute(arguments):
|
||||
if ret != "" \
|
||||
and ret != False:
|
||||
# all is good, ready to get the system work corectly
|
||||
debug.info("'" + ret + "'")
|
||||
debug.info("'" + str(ret) + "'")
|
||||
debug.error("Clone repository does not work ... ")
|
||||
continue
|
||||
# add global mirror list
|
||||
for mirror in elem.select_remote["mirror"]:
|
||||
debug.verbose("Add global mirror: " + str(mirror))
|
||||
cmd = "git remote add " + mirror["name"] + " " + mirror["fetch"] + "/" + elem.name
|
||||
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||
if ret != "" \
|
||||
and ret != False:
|
||||
# all is good, ready to get the system work corectly
|
||||
debug.info("'" + str(ret) + "'")
|
||||
debug.warning("Can not add global mirror ... ")
|
||||
continue
|
||||
debug.verbose("Add global mirror: " + str(mirror) + " (done)")
|
||||
#debug.info("plop " + str(elem.select_remote.keys()))
|
||||
# check submodule if requested:
|
||||
if elem.select_remote["sync"] == True \
|
||||
@@ -82,7 +95,7 @@ def execute(arguments):
|
||||
if ret != "" \
|
||||
and ret != False:
|
||||
# all is good, ready to get the system work corectly
|
||||
debug.info("'" + ret + "'")
|
||||
debug.info("'" + str(ret) + "'")
|
||||
debug.error("Can not init submodules ... ")
|
||||
continue
|
||||
cmd = "git submodule update"
|
||||
@@ -93,7 +106,7 @@ def execute(arguments):
|
||||
elif ret != "" \
|
||||
and ret != False:
|
||||
# all is good, ready to get the system work corectly
|
||||
debug.info("'" + ret + "'")
|
||||
debug.info("'" + str(ret) + "'")
|
||||
debug.error("Can not init submodules ... ")
|
||||
continue
|
||||
|
||||
@@ -106,6 +119,7 @@ def execute(arguments):
|
||||
# simply update the repository ...
|
||||
debug.verbose("Fetching project: ")
|
||||
# fetch the repository
|
||||
|
||||
cmd = "git fetch " + elem.select_remote["name"]
|
||||
debug.verbose("execute : " + cmd)
|
||||
multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||
@@ -141,20 +155,37 @@ def execute(arguments):
|
||||
if is_modify == True:
|
||||
debug.warning("[" + elem.name + "] Not update ==> the repository is modified")
|
||||
continue
|
||||
|
||||
""" # TODO: this does not work ...
|
||||
if ret_track[1] != elem.select_remote["name"] + "/" + elem.branch:
|
||||
debug.warning("[" + elem.name + "] Not update ==> the current branch does not track the correct branch : track '" + ret_track[1] + "' instead of '" + elem.select_remote["name"] + "/" + elem.branch + "'")
|
||||
continue
|
||||
"""
|
||||
cmd = "git pull"
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret_pull = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
if ret_pull[0] == 0:
|
||||
if ret_pull[1] == "Already up-to-date.":
|
||||
pass
|
||||
elif ret_pull[1] != "":
|
||||
debug.info(ret_pull[1])
|
||||
else:
|
||||
if ret_pull[1] != "":
|
||||
debug.warning("ERROR GIT: " + ret_pull[1])
|
||||
else:
|
||||
debug.warning("ERROR GIT: in pull")
|
||||
|
||||
debug.info("select branch = '" + select_branch + "' is modify : " + str(is_modify) + " track: '" + str(ret_track[1]) + "'")
|
||||
debug.verbose("select branch = '" + select_branch + "' is modify : " + str(is_modify) + " track: '" + str(ret_track[1]) + "'")
|
||||
# check submodule if requested:
|
||||
if elem.select_remote["sync"] == True \
|
||||
and os.path.exists(os.path.join(git_repo_path, ".gitmodules")) == True:
|
||||
debug.info(" ==> sync submodule")
|
||||
cmd = "git submodule sync"
|
||||
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||
if ret != "" \
|
||||
and ret != False:
|
||||
if ret[:31] == "Synchronizing submodule url for":
|
||||
#all is good ...
|
||||
debug.info(" " + ret)
|
||||
elif ret != "" \
|
||||
and ret != False:
|
||||
# all is good, ready to get the system work corectly
|
||||
debug.info("'" + ret + "'")
|
||||
debug.error("Can not sync submodules ... ")
|
||||
|
72
island/config.py
Normal file
72
island/config.py
Normal file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
import platform
|
||||
import sys
|
||||
import os
|
||||
import copy
|
||||
# Local import
|
||||
from . import debug
|
||||
from . import tools
|
||||
from . import env
|
||||
from . import multiprocess
|
||||
|
||||
|
||||
env.get_island_path_config()
|
||||
|
||||
|
||||
class Config():
|
||||
def __init__(self):
|
||||
self._repo = ""
|
||||
self._branch = "master"
|
||||
self._manifest_name = "default.xml"
|
||||
|
||||
self.load()
|
||||
|
||||
|
||||
def load(self):
|
||||
config_property = tools.file_read_data(env.get_island_path_config())
|
||||
element_config = config_property.split("\n")
|
||||
for line in element_config:
|
||||
if len(line) == 0 \
|
||||
or line[0] == "#":
|
||||
# simple comment line ==> pass
|
||||
pass
|
||||
elif line[:5] == "repo=":
|
||||
self._repo = line[5:]
|
||||
elif line[:7] == "branch=":
|
||||
self._branch = line[7:]
|
||||
elif line[:5] == "file=":
|
||||
self._manifest_name = line[5:]
|
||||
else:
|
||||
debug.warning("island config error: can not parse: '" + str(line) + "'")
|
||||
return True
|
||||
|
||||
def store(self):
|
||||
data = "repo=" + self._repo + "\nbranch=" + self._branch + "\nfile=" + self._manifest_name
|
||||
tools.file_write_data(env.get_island_path_config(), data)
|
||||
|
||||
def set_manifest(self, value):
|
||||
self._repo = value
|
||||
|
||||
def get_manifest(self):
|
||||
return self._repo
|
||||
|
||||
def set_branch(self, value):
|
||||
self._branch = value
|
||||
|
||||
def get_branch(self):
|
||||
return self._branch
|
||||
|
||||
def set_manifest_name(self, value):
|
||||
self._manifest_name = value
|
||||
|
||||
def get_manifest_name(self):
|
||||
return self._manifest_name
|
||||
|
@@ -28,6 +28,24 @@ def get_system_base_name():
|
||||
|
||||
|
||||
island_root_path = os.path.join(os.getcwd())
|
||||
if os.path.exists(os.path.join(island_root_path, "." + get_system_base_name())) == True:
|
||||
# all is good ...
|
||||
pass
|
||||
elif os.path.exists(os.path.join(island_root_path, "..", "." + get_system_base_name())) == True:
|
||||
island_root_path = os.path.join(os.getcwd(), "..")
|
||||
elif os.path.exists(os.path.join(island_root_path, "..", "..", "." + get_system_base_name())) == True:
|
||||
island_root_path = os.path.join(os.getcwd(), "..", "..")
|
||||
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "." + get_system_base_name())) == True:
|
||||
island_root_path = os.path.join(os.getcwd(), "..", "..", "..")
|
||||
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "." + get_system_base_name())) == True:
|
||||
island_root_path = os.path.join(os.getcwd(), "..", "..", "..")
|
||||
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "..", "." + get_system_base_name())) == True:
|
||||
island_root_path = os.path.join(os.getcwd(), "..", "..", "..", "..")
|
||||
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "..", "..", "." + get_system_base_name())) == True:
|
||||
island_root_path = os.path.join(os.getcwd(), "..", "..", "..", "..", "..")
|
||||
else:
|
||||
#debug.error("the root path of " + get_system_base_name() + " must not be upper that 6 parent path")
|
||||
pass
|
||||
island_path = os.path.join(island_root_path, "." + get_system_base_name())
|
||||
island_path_config = os.path.join(island_path, "config.txt")
|
||||
island_path_manifest = os.path.join(island_path, "manifest")
|
||||
|
@@ -15,30 +15,10 @@ import copy
|
||||
from . import debug
|
||||
from . import tools
|
||||
from . import env
|
||||
from . import multiprocess
|
||||
|
||||
from lxml import etree
|
||||
|
||||
|
||||
def load_config():
|
||||
config_property = tools.file_read_data(env.get_island_path_config())
|
||||
element_config = config_property.split("\n")
|
||||
if len(element_config) != 3:
|
||||
debug.error("error in configuration property")
|
||||
if element_config[0][:5] != "repo=":
|
||||
debug.error("error in configuration property (2)")
|
||||
if element_config[1][:7] != "branch=":
|
||||
debug.error("error in configuration property (3)")
|
||||
if element_config[2][:5] != "file=":
|
||||
debug.error("error in configuration property (4)")
|
||||
configuration = {
|
||||
"repo":element_config[0][5:],
|
||||
"branch":element_config[1][7:],
|
||||
"file":element_config[2][5:]
|
||||
}
|
||||
debug.info("configuration property: " + str(configuration))
|
||||
return configuration
|
||||
|
||||
|
||||
class RepoConfig():
|
||||
def __init__(self):
|
||||
self.name = ""
|
||||
@@ -83,6 +63,29 @@ class Manifest():
|
||||
name = child.attrib[attr]
|
||||
elif attr == "fetch":
|
||||
fetch = child.attrib[attr]
|
||||
if len(fetch) >= 2 \
|
||||
and fetch[:2] == "..":
|
||||
# we have a relative island manifest ==> use local manifest origin to get the full origin
|
||||
cmd = "git remote get-url origin"
|
||||
debug.verbose("execute : " + cmd)
|
||||
base_origin = multiprocess.run_command(cmd, cwd=env.get_island_path_manifest())
|
||||
debug.verbose("base_origin=" + base_origin[1])
|
||||
base_origin = base_origin[1]
|
||||
while len(fetch) >= 2 \
|
||||
and fetch[:2] == "..":
|
||||
fetch = fetch[2:]
|
||||
while len(fetch) >= 1 \
|
||||
and ( fetch[0] == "/" \
|
||||
or fetch[0] == "\\"):
|
||||
fetch = fetch[1:]
|
||||
base_origin = base_origin[:base_origin.rfind('/')]
|
||||
debug.verbose("new base_origin=" + base_origin)
|
||||
debug.verbose("tmp fetch=" + fetch)
|
||||
if fetch != "":
|
||||
fetch = base_origin + "/" + fetch
|
||||
else:
|
||||
fetch = base_origin
|
||||
debug.verbose("new fetch=" + fetch)
|
||||
while len(fetch) > 1 \
|
||||
and ( fetch[-1] == "\\" \
|
||||
or fetch[-1] == "/") :
|
||||
@@ -90,11 +93,42 @@ class Manifest():
|
||||
else:
|
||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name,fetch]")
|
||||
debug.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "' fetch='" + fetch + "'");
|
||||
# parse the sub global mirror list
|
||||
mirror_list = []
|
||||
for child_2 in child:
|
||||
if child_2.tag == "mirror":
|
||||
# find a new mirror
|
||||
mirror_name = ""
|
||||
mirror_fetch = ""
|
||||
for attr_2 in child_2.attrib:
|
||||
if attr_2 == "name":
|
||||
mirror_name = child_2.attrib[attr_2]
|
||||
elif attr_2 == "fetch":
|
||||
mirror_fetch = child_2.attrib[attr_2]
|
||||
while len(mirror_fetch) > 1 \
|
||||
and ( mirror_fetch[-1] == "\\" \
|
||||
or mirror_fetch[-1] == "/") :
|
||||
mirror_fetch = mirror_fetch[:-1]
|
||||
else:
|
||||
debug.error("(l:" + str(child_2.sourceline) + ") Parsing the manifest : Unknow '" + child_2.tag + "' attibute : '" + attr_2 + "', availlable:[name,fetch]")
|
||||
debug.debug("mirror: '" + mirror_name + "' '" + mirror_fetch + "'")
|
||||
if mirror_name == "":
|
||||
debug.error("(l:" + str(child_2.sourceline) + ") Missing mirrot 'name'")
|
||||
if mirror_fetch == "":
|
||||
debug.error("(l:" + str(child_2.sourceline) + ") Missing mirror 'fetch'")
|
||||
mirror_list.append({
|
||||
"name":mirror_name,
|
||||
"fetch":mirror_fetch,
|
||||
})
|
||||
else:
|
||||
debug.error("(l:" + str(child_2.sourceline) + ") Parsing the manifest : Unknow '" + child_2.tag + "', availlable:[mirror]")
|
||||
self.remotes.append({
|
||||
"name":name,
|
||||
"fetch":fetch
|
||||
"fetch":fetch,
|
||||
"mirror":mirror_list
|
||||
})
|
||||
continue
|
||||
|
||||
if child.tag == "include":
|
||||
name = ""
|
||||
for attr in child.attrib:
|
||||
@@ -197,21 +231,25 @@ class Manifest():
|
||||
out = []
|
||||
if default == None:
|
||||
if self.default != None:
|
||||
tmp_default = copy.deepcopy(self.default)
|
||||
default = copy.deepcopy(self.default)
|
||||
else:
|
||||
tmp_default = copy.deepcopy(self.default_base)
|
||||
default = copy.deepcopy(self.default_base)
|
||||
# debug.error(" self.default=" + str(self.default))
|
||||
# add all local project
|
||||
for elem in self.projects:
|
||||
debug.verbose("parse element " + str(elem))
|
||||
conf = RepoConfig()
|
||||
conf.name = elem["name"]
|
||||
conf.path = self._create_path_with_elem(elem)
|
||||
|
||||
# add default remote for the project (search in herited element)
|
||||
for remote in self.remotes:
|
||||
debug.verbose(" Local Remote: " + str(remote))
|
||||
if remote["name"] == default["remote"]:
|
||||
conf.remotes.append(remote)
|
||||
if len(conf.remotes) == 0:
|
||||
for remote in upper_remotes:
|
||||
debug.verbose(" upper Remote: " + str(remote))
|
||||
if remote["name"] == default["remote"]:
|
||||
conf.remotes.append(remote)
|
||||
if len(conf.remotes) == 0:
|
||||
@@ -221,11 +259,14 @@ class Manifest():
|
||||
conf.select_remote = None
|
||||
debug.debug(" remotes count: " + str(len(conf.remotes)))
|
||||
for remote in conf.remotes:
|
||||
debug.debug(" remote=" + str(remote))
|
||||
debug.debug(" Ckeck remote : " + remote["name"] + " == " + default["remote"])
|
||||
debug.verbose(" remote=" + str(remote))
|
||||
debug.verbose(" default=" + str(default))
|
||||
if remote["name"] == default["remote"]:
|
||||
conf.select_remote = copy.deepcopy(remote)
|
||||
debug.debug(" copy select=" + str(conf.select_remote))
|
||||
|
||||
# copy the submodule synchronisation
|
||||
conf.select_remote["sync"] = default["sync"]
|
||||
break
|
||||
@@ -240,7 +281,7 @@ class Manifest():
|
||||
upper_remotes_forward.append(remote)
|
||||
# add all include project
|
||||
for elem in self.includes:
|
||||
list_project = elem["manifest"].get_all_configs(tmp_default, upper_remotes_forward)
|
||||
list_project = elem["manifest"].get_all_configs(default, upper_remotes_forward)
|
||||
for elem_proj in list_project:
|
||||
out.append(elem_proj)
|
||||
return out
|
||||
|
2
setup.py
2
setup.py
@@ -16,7 +16,7 @@ def readme():
|
||||
|
||||
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
setup(name='island',
|
||||
version='0.2.0',
|
||||
version='0.4.0',
|
||||
description='island generic source manager (like repo in simple mode)',
|
||||
long_description=readme(),
|
||||
url='http://github.com/HeeroYui/island',
|
||||
|
Reference in New Issue
Block a user