Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
voidstrap.sh
#!/bin/sh
# voidstrap - bootstrap xbps from any *nix
# author: pancake - 2013
if [ -z "$1" ]; then
echo "Usage: voidstrap.sh /path/to/new/root"
exit 1
fi
VOIDROOT="$1"
VOIDPKG=base-chroot
#VOIDPKG=base-system
[ ! "`echo $VOIDROOT | cut -c 1`" = / ] && \
VOIDROOT="${PWD}/${VOIDROOT}"
makejobs="-j4"
if [ -z "${HOME}" ]; then
HOME=~
fi
S="${HOME}/.voidstrap"
export LD_LIBRARY_PATH=$S/prefix/lib
export PATH=$S/prefix/bin:$S/prefix/usr/sbin/:$PATH
export CFLAGS=-I$S/prefix/include
export LDFLAGS=-L$S/prefix/lib
export PKG_CONFIG_PATH="$S/prefix/lib/pkgconfig"
echo S=$S
mkdir -p $S
cd $S
vers="0.26.2_1"
arch=""
case "`uname -sm`" in
"Linux armv6l")
arch=armv6l
;;
"Linux x86_64")
arch=x86_64
;;
"Linux i686"|"Linux i386")
arch=i686
;;
esac
if [ -n "$arch" ]; then
if [ ! -f prefix/usr/sbin/xbps-install.static ]; then
wget -c http://xbps.nopcode.org/repos/current/xbps-static-$vers.$arch.xbps
if [ $? = 0 ]; then
cat > xbps.conf <<EOF
repositories = {
http://xbps.nopcode.org/repos/current,
#http://xbps.nopcode.org/repos/current/nonfree
}
EOF
mkdir -p prefix
tar xJvf xbps-static*.xbps -C prefix
fi
fi
xbps-install.static -Sy -C xbps.conf -r $VOIDROOT $VOIDPKG
mkdir -p $VOIDROOT/etc/xbps
cp -f xbps.conf $VOIDROOT/etc/xbps/xbps.conf
cp -f /bin/true $VOIDROOT/usr/bin/install-info # HACK
exec xbps-install.static -Sy -C xbps.conf -r $VOIDROOT $VOIDPKG
fi
function build() { (
K="$1"
U="$2"
echo ======
echo = $K
echo = $U
echo ======
if [ ! -e $K/configure ]; then
echo "GO DOWN $U/$K.tar.gz"
wget -c $U/$K.tar.gz || exit 1
tar xzvf $K.tar.gz || exit 1
fi
if [ ! -e $K/__install_done ]; then
cd $K
./configure --prefix=$S/prefix || exit 1
make ${makejobs} || exit 1
make install || exit 1
:> __install_done
fi
) }
build confuse-2.7 http://savannah.nongnu.org/download/confuse
build libiconv-1.14 http://ftp.gnu.org/pub/gnu/libiconv
build zlib-1.2.7 http://zlib.net
build libarchive-3.1.2 http://www.libarchive.org/downloads
build openssl-1.0.1e http://www.openssl.org/source
(
if [ ! -e xbps/configure ]; then
git clone git://github.com/xtraeme/xbps.git || exit 1
fi
cd xbps
if [ ! -f configure.orig ]; then
mv configure configure.orig
cat configure.orig | sed -e s,'^XCC.*','XCC="$CC $CFLAGS $CPPFLAGS $LDFLAGS"',g > configure
chmod +x configure
fi
./configure --pkgconfigdir=$S/prefix/lib/pkgconfig --prefix=$S/prefix || exit 1
make ${makejobs} || exit 1
make install || exit 1
)
xbps-install -r $VOIDROOT $VOIDPKG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment