Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Local Portage Mirror on OpenWrt
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
antonlacon
Apprentice
Apprentice


Joined: 27 Jun 2004
Posts: 249

PostPosted: Fri Mar 18, 2011 7:18 am    Post subject: Local Portage Mirror on OpenWrt Reply with quote

These are instructions to set up a local rsync mirror on top of an OpenWrt device, such as a hard drive equipped router. Much of this is adapted from Gentoo's documentation, with some additional tweaks for use on OpenWrt. Hopefully this will be useful to someone else as well.

1: Create the rsyncd configuration file:

Create /etc/rsyncd.conf with this content:
Code:
pid file = /var/run/rsyncd.pid
max connections = 5
use chroot = yes
uid = nobody
gid = nogroup
# hosts allow/deny are optional
hosts allow = 192.168.1.0/24
hosts deny = *

[gentoo-portage]
path=/mnt/usbdrive/path/to/portage/tree
comment=Gentoo Portage
exclude=distfiles/ packages/

Note: /var is symlinked to /tmp, a tmpfs mount instead of flash.

2: Start the rsync daemon on startup
An initscript has been added to the rsync package.
Code:
/etc/init.d/rsyncd enable
/etc/init.d/rsyncd start


3: Teach rsync to fetch Gentoo's portage tree:

Create rsync-gentoo-portage.sh (or script name of your choice) on the usbdisk
Code:
#!/bin/sh
RSYNC="/usr/bin/rsync"
OPTS="--quiet --recursive --links --perms --times -D --delete --timeout=300"
SRC="rsync://rsync.gentoo.org/gentoo-portage"
DST="/mnt/usbdisk/path/to/portage/tree"

if [ -e /mnt/usbdisk/USB_DISK_NOT_PRESENT ]; then
        exit
fi

${RSYNC} ${OPTS} ${SRC} ${DST}

exit

4: Sync portage with a scheduled task

Open browser Administration → Services → Scheduled Tasks
Enter:
Code:
18 4 * * * /mnt/usbdisk/bin/rsync-gentoo-portage.sh

Click submit

OR
In a shell:
Code:
crontab -e
18 4 * * * /mnt/usbdisk/bin/rsync-gentoo-portage.sh
:wq

Note: OpenWrt's default editor is vi.

5 entries separated by spaces, then the command to run. Order is:
Minutes Hour DayOfTheMonth Month DayOfTheWeek
Entry above = 04:18 each morning, every day of the year.

5: Configure workstations to use the local mirror:

Edit /etc/make.conf. Add a line that reads:
Code:
SYNC=”rsync://192.168.1.1/gentoo-portage”

Optional: Keep scheduled task from clobbering flash if usbdisk isn't mounted
While usbdisk is NOT mounted:
Code:
touch /mnt/usbdisk/USB_DISK_NOT_PRESENT
chmod 0444 /mnt/usbdisk -R

This serves as two lines of defense. The first is the readonly mountpoint. The second is the rsync-gentoo-portage.sh script aborts if USB_DISK_NOT_PRESENT is found, instead of the mounted files.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum