Created
October 30, 2017 09:13
-
-
Save bellflower2015/0d12209eafa2928eec68b6a962729807 to your computer and use it in GitHub Desktop.
さくらのレンタルサーバ (FreeBSD-9.1-RELEASE) にて、ユーザー権限で ports を利用できるようにする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
PSPKGDIR=${PSPKGDIR:-$HOME/.pspkg} | |
PSPKGRC=$HOME/.pspkgrc | |
[ ! -e $PSPKGRC ] && cat << 'EOD' > $PSPKGRC | |
export PREFIX=$PSPKGDIR | |
export INSTALL_AS_USER=yes | |
#export DEPENDS_TARGET='package' | |
export LOCALBASE=$PREFIX | |
export ETCDIR=$PREFIX/etc | |
export PORTSDIR=$PREFIX/ports | |
export MAKESYSPATH=$PORTSDIR/Mk.fix:/usr/share/mk:$PORTSDIR/Mk | |
export PKG_DBDIR=$PREFIX/var/db/pkg | |
export PORT_DBDIR=$PREFIX/var/db/pkg | |
export PKGTOOLS_CONF=$ETCDIR/pkgtools.conf | |
export SRCCONF=$ETCDIR/src.conf | |
export PKG_CONFIG_PATH=$PREFIX/libdata/pkgconfig:/usr/local/libdata/pkgconfig | |
export BINOWN=`whoami` | |
export BINGRP=`id -G -n $BINOWN` | |
export SHAREOWN=$BINOWN | |
export SHAREGRP=$BINGRP | |
export MANOWN=$BINOWN | |
export MANGRP=$BINGRP | |
export BINMODE=755 | |
export SHAREMODE=644 | |
export MANMODE=644 | |
export SU_CMD="sh -c" | |
export MAKECONF=$ETCDIR/make.conf | |
export __MAKE_CONF=$ETCDIR/make.conf | |
export LDCONFIG="ldconfig -i -f $PREFIX/var/run/ld-elf.so.hints" | |
export LD_LIBRARY_PATH=$PREFIX/lib:$PREFIX/lib/nss | |
export LD_RUN_PATH=$PREFIX/lib:$PREFIX/lib/nss | |
export PATH=$PREFIX/sbin:$PREFIX/bin:$PATH | |
export MANPATH_MAP=$PREFIX/bin:$PREFIX/man | |
EOD | |
[ -r $PSPKGRC ] && . $PSPKGRC | |
LOCALSRCDIR=$PSPKGDIR/local/src | |
mkdir -p $LOCALSRCDIR | |
cd $LOCALSRCDIR | |
curl -LO http://ftp.gnu.org/gnu/m4/m4-1.4.18.tar.gz | |
tar xzf m4-1.4.18.tar.gz | |
cd m4-1.4.18 | |
./configure --prefix=$PSPKGDIR | |
make | |
make install | |
cd $LOCALSRCDIR | |
curl -LO http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz | |
tar xzf autoconf-2.69.tar.gz | |
cd autoconf-2.69 | |
./configure --prefix=$PSPKGDIR | |
make | |
make install | |
cd $LOCALSRCDIR | |
curl -LO http://ftp.gnu.org/gnu/automake/automake-1.15.1.tar.gz | |
tar xzf automake-1.15.1.tar.gz | |
cd automake-1.15.1 | |
./configure --prefix=$PSPKGDIR | |
make | |
make install | |
cd $LOCALSRCDIR | |
curl -LO http://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.gz | |
tar xzf libtool-2.4.6.tar.gz | |
cd libtool-2.4.6 | |
./configure --prefix=$PSPKGDIR | |
make | |
make install | |
cd $LOCALSRCDIR | |
curl -LO http://ftp.netbsd.org/pub/NetBSD/misc/sjg/bmake-20170812.tar.gz | |
tar xzf bmake-20170812.tar.gz | |
cd bmake | |
./configure --prefix=$PSPKGDIR | |
sh ./make-bootstrap.sh | |
make install | |
ln -s $PSPKGDIR/bin/bmake $PSPKGDIR/bin/make | |
LOCALBASE=$PSPKGDIR | |
LOGDIR=$LOCALBASE/var/log | |
ETCDIR=$LOCALBASE/etc | |
PORTSNAPCONF=$ETCDIR/portsnap.conf | |
MAKECONF=$ETCDIR/make.conf | |
WORKDIR=$LOCALBASE/var/db/portsnap | |
PORTSDIR=$LOCALBASE/ports | |
RUNDIR=$LOCALBASE/var/run | |
PACKAGEDIR=$LOCALBASE/packages | |
MKDIR_DIRS=($LOGDIR $ETCDIR $WORKDIR $RUNDIR $PACKAGEDIR) | |
for dir in ${MKDIR_DIRS[@]}; do | |
[ ! -e $dir ] && mkdir -p $dir | |
done | |
[ ! -e $PORTSNAPCONF ] && cat << EOD > $PORTSNAPCONF | |
WORKDIR=$WORKDIR | |
PORTSDIR=$PORTSDIR | |
SERVERNAME=portsnap.FreeBSD.org | |
KEYPRINT=9b5feee6d69f170e3dd0a2c8e469ddbd64f13f978f2f3aede40c98633216c330 | |
INDEX INDEX-7 DESCRIBE.7 | |
INDEX INDEX-8 DESCRIBE.8 | |
INDEX INDEX-9 DESCRIBE.9 | |
REFUSE arabic chinese french german hebrew hungarian korean polish portuguese | |
REFUSE russian ukrainian vietnamese | |
EOD | |
[ ! -e $MAKECONF ] && cat << 'EOD' > $MAKECONF | |
MYMAKECONF=yes | |
WITH_PKGNG=yes | |
ALLOW_UNSUPPORTED_SYSTEM=yes | |
WARNING_WAIT=0 | |
NO_WARNING_PKG_INSTALL_EOL=yes | |
MAKE_JOBS_UNSAFE=yes | |
FORCE_PKG_REGISTER=yes | |
PERL5_DEFAULT=5.22 | |
DEFAULT_VERSIONS+=perl5=5.22 | |
OPTIONS_UNSET=X11 GUI DOCS EXAMPLES | |
editors_vim_SET=CONSOLE | |
editors_vim_UNSET=GTK2 | |
security_ca_root_nss_UNSET=ETCSYMLINK | |
devel_git_UNSET=GITWEB | |
EOD | |
portsnap -f $PORTSNAPCONF fetch && portsnap -f $PORTSNAPCONF extract && portsnap -f $PORTSNAPCONF update | |
if [ -e $PORTSDIR/Mk/bsd.port.mk ]; then | |
mv $PORTSDIR/Mk/bsd.port.mk $PORTSDIR/Mk/bsd.port.mk.orig | |
cat $PORTSDIR/Mk/bsd.port.mk.orig | perl -pe 's/^FreeBSD_MAINTAINER=/\.if !defined\(MYMAKECONF\)\n\. sinclude "\$\{PREFIX\}\/etc\/make\.conf\"\n\.endif\n\nFreeBSD_MAINTAINER=/' > $PORTSDIR/Mk/bsd.port.mk | |
fi | |
if [ -e /usr/share/mk/sys.mk ]; then | |
mkdir $PORTSDIR/Mk.fix | |
cp /usr/share/mk/sys.mk $PORTSDIR/Mk.fix/ | |
sed -i -e "s|^.WARN: dirsyntax|#.WARN: dirsyntax|" $PORTSDIR/Mk.fix/sys.mk | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment