forked from coreos/dev-util
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemerge-gitclone
More file actions
executable file
·40 lines (32 loc) · 1.05 KB
/
emerge-gitclone
File metadata and controls
executable file
·40 lines (32 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python
from __future__ import print_function
import os
import shutil
import subprocess
import sys
import portage
synced = False
eroot = portage.settings['EROOT']
for repo in portage.db[eroot]['vartree'].settings.repositories:
if repo.sync_type != 'git':
continue
print(">>> Cloning repository '%s' from '%s'..." % (repo.name, repo.sync_uri))
if os.path.isdir(repo.location):
shutil.rmtree(repo.location)
elif os.path.lexists(repo.location):
os.unlink(repo.location)
print('>>> Starting git clone in %s' % repo.location)
os.umask(0o022)
subprocess.check_call(['git', 'clone', repo.sync_uri, repo.location])
print('>>> Git clone in %s successful' % repo.location)
synced = True
if synced:
# Perform normal post-sync tasks
configroot = portage.settings['PORTAGE_CONFIGROOT']
post_sync = '%s/etc/portage/bin/post_sync' % configroot
if os.path.exists(post_sync):
subprocess.check_call([post_sync])
subprocess.check_call(['emerge', '--check-news', '--quiet'])
else:
sys.stderr.write('>>> No git repositories configured.\n')
sys.exit(1)