Gentoo Archives: gentoo-user

From: Peter Humphrey <peter@××××××××××××.uk>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Local portage git mirror
Date: Tue, 17 Jan 2017 13:58:52
Message-Id: 8116250.RlMcLTSm2s@peak
In Reply to: Re: [gentoo-user] Local portage git mirror by Bill Kenworthy
1 On Tuesday, 17 January 2017 20:51:38 GMT Bill Kenworthy wrote:
2 > On 17/01/17 18:03, Peter Humphrey wrote:
3 > > Hello list,
4 > >
5 > > Does anyone have some pointers to setting up a local portage mirror for
6 > > git to serve? I'm looking at http://www.funtoo.org/Portage_Git_Mirror
7 > > but some details are obscure to me. I hope I'm not going to have to
8 > > roll my sleeves up and learn the whole of git; I just want to cut down
9 > > the time my boxes take to sync via git - some of them have their
10 > > portage trees nfs-mounted in chroots on my workstation and take
11 > > anything up to 20 minutes to sync.
12 > >
13 > > One question comes up straight away: should the git-served repository be
14 > > the host's own /usr/portage tree? And what cron task should I run to
15 > > refresh the mirror?
16 > >
17 > > Any help would be gratefully received.
18 > >
19 > > (I can still read e-mails via web-mail even when KMail is playing up.)
20 >
21 > I moved my systems to a local git repos some time ago - it works (fast -
22 > much faster than rsync!)but its not perfect:
23 >
24 > It would be nice if someone can share how it really should be done!
25
26 It seems to me to be ideal material for a wiki page. Any offers?
27
28 > Below is the contents of an email to the list in 2015 when I got it
29 > working:
30 >
31 > * problems:
32 > the files in /usr/share/portage sometimes get overridden and give an
33 > error message
34 > renaming "gentoo" to "olympus" (the server host) made sense at the time
35 > but creates odd errors at times requiring files to be restored.
36 > git doesnt use the portage checksums which besides odd errors at times
37 > required using "thin-manifests = true" in
38 > "/usr/portage/metadata/layout.conf"
39
40 Many thanks, Bill. That'll give me something to think about!
41
42 --
43 Regards
44 Peter
45
46 > ++++++++++++++++++
47 > Replace your rsync infrastructure with a git one. After set up, there
48 > is faster syncing than rsync, both externally to the gentoo
49 > infrastructure (reasonable ADSL link), and really fast compared to rsync
50 > internally. Not simple, but its a one off hit on just a few machines
51 > for me. Works for me, no warranty etc.
52 >
53 > Thanks to Michael and Hasufell for the hints needed to get this working.
54 > Apologies for the line wrap.
55 >
56 >
57 >
58 > Replace with your own values!
59 > repo name: olympus
60 > repo master host: olympus.lan.localdomain
61 >
62 > On the master:
63 >
64 > install git !!!
65 >
66 > Download https://github.com/hasufell/portage-gentoo-git-config
67 >
68 > unzip
69 >
70 > cp -v portage-gentoo-git-config-master/etc/portage/repo.postsync.d/*
71 > /etc/portage/repo.postsync.d/
72 >
73 > cp portage-gentoo-git-config-master/etc/portage/repos.conf/gentoo.conf
74 > /etc/portage/repos.conf/
75 >
76 > if needed: chmod +x /etc/portage/repo.postsync.d/sync_overlay_cache
77 > cd /usr/
78 > mv portage portage.old
79 >
80 > emerge --sync
81 >
82 >
83 > To use as the master for your own mirror system:
84 > Uncomment the lines in /etc/rsyncd.conf to set up your own
85 > gentoo-portage rsync server - still needed for now
86 >
87 > rc-update add rsyncd
88 >
89 > /etc/init.d/rsyncd start
90 >
91 >
92 >
93 > On the internal clients wanting to use the mirror:
94 > reccomended: set up passwordless ssh between clients and the master
95 >
96 > emerge dev-vcs/git
97 >
98 > create /etc/portage/repos.conf/olympus.conf as follows
99 > --------------------
100 > [DEFAULT]
101 > main-repo = olympus
102 >
103 > [olympus]
104 > location = /usr/portage
105 > sync-type = git
106 > sync-uri = git://olympus.lan.localdomain:/usr/portage
107 > auto-sync = yes
108 > --------------------
109 >
110 > create /etc/portage/repo.postsync.d/sync_olympus
111 > --------------------
112 > #!/bin/bash
113 >
114 > repository_name="${1}"
115 > repository_path="${3}"
116 >
117 > [[ ${repository_name} == "olympus" ]] || exit 0
118 >
119 > source /lib/gentoo/functions.sh
120 >
121 > # Number of jobs for egencache, default is number or processors.
122 > parallel_jobs="$(nproc)"
123 >
124 > # caches
125 > ebegin "Fetching pre-generated metadata cache for ${repository_name}"
126 > rsync -a
127 > rsync://olympus.lan.localdomain/gentoo-portage/metadata/md5-cache/
128 > "${repository_path}"/metadata/md5-cache/
129 > eend $?
130 >
131 > ebegin "Updating metadata cache for ${repository_name}"
132 > egencache --jobs="${parallel_jobs}" --repo="${repository_name}"
133 > --update --update-use-local-desc
134 > eend $?
135 >
136 > #DTD's
137 > DTDDIR="${repository_path}"/metadata/dtd
138 > ebegin "Updating DTDs"
139 > if [[ -e ${DTDDIR} ]]; then
140 > git -C "${DTDDIR}" pull -q --ff
141 > else
142 > git clone olympus.lan.localdomain:/usr/portage/metadata/dtd
143 > "${DTDDIR}"
144 > fi
145 > eend "$?"
146 >
147 > #GLSA's
148 > GLSADIR="${repository_path}"/metadata/glsa
149 > ebegin "Updating GLSAs"
150 > if [[ -e ${GLSADIR} ]]; then
151 > git -C "${GLSADIR}" pull -q --ff
152 > else
153 > git clone olympus.lan.localdomain:/usr/portage/metadata/glsa
154 > "${GLSADIR}"
155 > fi
156 > eend "$?"
157 >
158 > # herds
159 > ebegin "Updating herds.xml"
160 > rsync -a
161 > rsync://olympus.lan.localdomain/gentoo-portage/metadata/herds.xml
162 > "${repository_path}"/metadata/md5-cache/
163 > eend $?
164 >
165 > #news
166 > NEWSDIR="${repository_path}"/metadata/news
167 > ebegin "Updating news items"
168 > if [[ -e ${NEWSDIR} ]]; then
169 > git -C "${NEWSDIR}" pull -q --ff
170 > else
171 > git clone olympus.lan.localdomain:/usr/portage/metadata/news
172 > "${NEWSDIR}"
173 > fi
174 > eend $? "Try to remove ${NEWSDIR}"
175 > --------------------
176 >
177 >
178 > mv /usr/portage /usr/portage.old
179 >
180 > git clone olympus.lan.localdomain:/usr/portage /usr/portage
181 >
182 > echo 'olympus' > /usr/portage/profiles/repo_name
183 >
184 > echo 'masters = olympus' > /usr/local/portage/metadata/layout.conf
185 >
186 > echo 'thin-manifests = true' >> /usr/local/portage/metadata/layout.conf
187 >
188 > cp /usr/portage/metadata/layout.conf
189 > /usr/local/portage/metadata/layout.conf
190 >
191 > cp /etc/portage/repos.conf/olympus.conf
192 > /usr/share/portage/config/repos.conf
193 >
194 > emerge --sync
195 > emerge --sync
196 >
197 > * the first sync will complete the process, the second is to check there
198 > are no errors.