HOWTO Gentoo on Cygwin
From Gentoo Linux Wiki
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
As of 2008, Gentoo on Cygwin is unmaintained.[1] See http://cygwinports.dotsrc.org/ for a better alternative.
Contents |
[edit] Installation
[edit] Prerequisites
In order for Portage to operate properly, you will need, at a minimum, the following Cygwin binary packages (and their dependencies) installed:
In order for Portage to properly build system, you will also need:
- autoconf
- automake1.9
- curl
- gcc
- libtool1.5
- make
- ncurses, especially libncurses-devel
- patch (or run 'emerge patch' before 'emerge system')
You should be warned that my rudimentary system package set includes app-editors/nano. That said, I advise against installing nano.
See http://www.cygwin.com/ to obtain the setup program for installing these packages.
[edit] Binaries
Though dominated by Python scripts, Portage actually makes use of two compiled files. As such, I have prepared a "binary" that you can download from http://web.mit.edu/jalonso/www/cygwin-portage/portage/. Unroll it by hand as you would a raw Cygwin installation binary tarball:
cd / tar -xjvf ~/portage-2.0.54-2.tar.bz2
The more GPL-conscious among you should notice that the original source tarball and ebuild are posted there along with my patches and modified ebuild.
[edit] Portage tree
[edit] "Managed" mounts
Before you get too far along in rsync'ing or otherwise downloading your portage tree, you should know that it contains some characters that are not permitted in Windows file systems. This turns out to be a more common problem than case insensitivity. Fortunately, Cygwin, in its great and mighty wisdom, has a way to circumvent both of these issues by rewriting file names in a manner similar to URL escaping, but it incurs a dreadful (but acceptable in this case) performance hit. The process is to use something called "managed" mounts.
cd /usr mkdir -p .managed/portage mkdir portage mount -o managed `cygpath -m /usr/.managed/portage` /usr/portage
Once the configuration process is complete, emerge --sync will Do The Right Thing. In fact, you can run the command to retrieve your initial tree.
| FIXME: Group configuration should be discussed before suggesting emerge can be run |
WARNING: You should know that mv and other utilities that may find a way to move an entire folder into a managed mount at once may not trigger Cygwin to rewrite filenames. Utilities like rsync are far more reliable. Failure to mind this may result in weird problems where ls might reveal a file called ChangeLog, but if the file hasn't been renamed to %43hange%4Cog, any attempt to open it will fail, as the file %43hange%4Cog is not really there.
[edit] Cygwin-specific and other overlays
At the time of this writing, the mainstream portage tree does not support Cygwin or the cygwin keyword. You will require, therefore, an overlay that starts with something like http://web.mit.edu/jalonso/www/cygwin-portage/cygwin-overlay.tar.gz. You should extract it into /usr/local/portage.cygwin:
mkdir /usr/local/portage.cygwin cd /usr/local/portage.cygwin tar -xzvf ~/cygwin-overlay.tar.gz
| FIXME: Documentation on auto-generating cygwin-binary ebuilds from the Cygwin setup.ini tree (and/or possible hosting of the same) should be put here. |
[edit] Configuration
What follows are the steps I followed to bootstrap a new machine, along with gently sanitized copies of the configuration files that I use.
[edit] User accounts and groups
[Errno 22] Invalid argument:Is caused by cygwin when not found a group or user into Windows(R) users or groups. If appear it, check the /etc/passwd or /etc/group files.
- Create portage group (add yourself to it), and add it to /etc/group
# If Administrators group looks like Administrators:S-1-5-32-544:0: echo 'portage:S-1-5-32-544:250:root' >> /etc/group
- Fake a wheel group (base it off of the root group).
# If root looks like 'root:S-1-5-32-544:0:' echo 'wheel:S-1-5-32-544:10:' >> /etc/group
- Fake a portage user (base it off of SYSTEM), and add it to /etc/passwd.
# If SYSTEM looks like 'SYSTEM:*:18:544:,S-1-5-18::' echo 'portage:*:250:250:,S-1-5-18::' >> /etc/passwd
You will need to log out and log in for the group assignments to pan out.
[edit] DLL rebasing
It will be necessary to rebase python's dynamic dlls.
cd /usr/lib/python2.4/lib-dynload ls *.dll >dll.lst rebase -b 0x70000000 -o 0x10000 -T dll.lst
[edit] /etc/make.conf
The most notable feature of this file is the invocation of the portage overlay. It also includes a userpriv code> entry in FEATURES code>, which enables some things to work out of a user's home directory instead of the mythical /root folder. This includes subversion sources.
| File: /etc/make.conf |
CHOST="i686-pc-cygwin" CFLAGS="-march=pentium3 -O3 -pipe" PORTDIR_OVERLAY="/usr/local/portage.cygwin" USE="doc" FEATURES="userpriv test" |
[edit] /etc/portage/profile/virtuals
This file provides the critical service of remapping certain common dependencies (which will be inevitably masked) to their cygwin binary equivalents. With an appropriately configurated overlay, portage can actually install these binaries.
| FIXME: tell the world how to do this... |
It should be noted, however, that portage cannot merge all packages into a live system. In particular, it cannot replace running executables, most notably python, bash, and cygwin1.dll.
| File: /etc/portage/profile/virtuals |
sys-libs/ncurses cygwin-binaries/ncurses sys-apps/sysvinit cygwin-binaries/sysvinit dev-util/subversion cygwin-binaries/subversion sys-devel/automake cygwin-binaries/automake sys-devel/libtool cygwin-binaries/libtool sys-devel/autoconf cygwin-binaries/autoconf sys-devel/gettext cygwin-binaries/gettext cygwin-binaries/gettext-devel cygwin-binaries/libgettextpo0 virtual/libintl cygwin-binaries/gettext cygwin-binaries/gettext-devel cygwin-binaries/libgettextpo0 |
[edit] /etc/portage/profile/package.provided
This file is a source of great sanity in using portage sensibly on Cygwin. In conjunction with /etc/portage/profile/virtuals as described above, this file specifies explicitly which packages (with their versions) that portage should not worry about. This should be populated with data reflective of packages installed using Cygwin setup.
| File: /etc/portage/profile/package.provided |
cygwin-binaries/base-files-3.7a cygwin-binaries/python-2.4.1-r1 cygwin-binaries/cygwin-1.5.19-r4 cygwin-binaries/ncurses-5.4-r4 cygwin-binaries/sysvinit-2.84-r4 cygwin-binaries/subversion-1.2.3-r1 cygwin-binaries/automake-1.7.9-r2 cygwin-binaries/libtool-1.5b-r2 cygwin-binaries/autoconf-2.59-r2 |
It should be noted that cygcheck -c -d can give you a dump of all the packages installed in that manner. The script below can generate the /etc/portage/profile/package.provided for you.
| Code: Generate package.provided |
cygcheck -c -d | \
awk '{print "cygwin-binaries/"$1"-"$2}' | \
dos2unix | \
sed -e 's/-\([0-9]\+\)$/-r\1/' > /etc/portage/profile/package.provided
|
[edit] /etc/make.profile
You shall also require a symlink at /etc/make.profile to the default-cygwin profile:
ln -s /usr/local/portage.cygwin/profiles/default-cygwin /etc/make.profile
[edit] Bootstrap
At this point, you may now issue your first portage commands to get yourself going.
/usr/sbin/env-update emerge --sync emerge patch # if you did not install cygwin's patch emerge system
The emerge system command should run without error. You'll quickly notice, however, that my definition of system is quite dull.
[edit] Further Discussion
Scattered bits of additional notes are available at http://web.mit.edu/jalonso/www/cygwin-portage/.
Enjoy. --Jalonso 08:52, 1 March 2006 (GMT)
- Why is this a HowTo instead of a single python or bash script (with shUnit2 or pyUnit sanity checks)? --BrianFennell
