mirror of
https://github.com/tuna/tunasync.git
synced 2025-04-21 04:42:46 +00:00
set environment variable for mirror jobs
This commit is contained in:
parent
6205d4a3a6
commit
5576efff56
@ -2,5 +2,6 @@
|
|||||||
echo $TUNASYNC_WORKING_DIR
|
echo $TUNASYNC_WORKING_DIR
|
||||||
echo $TUNASYNC_LOG_FILE
|
echo $TUNASYNC_LOG_FILE
|
||||||
echo $TUNASYNC_UPSTREAM_URL
|
echo $TUNASYNC_UPSTREAM_URL
|
||||||
|
echo $REPO
|
||||||
sleep 5
|
sleep 5
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -58,5 +58,18 @@ command = "./shell_provider.sh"
|
|||||||
upstream = "https://pypi.python.org/"
|
upstream = "https://pypi.python.org/"
|
||||||
# log_file = "/tmp/arch4-{date}.log"
|
# log_file = "/tmp/arch4-{date}.log"
|
||||||
use_btrfs = false
|
use_btrfs = false
|
||||||
|
# set environment varialbes
|
||||||
|
[mirrors.env]
|
||||||
|
REPO = "/usr/local/bin/repo"
|
||||||
|
|
||||||
# vim: ft=toml
|
[[mirrors]]
|
||||||
|
name = "arch5"
|
||||||
|
provider = "shell"
|
||||||
|
command = "./shell_provider.sh"
|
||||||
|
upstream = "https://pypi.python.org/"
|
||||||
|
# log_file = "/tmp/arch4-{date}.log"
|
||||||
|
use_btrfs = false
|
||||||
|
[mirrors.env]
|
||||||
|
REPO = "/usr/local/bin/repo2"
|
||||||
|
|
||||||
|
# vim: ft=toml ts=2 sts=2 sw=2
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
function sync_android() {
|
|
||||||
cd $TUNASYNC_WORKING_DIR
|
|
||||||
/usr/local/bin/android-repo sync -f
|
|
||||||
}
|
|
||||||
|
|
||||||
function update_repo_config() {
|
|
||||||
for repo in $(find $TUNASYNC_WORKING_DIR -type d -not -path "*/.repo/*" -name "*.git")
|
|
||||||
do
|
|
||||||
cd $repo
|
|
||||||
echo $repo
|
|
||||||
git config pack.threads 1
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
sync_android
|
|
||||||
update_repo_config
|
|
21
scripts/aosp.sh
Executable file
21
scripts/aosp.sh
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
REPO=${REPO:-"/usr/local/bin/repo"}
|
||||||
|
|
||||||
|
function repo_init() {
|
||||||
|
mkdir -p $TUNASYNC_WORKING_DIR
|
||||||
|
cd $TUNASYNC_WORKING_DIR
|
||||||
|
$REPO init -u https://android.googlesource.com/mirror/manifest --mirror
|
||||||
|
}
|
||||||
|
|
||||||
|
function repo_sync() {
|
||||||
|
cd $TUNASYNC_WORKING_DIR
|
||||||
|
$REPO sync -f
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ ! -d "$TUNASYNC_WORKING_DIR/git-repo.git" ]; then
|
||||||
|
echo "Initializing AOSP mirror"
|
||||||
|
repo_init
|
||||||
|
fi
|
||||||
|
|
||||||
|
repo_sync
|
@ -53,6 +53,9 @@ class MirrorConfig(object):
|
|||||||
self.options["use_btrfs"] = self._parent.use_btrfs
|
self.options["use_btrfs"] = self._parent.use_btrfs
|
||||||
assert self.options["use_btrfs"] in (True, False)
|
assert self.options["use_btrfs"] in (True, False)
|
||||||
|
|
||||||
|
if "env" in self.options:
|
||||||
|
assert isinstance(self.options["env"], dict)
|
||||||
|
|
||||||
def __getattr__(self, key):
|
def __getattr__(self, key):
|
||||||
if key in self.__dict__:
|
if key in self.__dict__:
|
||||||
return self.__dict__[key]
|
return self.__dict__[key]
|
||||||
@ -68,6 +71,7 @@ class MirrorConfig(object):
|
|||||||
'log_dir': self.log_dir,
|
'log_dir': self.log_dir,
|
||||||
'log_file': self.log_file,
|
'log_file': self.log_file,
|
||||||
'interval': self.interval,
|
'interval': self.interval,
|
||||||
|
'env': self.env,
|
||||||
'hooks': hooks,
|
'hooks': hooks,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ class RsyncProvider(MirrorProvider):
|
|||||||
|
|
||||||
def __init__(self, name, upstream_url, local_dir, log_dir,
|
def __init__(self, name, upstream_url, local_dir, log_dir,
|
||||||
useIPv6=True, password=None, exclude_file=None,
|
useIPv6=True, password=None, exclude_file=None,
|
||||||
log_file="/dev/null", interval=120, hooks=[]):
|
log_file="/dev/null", interval=120, env=None, hooks=[]):
|
||||||
super(RsyncProvider, self).__init__(name, local_dir, log_dir, log_file,
|
super(RsyncProvider, self).__init__(name, local_dir, log_dir, log_file,
|
||||||
interval, hooks)
|
interval, hooks)
|
||||||
|
|
||||||
@ -73,6 +73,7 @@ class RsyncProvider(MirrorProvider):
|
|||||||
self.useIPv6 = useIPv6
|
self.useIPv6 = useIPv6
|
||||||
self.exclude_file = exclude_file
|
self.exclude_file = exclude_file
|
||||||
self.password = password
|
self.password = password
|
||||||
|
self.env = env
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def options(self):
|
def options(self):
|
||||||
@ -99,6 +100,9 @@ class RsyncProvider(MirrorProvider):
|
|||||||
new_env = os.environ.copy()
|
new_env = os.environ.copy()
|
||||||
if self.password is not None:
|
if self.password is not None:
|
||||||
new_env["RSYNC_PASSWORD"] = self.password
|
new_env["RSYNC_PASSWORD"] = self.password
|
||||||
|
if self.env is not None and isinstance(self.env, dict):
|
||||||
|
for k, v in self.env.items():
|
||||||
|
new_env[k] = v
|
||||||
|
|
||||||
self.p = sh.rsync(*_args, _env=new_env, _out=log_file,
|
self.p = sh.rsync(*_args, _env=new_env, _out=log_file,
|
||||||
_err_to_out=True, _out_bufsize=1, _bg=True)
|
_err_to_out=True, _out_bufsize=1, _bg=True)
|
||||||
@ -153,6 +157,9 @@ class TwoStageRsyncProvider(RsyncProvider):
|
|||||||
new_env = os.environ.copy()
|
new_env = os.environ.copy()
|
||||||
if self.password is not None:
|
if self.password is not None:
|
||||||
new_env["RSYNC_PASSWORD"] = self.password
|
new_env["RSYNC_PASSWORD"] = self.password
|
||||||
|
if self.env is not None and isinstance(self.env, dict):
|
||||||
|
for k, v in self.env.items():
|
||||||
|
new_env[k] = v
|
||||||
|
|
||||||
with open(log_file, 'w', buffering=1) as f:
|
with open(log_file, 'w', buffering=1) as f:
|
||||||
def log_output(line):
|
def log_output(line):
|
||||||
@ -175,13 +182,15 @@ class TwoStageRsyncProvider(RsyncProvider):
|
|||||||
class ShellProvider(MirrorProvider):
|
class ShellProvider(MirrorProvider):
|
||||||
|
|
||||||
def __init__(self, name, command, upstream_url, local_dir, log_dir,
|
def __init__(self, name, command, upstream_url, local_dir, log_dir,
|
||||||
log_file="/dev/null", log_stdout=True, interval=120, hooks=[]):
|
log_file="/dev/null", log_stdout=True, interval=120, env=None,
|
||||||
|
hooks=[]):
|
||||||
|
|
||||||
super(ShellProvider, self).__init__(name, local_dir, log_dir, log_file,
|
super(ShellProvider, self).__init__(name, local_dir, log_dir, log_file,
|
||||||
interval, hooks)
|
interval, hooks)
|
||||||
self.upstream_url = str(upstream_url)
|
self.upstream_url = str(upstream_url)
|
||||||
self.command = shlex.split(command)
|
self.command = shlex.split(command)
|
||||||
self.log_stdout = log_stdout
|
self.log_stdout = log_stdout
|
||||||
|
self.env = env
|
||||||
|
|
||||||
def run(self, ctx={}):
|
def run(self, ctx={}):
|
||||||
|
|
||||||
@ -194,6 +203,10 @@ class ShellProvider(MirrorProvider):
|
|||||||
new_env["TUNASYNC_UPSTREAM_URL"] = self.upstream_url
|
new_env["TUNASYNC_UPSTREAM_URL"] = self.upstream_url
|
||||||
new_env["TUNASYNC_LOG_FILE"] = log_file
|
new_env["TUNASYNC_LOG_FILE"] = log_file
|
||||||
|
|
||||||
|
if self.env is not None and isinstance(self.env, dict):
|
||||||
|
for k, v in self.env.items():
|
||||||
|
new_env[k] = v
|
||||||
|
|
||||||
_cmd = self.command[0]
|
_cmd = self.command[0]
|
||||||
_args = [] if len(self.command) == 1 else self.command[1:]
|
_args = [] if len(self.command) == 1 else self.command[1:]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user