diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2018-01-28 18:25:52 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2018-01-28 18:25:52 +0100 |
commit | 37be8f73669ddadf2259656f656af5f5c5bc39b9 (patch) | |
tree | 68fea63a95500245869ebac5537dda5c4401490f | |
parent | 164181c1589942d9d1c8e1bf6cbba76974b7e1c7 (diff) | |
download | bootstrap32-37be8f73669ddadf2259656f656af5f5c5bc39b9.tar.xz |
added package descriptions for stage1
added stage1 build script
shellchecked all scripts
-rw-r--r-- | README | 25 | ||||
-rwxr-xr-x | build_cross.sh | 19 | ||||
-rwxr-xr-x | build_stage1.sh | 15 | ||||
-rwxr-xr-x | build_stage1_package.sh | 70 | ||||
-rwxr-xr-x[-rw-r--r--] | create_ca-certificates-utils_shim.sh | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | create_gcc-lib_shim.sh | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | create_glibc_shim.sh | 2 | ||||
-rw-r--r-- | default.conf | 14 | ||||
-rwxr-xr-x | install_host.sh | 12 | ||||
-rw-r--r-- | packages-i486-stage1/.gitkeep | 0 | ||||
-rw-r--r-- | packages-i486-stage1/perl | 1 | ||||
-rw-r--r-- | packages-i486-stage1/template | 8 | ||||
-rw-r--r-- | packages-i486-stage1/uinit | 1 | ||||
-rwxr-xr-x | prepare_stage1_repo.sh | 4 |
14 files changed, 156 insertions, 47 deletions
@@ -144,19 +144,23 @@ su cross ./create_glibc_shim.sh su cross ./create_ca-certificates-utils_shim.sh +# Install stage 1 + +./build_stage1.sh + + + + # TODO FROM HERE: # build packages for the i486-chroot #################################### -All packages we built here are installed with pacman into i486-chroot -and with bsdtar in the toolchains sysroot # the package list ################## -export PATH=/home/cross/x-tools/i486-unknown-linux-gnu/bin:${PATH} # basic packages PACKAGES="iana-etc filesystem linux-api-headers tzdata ncurses readline bash \ @@ -173,7 +177,6 @@ net-tools libmnl elfutils libnfnetlink iptables iproute2 \ libedit openssh \ sysfsutils libidn nettle iputils" # libunwind -# TODO: sort out name clash glibc and glibc-real # for ncurses, readline for bash # attr for acl @@ -202,24 +205,10 @@ libedit sysfsutils libidn" NOPARALLEL_PACKAGE="perl" for p in $PACKAGES; do - # TODO: for some packages, uinit - # yaourt -G $p - asp export $p - cd $p - # TODO: if exists packages32 diff-PKGBUILD, attach at the end - sed -i '/^arch=[^#]*any/!{/^arch=(/s/(/(i486 /}' PKGBUILD - if test $p in $NOPARALLEL_PACKAGE; then - $HOME/build/makepkg-i486 -C --config $HOME/build/makepkg-i486-noparallel.conf --skipchecksums --skippgpcheck --nocheck > $p.log 2>&1 - else - $HOME/build/makepkg-i486 -C --config $HOME/build/makepkg-i486.conf --skipchecksums --skippgpcheck --nocheck > $p.log 2>&1 - fi - tail $p.log - rm -f *debug*.pkg.tar.xz - cp -v *.pkg.tar.xz $STAGE1_CHROOT/packages/i486/. # redo the whole cache rm -rf $STAGE1_CHROOT/var/cache/pacman/pkg/* diff --git a/build_cross.sh b/build_cross.sh index 6689c50..dffb1c4 100755 --- a/build_cross.sh +++ b/build_cross.sh @@ -19,14 +19,14 @@ if test ! -f /etc/sudoers.d/cross; then fi # we need the github keys -if test ! -d $CROSS_HOME/.ssh; then - mkdir $CROSS_HOME/.ssh - chown cross:cross $CROSS_HOME/.ssh +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* +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 @@ -47,7 +47,7 @@ fi 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} + rm -rf $XTOOLS_HOME cp ct-ng.config $CROSS_HOME/.config CPUS=$(nproc) sed -i "s/^CT_PARALLEL_JOBS=.*/CT_PARALLEL_JOBS=$CPUS/" $CROSS_HOME/.config @@ -58,6 +58,5 @@ EOF echo "Done creating the cross compiler." fi -echo -n "Cross-compiler ready: " CROSS_MSG="$($CROSS_HOME/x-tools/${TARGET_ARCH}/bin/${TARGET_ARCH}-gcc --version | head -n 1)" -echo $CROSS_MSG +echo "Cross-compiler ready: $CROSS_MSG" diff --git a/build_stage1.sh b/build_stage1.sh new file mode 100755 index 0000000..33ad94b --- /dev/null +++ b/build_stage1.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +. "./default.conf" + +# build all packages for stage 1 using the cross-compiler +# packages will be installed with pacman into $STAGE1_CHROOT, dependencies +# for cross-compiling packages will be installed with bsdtar into +# the sysroot of the specific cross compiler in $XTOOLS_ARCH + +PACKAGES="iana-etc filesystem tzdata" + +for p in $PACKAGES; do + "$SCRIPT_DIR/build_stage1_package.sh" "$p" +done + diff --git a/build_stage1_package.sh b/build_stage1_package.sh new file mode 100755 index 0000000..dd49693 --- /dev/null +++ b/build_stage1_package.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +. "./default.conf" + +# builds and installs one package for stage 1 + +if test "$(id -u)" = 0; then + sudo -u cross "$0" "$1" + exit 0 +fi + +PACKAGE=$1 + +export PATH="$XTOOLS_ARCH/bin:${PATH}" + +NEEDS_YAOURT=0 +NOPARALLEL_BUILD=0 + +if test ! -f "$STAGE1_CHROOT/packages/$TARGET_CPU/$PACKAGE.pkg.tar.xz"; then + echo "Building package $PACKAGE." + + cd $STAGE1_BUILD || exit 1 + + rm -rf "$PACKAGE" + + # source the package specific configuration + + PACKAGE_CONF="$SCRIPT_DIR/packages-$TARGET_CPU-stage1/$PACKAGE" + if test -f "$PACKAGE_CONF"; then + . "$PACKAGE_CONF" + fi + + # get the package build description + + if test $NEEDS_YAOURT; then + yaourt -G "$PACKAGE" + else + asp export "$PACKAGE" + fi + cd "$PACKAGE" || exit 1 + + # if exists packages32 diff-PKGBUILD, attach at the end + # (we assume, we build only 'core' packages) + DIFF_PKGBUILD="$ARCHLINUX32_PACKAGES/core/$PACKAGE/PKGBUILD" + if test -f "$DIFF_PKGBUILD"; then + cat "$DIFF_PKGBUILD" >> PKGBUILD + fi + + sed -i "/^arch=[^#]*any/!{/^arch=(/s/(/($TARGET_CPU /}" PKGBUILD + + if test $NOPARALLEL_BUILD = 0; then + CPUS=$(nproc) + else + CPUS=1 + fi + sed -i "s@^#MAKEFLAGS=.*@MAKEFLAGS=\"-j$CPUS\"@" $STAGE1_BUILD/makepkg-$TARGET_CPU.conf + + $STAGE1_BUILD/makepkg-$TARGET_CPU -C --config $STAGE1_BUILD/makepkg-$TARGET_CPU.conf \ + --skipchecksums --skippgpcheck --nocheck > "$PACKAGE.log" 2>&1 + RES=$? + + tail "$PACKAGE.log" + + if test $RES = 0; then + rm -f ./*debug*.pkg.tar.xz + cp -v ./*.pkg.tar.xz $STAGE1_CHROOT/packages/$TARGET_CPU/. + fi +fi + +echo "Built package $PACKAGE." diff --git a/create_ca-certificates-utils_shim.sh b/create_ca-certificates-utils_shim.sh index 6026454..2f73102 100644..100755 --- a/create_ca-certificates-utils_shim.sh +++ b/create_ca-certificates-utils_shim.sh @@ -6,16 +6,16 @@ if test ! -f $STAGE1_CHROOT/packages/$TARGET_CPU/ca-certificates-utils-shim-20170307-1-any.pkg.tar.xz; then - cd $STAGE1_BUILD + cd $STAGE1_BUILD || exit 1 rm -rf ca-certificates-utils-shim mkdir ca-certificates-utils-shim - cd ca-certificates-utils-shim + cd ca-certificates-utils-shim || exit 1 mkdir -p pkg/ca-certificates-utils-shim/etc/ssl/certs/ cp /etc/ssl/certs/ca-certificates.crt pkg/ca-certificates-utils-shim/etc/ssl/certs/. - BUILDDATE=`date '+%s'` - size=`du -sk --apparent-size pkg/` + BUILDDATE=$(date '+%s') + size=$(du -sk --apparent-size pkg/) size="$(( ${size%%[^0-9]*} * 1024 ))" cat > pkg/ca-certificates-utils-shim/.PKGINFO <<EOF pkgname = ca-certificates-utils-shim @@ -29,11 +29,11 @@ provides = ca-certificates-utils conflict = ca-certificates-utils EOF - cd pkg/ca-certificates-utils-shim - tar cJvf - .PKGINFO * | xz > ../../ca-certificates-utils-shim-20170307-1-any.pkg.tar.xz - cd ../.. + cd pkg/ca-certificates-utils-shim || exit 1 + tar cJvf - .PKGINFO ./* | xz > ../../ca-certificates-utils-shim-20170307-1-any.pkg.tar.xz + cd ../.. || exit 1 - cp -v *.pkg.tar.xz $STAGE1_CHROOT/packages/$TARGET_CPU/. + cp -v ./*.pkg.tar.xz $STAGE1_CHROOT/packages/$TARGET_CPU/. rm -rf $STAGE1_CHROOT/var/cache/pacman/pkg/* rm -rf $STAGE1_CHROOT/packages/$TARGET_CPU/temp.db* rm -rf $STAGE1_CHROOT/packages/$TARGET_CPU/temp.files* diff --git a/create_gcc-lib_shim.sh b/create_gcc-lib_shim.sh index 5045a45..9b5edcc 100644..100755 --- a/create_gcc-lib_shim.sh +++ b/create_gcc-lib_shim.sh @@ -6,10 +6,10 @@ if test ! -f $STAGE1_CHROOT/packages/$TARGET_CPU/gcc-libs-shim-7.2.0-1-$TARGET_CPU.pkg.tar.xz; then - cd $STAGE1_BUILD + cd $STAGE1_BUILD || exit 1 rm -rf gcc-libs-shim mkdir gcc-libs-shim - cd gcc-libs-shim + cd gcc-libs-shim || exit 1 mkdir -p pkg/gcc-libs-shim/usr/lib cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libgcc_s.so pkg/gcc-libs-shim/usr/lib/. cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libgcc_s.so.1 pkg/gcc-libs-shim/usr/lib/. @@ -21,8 +21,8 @@ if test ! -f $STAGE1_CHROOT/packages/$TARGET_CPU/gcc-libs-shim-7.2.0-1-$TARGET_C ln -s libstdc++.so.6.0.24 pkg/gcc-libs-shim/usr/lib/libstdc++.so.6 ln -s libstdc++.so.6.0.24 pkg/gcc-libs-shim/usr/lib/libstdc++.so - BUILDDATE=`date '+%s'` - size=`du -sk --apparent-size pkg/` + BUILDDATE=$(date '+%s') + size=$(du -sk --apparent-size pkg/) size="$(( ${size%%[^0-9]*} * 1024 ))" cat > pkg/gcc-libs-shim/.PKGINFO <<EOF pkgname = gcc-libs-shim @@ -36,11 +36,11 @@ provides = gcc-libs conflict = gcc-libs EOF - cd pkg/gcc-libs-shim - tar cJvf - .PKGINFO * | xz > ../../gcc-libs-shim-7.2.0-1-$TARGET_CPU.pkg.tar.xz - cd ../.. + cd pkg/gcc-libs-shim || exit 1 + tar cJvf - .PKGINFO ./* | xz > ../../gcc-libs-shim-7.2.0-1-$TARGET_CPU.pkg.tar.xz + cd ../.. || exit 1 - cp -v *.pkg.tar.xz $STAGE1_CHROOT/packages/$TARGET_CPU/. + cp -v ./*.pkg.tar.xz $STAGE1_CHROOT/packages/$TARGET_CPU/. rm -rf $STAGE1_CHROOT/var/cache/pacman/pkg/* rm -rf $STAGE1_CHROOT/packages/$TARGET_CPU/temp.db* rm -rf $STAGE1_CHROOT/packages/$TARGET_CPU/temp.files* diff --git a/create_glibc_shim.sh b/create_glibc_shim.sh index c8ce59d..d79d41f 100644..100755 --- a/create_glibc_shim.sh +++ b/create_glibc_shim.sh @@ -70,7 +70,7 @@ EOF tar cJvf - .PKGINFO * | xz > ../../glibc-shim-2.26-1-$TARGET_CPU.pkg.tar.xz cd ../.. - cp -v *.pkg.tar.xz $STAGE1_CHROOT/packages/$TARGET_CPU/. + cp -v ./*.pkg.tar.xz $STAGE1_CHROOT/packages/$TARGET_CPU/. rm -rf $STAGE1_CHROOT/var/cache/pacman/pkg/* rm -rf $STAGE1_CHROOT/packages/$TARGET_CPU/temp.db* rm -rf $STAGE1_CHROOT/packages/$TARGET_CPU/temp.files* diff --git a/default.conf b/default.conf index 8786157..bb0834f 100644 --- a/default.conf +++ b/default.conf @@ -20,3 +20,17 @@ STAGE1_CHROOT=$CROSS_HOME/$TARGET_CPU-root # the place where we build stage 1 STAGE1_BUILD=$CROSS_HOME/$TARGET_CPU-build + +# git repository for PKGBUILD diffs and patches for the +# i686 architecture +GIT_URL_ARCHLINUX32_PACKAGES=https://github.com/archlinux32/packages.git + +# the packages32 directory (where GIT_URL_ARCHLINUX32_PACKAGES is checked out) +ARCHLINUX32_PACKAGES=$CROSS_HOME/packages32 + +# uncomment to debug scripts +#set -x + +# some default variables, not to be changed +SCRIPT=$(sudo realpath -s "$0") +SCRIPT_DIR=$(dirname "$SCRIPT") diff --git a/install_host.sh b/install_host.sh index 362502a..d531a4b 100755 --- a/install_host.sh +++ b/install_host.sh @@ -28,4 +28,16 @@ pacman --noconfirm --needed -S flex # for a bootable ISO image pacman --noconfirm --needed -S syslinux cdrtools +# some packages come from the AUR +if test "$(grep -c '\[archlinuxfr\]' /etc/pacman.conf)" = 0; then + cat >> /etc/pacman.conf <<EOF +[archlinuxfr] +Server = http://repo.archlinux.fr/\$arch +SigLevel = Optional DatabaseOptional +EOF + + pacman --noconfirm -Syy + pacman --noconfirm -S --needed yaourt +fi + echo "Host ready." diff --git a/packages-i486-stage1/.gitkeep b/packages-i486-stage1/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/packages-i486-stage1/.gitkeep diff --git a/packages-i486-stage1/perl b/packages-i486-stage1/perl new file mode 100644 index 0000000..087b08b --- /dev/null +++ b/packages-i486-stage1/perl @@ -0,0 +1 @@ +NOPARALLEL_BUILD=1 diff --git a/packages-i486-stage1/template b/packages-i486-stage1/template new file mode 100644 index 0000000..26af3c3 --- /dev/null +++ b/packages-i486-stage1/template @@ -0,0 +1,8 @@ +# NEEDS_YAOURT: asp is the default tool to fetch packages, if the +# package is only available in AUR, the set NEEDS_YAOURT=1 +NEEDS_YAOURT=0 + +# NOPARALLEL_BUILD: -j<N> parameter to makepkg will be set to -j +# if NOPARALLEL_PACKAGE=1. The default is to use all avaiable cores +# and set -j<CPUS> +NOPARALLEL_BUILD=0 diff --git a/packages-i486-stage1/uinit b/packages-i486-stage1/uinit new file mode 100644 index 0000000..6818abe --- /dev/null +++ b/packages-i486-stage1/uinit @@ -0,0 +1 @@ +NEEDS_YAOURT=1 diff --git a/prepare_stage1_repo.sh b/prepare_stage1_repo.sh index dcce93b..d7df4e2 100755 --- a/prepare_stage1_repo.sh +++ b/prepare_stage1_repo.sh @@ -64,7 +64,7 @@ if test ! -d $STAGE1_BUILD; then # prepare the build enviroment mkdir $STAGE1_BUILD - cd $STAGE1_BUILD + cd $STAGE1_BUILD || exit 1 # prepare makepkg for building into the i486-chroot cp /usr/bin/makepkg $STAGE1_BUILD/makepkg-i486 @@ -90,7 +90,7 @@ 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 + git clone $GIT_URL_ARCHLINUX32_PACKAGES $CROSS_HOME/packages32 echo "Fetched Archlinux32 diffs for packages." fi |