Author Topic: Porting Programs In Port Tree Via Nfs@mac Os X  (Read 5828 times)

ZDevil

  • Hero Member
  • *****
  • Posts: 1998
    • View Profile
    • http://
Porting Programs In Port Tree Via Nfs@mac Os X
« on: August 13, 2007, 10:14:55 pm »
The following is how I build in the port tree via a NFS server created on my MacBook (10.4.10) and mounted on my Zaurus SL-C3200@OpenBSD 4.2 beta (GENERIC #158).    

The process looks a bit involving indeed, but you will be fine if you take each small step carefully.
I am doing this in a slightly differently way from http://www.planetofidiots.com/zaurus/#ports .  I will raise some questions at the end.

But hang on. Why bother? Well, three considerations:

-- Building things on NFS shares is supposed to be faster than doing so on the microdrive on Z
-- Less heat is generated because the building jobs are done on a remote server (= my Macbook)
-- My personal reason: i cannot afford to let the precious internal SanDisk Extreme III 16GB CF wear out too soon because of extensive writing during make!    

Alright, here we go.

************

[span style=\'font-size:14pt;line-height:100%\']On the Mac (OS X 10.4) side [/span]

#1. Create a new directory for shares to be exported. Let's say /share/zaurus/usr. Then create a subdirectory obj/ under it. (More on this. Read on.)


#2. Set up an NFS server by following the instructions at http://www.behanna.org/osx/nfs/howto1.html up to Step 3.
This basically comes in two parts:
A. applying Chris' patch
B. configuring the NFS server and shares using Mac OS X's NetInfo application (a really neat program though seldom mentioned to ordinary users).
For instance, I use only /share/zaurus/usr/ports and /share/zaurus/usr/obj as the share directories (or technically called "shares").

The ports/ directory is where the port tree lives (of course).
The obj/ directory is the "workspace" where things got built. (See 15 for how to get it working)


#3. Download the ports tarball from OpenBSD snapshots: ftp://ftp.openbsd.org/pub/OpenBSD/snapshots/zaurus/


#4. Extract ports.tar.gz to /share/zaurus/usr
Code: [Select]
tar xvf ports.tar.gz -C /share/zaurus/usr
#5. Make sure you have restarted NFS to enable the new settings to take effect:
Code: [Select]
sudo SystemStarter restart NFS
showmount -e

#6. Find out the UID and GID of your Mac user account:
Code: [Select]
id YOUR_USER_NAMEFor example,
id XYZ
uid=502(XYZ) gid=502(XYZ) groups=502(XYZ), 80(admin)

(Why? The NFS client, i.e. your Zaurus, has to use an account matching the UID and GID in order to access the NFS shares.)


#7. Find out your Mac IP address (e.g. use ifconfig).
(This is to tell your Zaurus where the server is ... of course!)


[span style=\'font-size:14pt;line-height:100%\']Good![/span]  Now NFS is ready to run on your Mac. Let's switch to your Zaurus.


[span style=\'font-size:14pt;line-height:100%\']On the Zaurus side [/span]

#8. Log in as root.


#9. Add a new group with the same GID as the Mac user
Code: [Select]
groupadd 502
#10. Add a new user with the same GID and UID as the Mac user
Code: [Select]
useradd -g 502 -u 502 XYZ
#11. Add the new user to the wheel group
Code: [Select]
usermod -G wheel XYZ(Members in the wheel group have root privilege through using the sudo command).

#12. Grant this new user with the necessary root privilege by editing /etc/sudoers
Code: [Select]
visudo (visudo has automatic syntax-checking. DON'T edit /etc/sudoers using something else! You are on your own if the file gets messed up.)

Uncomment this line (i.e. take away the initial pound "#" sign)
Code: [Select]
#%wheel    ALL=(ALL) ALLSave and exit. Now the new user on Z has enough permission to build stuff on the NFS server.


#13. Log out the root account and log in as the newly created user.


#14. Mount the NFS shares on the server (Mac)
Code: [Select]
sudo mount_nfs -o soft,intr YOUR_MAC_IP_ADDRESS:/share/zaurus/usr/ports /usr/ports
sudo mount_nfs -o soft,intr YOUR_MAC_IP_ADDRESS:/share/zaurus/usr/obj /usr/obj
(Two options are being used here: "soft" helps performance, "intr" lets you stop in the middle by pressing Ctrl-C)

(You can make sure that NFS is properly mounted by using showmount -a in your Mac's terminal)


#15. Finetune in /etc/mk.conf
A. /usr/obj as the designated workspace:
-- The main advantage of moving all stuff created during building to /usr/obj is that you can simply delete whatever you want directory in this directory, without invoking make clean and the like or messing up the /usr/ports (sub-)directories over time.
-- Do it this way:
Use an editor to open /etc/mk.conf (create one if it's not yet present in the system).
Write down this line:
Code: [Select]
WRKOBJDIR=/usr/obj
B. Optimization (improves overall performance of the builds):
-- It seems to me the ports system ignores the architecture optimization flags I pass in .profile or the shell configuration files (.cshrc/.kshrc/.bash_profile), although the flags work if I build things outside of the port tree. These options, I believe, are important especially to a handheld device like Zaurus with low hardware specs compared to full-blown PCs/laptops.

-- This is how this can be done:
Add these two lines in /etc/mk.conf
Code: [Select]
CFLAGS+=-mcpu=xscale -mtune=xscale
CXXFLAGS+=-mcpu=xscale -mtune=xscale
Save and exit (no need to reboot/restart). Now your system will start building Zaurus-optimized ports without further tweaking!


#16. Now you can start building your favorite ports by running something like
Code: [Select]
sudo make BUILD=yes REPORT_PROBLEM=true SUBDIRLIST=/usr/ports/mypackages.txt install package(Assuming you have your desired ports to build specified in mypackages.txt, this command will install your ports AND package the ports for backup and sharing. Very handy, right?)

(You need to use sudo because make requires root permission to do many operations. You may also want to use visudo to extend the time limit by changing the value of timeout, for instance,
Code: [Select]
# Timeout options
Defaults timestamp_timeout=99999

See this nice how-to for batch porting: http://www.planetofidiots.com/zaurus/#ports


#17. Handy references
Where to find a specific port in the port tree?  Either use find /usr/ports -name NAME_OF_PORT or use http://ports.openbsd.nu/
More on ports and packages: http://www.openbsd.org/ports.html, http://www.openbsd.org/faq/faq15.html
All the technical ins and outs: http://www.openbsd.org/cgi-bin/man.cgi?que...386&format=html


************

A question:
According to http://www.planetofidiots.com/zaurus/#ports, the /etc/fstab on Z has these lines for NFS server:

Code: [Select]
    server1:/share/zaurus/bu /mnt/bu nfs rw,noauto,soft 0 0
    server1:/share/zaurus/usr/obj /usr/obj nfs rw,noauto,soft 0 0
    server1:/share/zaurus/usr/ports /usr/ports nfs rw,noauto,soft 0 0
    server1:/share/zaurus/usr/src /usr/src nfs rw,noauto,soft 0 0
    server1:/share/zaurus/usr/XF4 /usr/XF4 nfs rw,noauto,soft 0 0
But:
-- I don't quite understand how this works as the NFS is specified not to mount automatically. Still if I mount manually "server1" is not recognized either. I need to specify the full IP address of my NFS server (= my MacBook) instead of "server1". In fact I can mount the NFS shares without specifying them in /etc/fstab on Z. Any hint?  

Comments and questions are most welcome! I will surely incorporate useful points into the walkthrough.
« Last Edit: August 13, 2007, 10:52:32 pm by ZDevil »

Life is too precious for hacking *too much*
Visit my Z screencap gallery[/color]
My EeePC 701 Black = Debian (Lenny) on IceRocks + Transcend SDHC Class6 8GB + 2GB RAM
My Zaurus SL-C3200 = Debian EABI (kernel 2.6.24.3-yonggun) on a swapped internal Sandisk Extreme III CF 16gb
My Debian EABI feed: http://matrixmen.free.fr/zaurus/debian/
My OpenBSD/Zaurus feeds:  Link1, Link2
[/i][/font][/color][/size]

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
Porting Programs In Port Tree Via Nfs@mac Os X
« Reply #1 on: August 14, 2007, 12:03:17 am »
edit /etc/hosts and add

x.x.x.x server1

where x.x.x.x is the ip address of the server with the nfs shares
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

ZDevil

  • Hero Member
  • *****
  • Posts: 1998
    • View Profile
    • http://
Porting Programs In Port Tree Via Nfs@mac Os X
« Reply #2 on: August 14, 2007, 12:15:47 am »
Great. Thanks, Meanie. Will try that soon.
This piece seems missing in gen2's page. It would be better if this is included.  

Life is too precious for hacking *too much*
Visit my Z screencap gallery[/color]
My EeePC 701 Black = Debian (Lenny) on IceRocks + Transcend SDHC Class6 8GB + 2GB RAM
My Zaurus SL-C3200 = Debian EABI (kernel 2.6.24.3-yonggun) on a swapped internal Sandisk Extreme III CF 16gb
My Debian EABI feed: http://matrixmen.free.fr/zaurus/debian/
My OpenBSD/Zaurus feeds:  Link1, Link2
[/i][/font][/color][/size]