-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_cgitrc.py
More file actions
executable file
·81 lines (59 loc) · 1.54 KB
/
make_cgitrc.py
File metadata and controls
executable file
·81 lines (59 loc) · 1.54 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/env python3
import os, git, sys
from configparser import ConfigParser
GIT_LOCATION="/var/git"
CGITRC_TEMPLATE="""
# Specify the css url
css=/style.css
# Allow http transport git clone
enable-http-clone=1
# Enable caching of up to 1000 output entries
cache-size=1000
# Use a custom logo
logo=/images/kdlp_logo.png
# Set the title and heading of the repository index page
root-title=Kernel Development Learning Pipeline
# Set a subheading for the repository index page
root-desc=KDLP Git repositories
# Include some more info about this site on the index page
root-readme=%(cache)s/index.html
##
## List of common mimetypes
##
mimetype.gif=image/gif
mimetype.html=text/html
mimetype.jpg=image/jpeg
mimetype.jpeg=image/jpeg
mimetype.pdf=application/pdf
mimetype.png=image/png
mimetype.svg=image/svg+xml
virtual-root=/cgit
scan-path=%(scan_path)s
""".strip()
try:
os.mkdir(GIT_LOCATION)
except FileExistsError:
# It's fine if the location already exists
pass
ini_file='kdlp.ini'
if len(sys.argv) > 1:
ini_file = sys.argv[1]
parser = ConfigParser()
parser.read(ini_file)
cgit = parser['cgit']
repos = cgit['list']
#repo = Repo.clone_from()
CGITRC = CGITRC_TEMPLATE % {
"cache": os.getcwd(),
"scan_path": GIT_LOCATION
}
repolist=""
with open(repos) as f:
repolist=f.read().strip()
for r in repolist.split('\n'):
target = "%s/%s" % (GIT_LOCATION, os.path.basename(r))
print("check", target)
if not os.path.isdir(target):
git.Repo.clone_from(r, target)
with open('cgitrc', 'w') as f:
f.write(CGITRC)