summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README14
-rwxr-xr-xbuild_cross.sh17
-rw-r--r--default.conf5
-rwxr-xr-xprepare_stage1_repo.sh38
4 files changed, 47 insertions, 27 deletions
diff --git a/README b/README
index 63a1703..0b8c205 100644
--- a/README
+++ b/README
@@ -119,19 +119,15 @@ cp .config ct-ng.config
su cross ./prepare_stage1_repo.sh
+#########
+# PHASE 1
+#########
+Build stage1 with the cross-compiler and modified PKGBUILDs and patches
+into $STAGE1_CHROOT
# TODO FROM HERE:
-# get the Archlinux32 diffs
-###########################
-
-cd $HOME
-git clone git@github.com:archlinux32/packages.git packages32
-
-#########
-# PHASE 1
-#########
# package shims
################
diff --git a/build_cross.sh b/build_cross.sh
index f40ce98..6689c50 100755
--- a/build_cross.sh
+++ b/build_cross.sh
@@ -18,6 +18,17 @@ if test ! -f /etc/sudoers.d/cross; then
echo "cross ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/cross
fi
+# we need the github keys
+if test ! -d $CROSS_HOME/.ssh; then
+ mkdir $CROSS_HOME/.ssh
+ chown cross:cross $CROSS_HOME/.ssh
+fi
+if test ! -f $CROSS_HOME/.ssh/id_rsa.pub; then
+ cp $HOME/.ssh/id_rsa.pub $CROSS_HOME/.ssh/.
+ cp $HOME/.ssh/id_rsa $CROSS_HOME/.ssh/.
+ chown cross:cross $CROSS_HOME/.ssh/id_rsa*
+fi
+
if test ! -x /usr/local/bin/ct-ng; then
echo "Installing crosstool-ng:"
su - cross <<EOF
@@ -34,8 +45,8 @@ EOF
echo "Done crosstool-ng."
fi
-if test ! -x $CROSS_HOME/x-tools/i486-unknown-linux-gnu/bin/i486-unknown-linux-gnu-gcc; then
- echo "Building cross compiler for i486-unknown-linux-gnu-gcc:"
+if test ! -x $CROSS_HOME/x-tools/${TARGET_ARCH}/bin/${TARGET_ARCH}-gcc; then
+ echo "Building cross compiler for ${TARGET_ARCH}=gcc:"
rm -rf $CROSS_HOME/{x-tools,.build,build.log,.wget-hsts,.config,.config.old}
cp ct-ng.config $CROSS_HOME/.config
CPUS=$(nproc)
@@ -48,5 +59,5 @@ EOF
fi
echo -n "Cross-compiler ready: "
-CROSS_MSG="$($CROSS_HOME/x-tools/i486-unknown-linux-gnu/bin/i486-unknown-linux-gnu-gcc --version | head -n 1)"
+CROSS_MSG="$($CROSS_HOME/x-tools/${TARGET_ARCH}/bin/${TARGET_ARCH}-gcc --version | head -n 1)"
echo $CROSS_MSG
diff --git a/default.conf b/default.conf
index 9ca43dd..20f5972 100644
--- a/default.conf
+++ b/default.conf
@@ -1,5 +1,8 @@
# configuration
+# target architecture
+TARGET_ARCH=i486-unknown-linux-gnu
+
# where to build the cross compiler
CROSS_HOME=/home/cross
@@ -9,3 +12,5 @@ XTOOLS_HOME=$CROSS_HOME/x-tools
# the chroot of stage 1
STAGE1_CHROOT=$CROSS_HOME/i486-root
+# the place where we build stage 1
+STAGE1_BUILD=$CROSS_HOME/build
diff --git a/prepare_stage1_repo.sh b/prepare_stage1_repo.sh
index 882c431..b93635d 100755
--- a/prepare_stage1_repo.sh
+++ b/prepare_stage1_repo.sh
@@ -2,13 +2,9 @@
. "./default.conf"
-set -x
-
# prepare the i486-chroot for stage 1
# prepare pacman in i486-chroot
-sudo rm -rf $STAGE1_CHROOT
-
if test ! -d $STAGE1_CHROOT; then
# create and initialize a new i486 chroot in $STAGE1_CHROOT
@@ -61,28 +57,40 @@ EOF
sudo pacman --config $STAGE1_CHROOT/etc/pacman.conf -r $STAGE1_CHROOT -Syyu
pacman --config $STAGE1_CHROOT/etc/pacman.conf -r $STAGE1_CHROOT -Q
+fi
- # prepare the build enviroment
+if test ! -d $STAGE1_BUILD; then
- mkdir $HOME/build
- cd $HOME/build
+ # prepare the build enviroment
+
+ mkdir $STAGE1_BUILD
+ cd $STAGE1_BUILD
# prepare makepkg for building into the i486-chroot
-
- cp /usr/bin/makepkg $HOME/build/makepkg-i486
+ cp /usr/bin/makepkg $STAGE1_BUILD/makepkg-i486
# patch run_pacman in makepkg, we cannot pass the pacman root to it as parameter ATM
+
sed -i "s@\"\$PACMAN_PATH\"@\"\$PACMAN_PATH\" --config $STAGE1_CHROOT/etc/pacman.conf -r $STAGE1_CHROOT@" makepkg-i486
+ # prepare a configuration for building the packages with makepkg
+ # fitting to the destination architecture
+
cp /etc/makepkg.conf makepkg-i486.conf
- sed -i 's@^CARCH=.*@CARCH="i486"@' makepkg-i486.conf
- sed -i 's@^CHOST=.*@CHOST="i486-unknown-linux-gnu"@' makepkg-i486.conf
- sed -i 's@^#MAKEFLAGS=.*@MAKEFLAGS="-j20"@' makepkg-i486.conf
- sed -i 's@-march=x86-64 -mtune=generic @@' makepkg-i486.conf
+ sed -i "s@^CARCH=.*@CARCH=\"i486\"@" makepkg-i486.conf
+ sed -i "s@^CHOST=.*@CHOST=\"${TARGET_ARCH}\"@" makepkg-i486.conf
+ CPUS=$(nproc)
+ sed -i "s@^#MAKEFLAGS=.*@MAKEFLAGS=\"-j$CPUS\"@" makepkg-i486.conf
+ sed -i "s@-march=x86-64 -mtune=generic @-march=i486 @" makepkg-i486.conf
echo "Prepared the stage 1 build environment."
-
fi
+if test ! -d $CROSS_HOME/packages32; then
+
+ # get packages repo from Archlinux32 for the diffs
-
+ git clone git@github.com:archlinux32/packages.git $CROSS_HOME/packages32
+
+ echo "Fetched Archlinux32 diffs for packages."
+fi