Gentoo Prefix-Portage For IRIX
On Nekochan in 2009, user Stuart posted that he had gotten Gentoo Prefix, a type of Portage port to other systems, working on IRIX. This article is an archive/documentation of that effort. Due to the 12-year gap from the time of writing this adaptation of his methods, this article is posted without warranty or guarantees.
History
Stuart posted on his initial post that he had quit working on pkgsrc (a NetBSD project) for the following reasons:
- The build process was too basic and couldn't handle individual upgrades of packages.
- Inattention from the development staff to patch their projects.
In contrast he found ebuilds from Gentoo easy to modify and support staff incredibly helpful. All in all he found this a better way forward.
Bootstrapping
Firstly, one must decide a prefix. For the purposes of this guide, /opt/gentoo
will be used.
Create this directory, and subdirectory named 'home' within it. Create the user and group 'portage:portage' with UID and GID 250 with the recently-created 'home' directory as their home directory, and then recursively change ownership of the top-level installation directory to 'portage:portage'.
Save the following script as '~portage/.bashrc', altering EPREFIX as necessary:
EPREFIX="/opt/gentoo"
CHOST="mips-sgi-irix6.5"
PATH="${EPREFIX}/sbin:${EPREFIX}/usr/sbin:\
${EPREFIX}/usr/${CHOST}/bin:\
${EPREFIX}/usr/bin:${EPREFIX}/bin:\
/opt/bin:/usr/local/bin:\
/usr/nekoware/bin:/usr/bsd/bin:\
/usr/nekoware/sbin:/usr/bsd/sbin:$PATH"
export PATH EPREFIX CHOST
LD_LIBRARYN32_PATH="${EPREFIX}/usr/lib:${EPREFIX}/lib:${EPREFIX}/usr/lib/nspr"
export LD_LIBRARYN32_PATH
# This breaks most builds...
#ac_cv_path_RAWCPP="$( which cpp )"
CC="cc"
BUILD_CC="cc"
CXX="CC"
CXXCPP="CC -E"
export CC BUILD_CC CXX CXXCPP # ac_cv_path_RAWCPP
MIPSPRO_DEBUG=0
MIPSPRO_VERBOSE=0
MIPSPRO_PERMISSIVE=0
export MIPSPRO_DEBUG MIPSPRO_VERBOSE MIPSPRO_PERMISSIVE
# This should now all be handled by the IRIX MIPSpro wrapper...
# ... but some builds (such as perl) interrogate these flags directly without
# going via the compiler, so we do need to define them in the environment
# regardless.
common="-O2 -n32 -mips4 -r14000 -float_const -use_readonly_const -TARG:isa=mips4:platform=ip30:processor=r14000 -TENV:zeroinit_in_bss=ON -OPT:fast_io=ON:Olimit=8192:reorg_common=ON:swp=ON -LNO:auto_dist=ON:fusion_peeling_limit=8:gather_scatter=2"
# cc-1035 is generated when the compiler hits '#error', but by default it
# is treated only as a warning. This is broken.
common="$common -diag_error 1035"
# There are various problems building C++ code with MIPSpro 7.4.4m compiler
# front-end, which can actually produce incorrect code. This can be worked-
# around by using the 7.4.3m front-end, which appears not to be affected.
fixcxx="-LANG:std=off:libc_in_namespace_std=off -Zf,_245"
# Comment out the following line to increase C++ compatibility...
unset fixcxx
bsdcompat="-D_BSD_COMPAT"
bsdfull="-D_BSD_TYPES -D_BSD_TIME" # -D_BSD_SIGNALS : Breaks use of <sigaction.h>
quiet="-woff 1174,1183,1185,1552"
ccquiet="${quiet},3968,3970"
# With `-Zf,_245', the higher error numbers aren't set...
if [ -n "$( echo "${fixcxx}" | grep "_245" )" ]; then
cxxquiet="${quiet}"
else
cxxquiet="${ccquiet}"
fi
nowarn="-woff 1009,1014,1110,1116,1188,1204,1230,1233 -Wl,-woff,84,-woff,85"
# Additional options:
# -signed Make variables of type 'char' default to 'signed char' rather than
# 'unsigned char'
#
CPPFLAGS="${BSDCOMPAT} -I${EPREFIX}/usr/include"
CFLAGS="-c99 ${common} ${ccquiet}"
CXXFLAGS="-J2 ${common} -FE:eliminate_duplicate_inline_copies:template_in_elf_section ${cxxquiet} ${fixcxx}"
LDFLAGS="-Wl,-s,-x,-n32,-mips4,-rdata_shared,-allow_jump_at_eop" # -v
LDFLAGS="${LDFLAGS},-rpath,${EPREFIX}/usr/lib:${EPREFIX}/lib -L${EPREFIX}/usr/lib -L${EPREFIX}/lib"
unset common fixcxx bsdcompat bsdfull quiet ccquiet cxxquiet nowarn
export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS
# Other random fixes...
CONFIG_SHELL="$( which bash )"
export CONFIG_SHELL
gentoopath="${EPREFIX}/usr/share/man:${EPREFIX}/usr/man"
sysman="/usr/catman:/usr/share/man:/usr/share/catman"
optman="/opt/man:/opt/modules/2.2.2.5/man"
sgiman="/usr/freeware/catman:/var/sgi_apache/server/man"
localman="/usr/local/man"
bsdman="/usr/bsd/catman:/usr/bsd/man:/usr/bsd/lib/perl5/man:/usr/bsd/lib/perl5/site_perl/man:/usr/bsd/lib/perl5/vendor_perl/man"
nekoman="/usr/nekoware/man:/usr/nekoware/ssl/man"
MANPATH="$gentoopath:$sysman:$optman:$sgiman:$localman:$bsdman:$nekoman"
#MANFMTCMD="groff -Tascii -man"
export MANPATH # MANFMTCMD
unset gentoopath sysman optman sgiman localman bsdman nekoman
# The 'rs', 'hl' and 'ca' directives don't work as of coreutils-7.1
type -pf dircolors >/dev/null && eval $( dircolors -b | sed 's/rs=[^:]\+:// ; s/:hl=[^:]\+:/:/ ; s/:ca=[^:]\+:/:/' )
alias ls='ls --color=auto -hF'
alias grep='grep --colour'
alias man='PAGER="less" man'
EDITOR="vim"
export EDITOR
XDG_DATA_HOME=/opt/gentoo/usr/share
XDG_DATA_DIRS=/opt/gentoo/usr/share
export XDG_DATA_HOME XDG_DATA_DIRS
# set vi:nowrap
Finally, download the bootstrap script from https://gitweb.gentoo.org/repo/proj/prefix.git/plain/scripts/bootstrap-bash.sh and the compiler wrapper from http://nekofiles.irixnet.org/stuart-contrib/portage-prefix/irixmipsprowrapper.tar.gz.
Switch to the portage user with su -, copy the bootstrap script to the ~ directory of portage. Extract the compiler wrapper to /opt/gentoo and then run hash -r. From then on the compiler wrappers will be active. These are controlled by the MIPSPRO_ * variables — MIPSPRO_VERBOSE=1 will result in copious output regarding what the wrapper is doing, and MIPSPRO_DEBUG=1 will show additional debugging information. Additional options are MIPSPRO_WRAPPER (set to 0 to disable the wrapper entirely, which is highly unrecommended!), MIPSPRO_ALLOWNOSTD (to allow -nostdlib and -nostdinc, which generally break builds: default off), MIPSPRO_MANGLE (to add additional optimizations beyond simply setting library paths: default on), MIPSPRO_INJECT (experimental fix for use of GNU attributes: default off), MIPSPRO_PERMISSIVE (to pass unrecognised options to the compiler even though they're likely GNUisms: default on for now), and MIPSPRO_ABORT (when MIPSPRO_PERMISSIVE is set to 0, the wrapper exits with a failure if an unrecognised option is encountered, rather than silently dropping it: default off).
By default the wrapper will automatically detect the platform and target and apply other optimisation options, the defaults are: '-mips4', '-n32', and '-O2' with an Olimit of 8192. These can be overridden with MIPSPRO_ISA, MIPSPRO_ABI, OLIMIT, and MIPSPRO_OPT.
Next, run:
$ chmod 755 bootstrap-prefix.sh
$ STDPATH="$PATH"
$ export PATH="$EPREFIX/tmp/usr/bin:$EPREFIX/tmp/bin:$PATH"
$ ./bootstrap-prefix.sh $EPREFIX tree
There is a flag-o-matic.eclass.patch which may need application here.
$ ./bootstrap-prefix.sh $EPREFIX/tmp make
$ ./bootstrap-prefix.sh $EPREFIX/tmp wget
$ ./bootstrap-prefix.sh $EPREFIX/tmp sed
$ ./bootstrap-prefix.sh $EPREFIX/tmp python
$ ./bootstrap-prefix.sh $EPREFIX/tmp coreutils6
$ ./bootstrap-prefix.sh $EPREFIX/tmp findutils
$ ./bootstrap-prefix.sh $EPREFIX/tmp tar15
$ ./bootstrap-prefix.sh $EPREFIX/tmp patch9
$ ./bootstrap-prefix.sh $EPREFIX/tmp grep
$ ./bootstrap-prefix.sh $EPREFIX/tmp gawk
$ ./bootstrap-prefix.sh $EPREFIX/tmp bash
$ ./bootstrap-prefix.sh $EPREFIX portage
$ hash -r
$ USE="-*" emerge oneshot -v keep-going sed wget bash baselayout-prefix lzma-utils m4 flex bison coreutils findutils tar grep patch gawk make
$ USE="-*" emerge oneshot -v nodeps file
$ FEATURES="-collision-protect" emerge -v --oneshot portage
$ export PATH="$STDPATH"
$ unset STDPATH
$ hash -r
$ rm -r $EPREFIX/tmp/*
$ emerge --sync
$ emerge -uv system
$ emerge -Dev --with-bdeps y system
This will result in a minimal working install system.
Finally, add /opt/portage/usr/bin:/opt/portage/bin
to PATH for this to work.
Warning
As this article derives from things more than 10 years ago, there is no guarantee it'll work.