summaryrefslogtreecommitdiff
path: root/src/stage1
diff options
context:
space:
mode:
authorAndreas Grapentin <andreas@grapentin.org>2018-02-11 21:31:45 +0100
committerAndreas Grapentin <andreas@grapentin.org>2018-02-11 21:31:45 +0100
commite973323773123182b6ba135f5c7d5b4490507139 (patch)
tree005f12e75994247dc1bcdc6fcb7fbbf53e9b2fbe /src/stage1
parent63020fa3aa2c4f703d0df0299aa2f45cecfd55ad (diff)
starting to actually build packages
Diffstat (limited to 'src/stage1')
-rw-r--r--src/stage1/build_from_deptree.sh62
-rw-r--r--src/stage1/ca-certificates-utils-shim.sh4
-rw-r--r--src/stage1/create_chroot.sh2
-rw-r--r--src/stage1/create_makepkg.sh5
-rw-r--r--src/stage1/create_package_tree.sh26
-rw-r--r--src/stage1/gcc-libs-shim.sh4
-rw-r--r--src/stage1/glibc-shim.sh4
-rw-r--r--src/stage1/patches/filesystem.patch0
-rw-r--r--src/stage1/repackage_arch_any.sh60
9 files changed, 77 insertions, 90 deletions
diff --git a/src/stage1/build_from_deptree.sh b/src/stage1/build_from_deptree.sh
index 836a790..f6bfbf7 100644
--- a/src/stage1/build_from_deptree.sh
+++ b/src/stage1/build_from_deptree.sh
@@ -18,7 +18,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
-set -eu
+set -euo pipefail
+
+# set path to include $_target toolchain
+export PATH="/usr/$_target/bin:/usr/$_target/usr/bin:$PATH"
# keep building packages until the deptree is empty
while [ -s "$_deptree" ]; do
@@ -26,30 +29,67 @@ while [ -s "$_deptree" ]; do
_pkgname=$(grep '\[ \]' "$_deptree" | head -n1 | awk '{print $1}')
[ -n "$_pkgname" ] || die "could not resolve cyclic dependencies. exiting."
- _pkgver=$(pacman -Qi $_pkgname | grep '^Version' | awk '{print $3}')
+ _pkgarch=$(pacman -Si $_pkgname | grep '^Architecture' | awk '{print $3}')
+ _pkgver=$(pacman -Si $_pkgname | grep '^Version' | awk '{print $3}')
_pkgdir="$_makepkgdir"/$_pkgname/pkg/$_pkgname
- msg "makepkg: $_pkgname-$_pkgver-$_arch.pkg.tar.xz"
+ [ "x$_pkgarch" == "xany" ] || _pkgarch=$_arch
+
+ msg "makepkg: $_pkgname-$_pkgver-$_pkgarch.pkg.tar.xz"
msg " remaining pkges: $(cat "$_deptree" | wc -l)"
- if [ ! -f "$_makepkgdir"/$_pkgname-$_pkgver-$_arch.pkg.tar.xz ]; then
+ if [ ! -f "$_makepkgdir"/$_pkgname-$_pkgver-$_pkgarch.pkg.tar.xz ]; then
rm -rf "$_makepkgdir"/$_pkgname
mkdir -pv "$_makepkgdir"/$_pkgname
pushd "$_makepkgdir"/$_pkgname >/dev/null
+ if [ "x$_pkgarch" == "xany" ]; then
+ # simply reuse arch=(any) packages
+ pacman -Sw --noconfirm --cachedir . $_pkgname
+ else
+ # acquire the pkgbuild and auxiliary files
+ _libre=https://www.parabola.nu/packages/libre/x86_64/$_pkgname/
+ _core=https://www.archlinux.org/packages/core/x86_64/$_pkgname/
+ _extra=https://www.archlinux.org/packages/extra/x86_64/$_pkgname/
+ _community=https://www.archlinux.org/packages/community/x86_64/$_pkgname/
+ for url in $_libre $_core $_extra $_community; do
+ if ! curl -s $url | grep -iq 'not found'; then
+ src=$(curl -s $url | grep -i 'source files' | cut -d'"' -f2 | sed 's#/tree/#/plain/#')
+ for link in $(curl -sL $src | grep '^ <li><a href' | cut -d"'" -f2 \
+ | sed "s#^#$(echo $src | awk -F/ '{print $3}')#"); do
+ wget -q $link -O $(basename ${link%\?*});
+ done
+ break
+ fi
+ done
+
+ [ -f "$_srcdir"/stage1/patches/$_pkgname.patch ] || die "missing package patch"
+ patch -Np1 -i "$_srcdir"/stage1/patches/$_pkgname.patch
+
+ # enable the target arch explicitly
+ sed -i "s/arch=([^)]*/& $_arch/" PKGBUILD
+
+ # build the package
+ chown -R $SUDO_USER "$_makepkgdir"/$_pkgname
+ sudo -u $SUDO_USER \
+ "$_makepkgdir"/makepkg-$_arch.sh -C --config "$_makepkgdir"/makepkg-$_arch.conf \
+ --skipchecksums --skippgpcheck --nocheck 2>&1 | tee $_pkgname.log
+ fi
+
+ cp -l $_pkgname-$_pkgver-$_pkgarch.pkg.tar.xz "$_makepkgdir"/
popd >/dev/null
# rm -rf "$_makepkgdir"/$_pkgname
fi
-# cp -av "$_makepkgdir"/$_pkgname-$_pkgver-any.pkg.tar.xz "$_chrootdir"/packages/$_arch
-#
-# rm -rf "$_chrootdir"/var/cache/pacman/pkg/*
-# rm -rf "$_chrootdir"/packages/$_arch/repo.{db,files}*
-# repo-add -q -R "$_chrootdir"/packages/$_arch/{repo.db.tar.gz,*.pkg.tar.xz}
-# pacman --noscriptlet --noconfirm --force -dd --config "$_chrootdir"/etc/pacman.conf \
-# -r "$_chrootdir" -Syy $_pkgname
+ cp -av "$_makepkgdir"/$_pkgname-$_pkgver-$_pkgarch.pkg.tar.xz "$_chrootdir"/packages/$_arch
+
+ rm -rf "$_chrootdir"/var/cache/pacman/pkg/*
+ rm -rf "$_chrootdir"/packages/$_arch/repo.{db,files}*
+ repo-add -q -R "$_chrootdir"/packages/$_arch/{repo.db.tar.gz,*.pkg.tar.xz}
+ pacman --noscriptlet --noconfirm --force -dd --config "$_chrootdir"/etc/pacman.conf \
+ -r "$_chrootdir" -Syy $_pkgname
# remove pkg from deptree
sed -i "/^$_pkgname :/d; s/ $_pkgname\b//g" "$_deptree"
diff --git a/src/stage1/ca-certificates-utils-shim.sh b/src/stage1/ca-certificates-utils-shim.sh
index b48098d..047d5ec 100644
--- a/src/stage1/ca-certificates-utils-shim.sh
+++ b/src/stage1/ca-certificates-utils-shim.sh
@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
-set -eu
+set -euo pipefail
_pkgname=ca-certificates-utils-shim
_pkgver=$(pacman -Qi ${_pkgname%-*} | grep '^Version' | awk '{print $3}')
@@ -66,7 +66,7 @@ EOF
# rm -rf "$_makepkgdir"/$_pkgname
fi
-cp -av "$_makepkgdir"/$_pkgname-$_pkgver-$_arch.pkg.tar.xz "$_chrootdir"/packages/$_arch
+cp -alv "$_makepkgdir"/$_pkgname-$_pkgver-$_arch.pkg.tar.xz "$_chrootdir"/packages/$_arch
rm -rf "$_chrootdir"/var/cache/pacman/pkg/*
rm -rf "$_chrootdir"/packages/$_arch/repo.{db,files}*
diff --git a/src/stage1/create_chroot.sh b/src/stage1/create_chroot.sh
index 739a069..e8cc776 100644
--- a/src/stage1/create_chroot.sh
+++ b/src/stage1/create_chroot.sh
@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
-set -eu
+set -euo pipefail
msg "preparing a skeleton $_arch chroot"
diff --git a/src/stage1/create_makepkg.sh b/src/stage1/create_makepkg.sh
index 0440dac..f616d78 100644
--- a/src/stage1/create_makepkg.sh
+++ b/src/stage1/create_makepkg.sh
@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
-set -eu
+set -euo pipefail
msg "preparing a $_arch cross makepkg environment"
@@ -37,10 +37,11 @@ if [ ! -f "$_makepkgdir"/makepkg-$_arch.sh ]; then
cp -av tmp/usr/bin/makepkg "$_makepkgdir"/makepkg-$_arch.sh
# patch run_pacman in makepkg, we cannot pass the pacman root to it as parameter ATM
- sed -i "/\"\$PACMAN_PATH\"/a --config $_chrootdir/etc/pacman.conf -r $_chrootdir" \
+ sed -i "s#\"\$PACMAN_PATH\"#& --config $_chrootdir/etc/pacman.conf -r $_chrootdir#" \
"$_makepkgdir"/makepkg-$_arch.sh
popd >/dev/null
+
# rm -rf "$_makepkgdir"/makepkg-$_arch
fi
diff --git a/src/stage1/create_package_tree.sh b/src/stage1/create_package_tree.sh
index 4d5fdb3..467befd 100644
--- a/src/stage1/create_package_tree.sh
+++ b/src/stage1/create_package_tree.sh
@@ -18,33 +18,39 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
-set -eu
+set -euo pipefail
msg "creating transitive dependency tree for $_groups"
if [ ! -f "$_deptree" ]; then
declare -A _tree
- _frontier=($(pacman -Sg $_groups | cut -d' ' -f2))
+ _frontier=($(pacman -Sg $_groups | awk '{print $2}' ))
while [ ${#_frontier[@]} -gt 0 ]; do
# pop pkg from frontier
- _pkg=$(echo ${_frontier[0]})
+ _pkgname=$(echo ${_frontier[0]})
_frontier=("${_frontier[@]:1}")
+
# if seen before, skip, otherwise create entry in dependency tree
- [[ -v _tree[$_pkg] ]] && continue
- _tree[$_pkg]=""
+ [[ -v _tree[$_pkgname] ]] && continue
+ _tree[$_pkgname]=""
+
+ _pkgdeps=$(pacman -Si $_pkgname | grep '^Depends' | cut -d':' -f2 | sed 's/None//')
+
# iterate dependencies for pkg
- _deps="$(echo $(pacman -Si $_pkg | grep '^Depends' | cut -d':' -f2 | sed 's/None//'))"
- for dep in $_deps; do
+ for dep in $_pkgdeps; do
# translate dependency string to actual package
- realdep=$(yes n | pacman --confirm -Sd "$dep" 2>&1 | grep '^Packages' \
- | cut -d' ' -f3 | rev | cut -d'-' -f3- | rev)
+ realdep=$(pacman --noconfirm -Sw "$dep" | grep '^Packages' | awk '{print $3}')
+ realdep=${realdep%-*-*}
# add dependency to tree and frontier
- _tree[$_pkg]="${_tree[$_pkg]} $realdep"
+ _tree[$_pkgname]="${_tree[$_pkgname]} $realdep"
_frontier+=($realdep)
done
done
+ # add some additional build-order dependencies by hand
+ _tree[libutil-linux]="${_tree[libutil-linux]}pam libcap-ng ncurses "
+
# log package dependency tree
truncate -s0 "$_deptree".FULL
for i in "${!_tree[@]}"; do
diff --git a/src/stage1/gcc-libs-shim.sh b/src/stage1/gcc-libs-shim.sh
index 2a48da3..ce59e0c 100644
--- a/src/stage1/gcc-libs-shim.sh
+++ b/src/stage1/gcc-libs-shim.sh
@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
-set -eu
+set -euo pipefail
_pkgname=gcc-libs-shim
_pkgver=$(pacman -Qi $_target-gcc | grep '^Version' | awk '{print $3}')
@@ -66,7 +66,7 @@ EOF
# rm -rf "$_makepkgdir"/$_pkgname
fi
-cp -av "$_makepkgdir"/$_pkgname-$_pkgver-$_arch.pkg.tar.xz "$_chrootdir"/packages/$_arch
+cp -alv "$_makepkgdir"/$_pkgname-$_pkgver-$_arch.pkg.tar.xz "$_chrootdir"/packages/$_arch
rm -rf "$_chrootdir"/var/cache/pacman/pkg/*
rm -rf "$_chrootdir"/packages/$_arch/repo.{db,files}*
diff --git a/src/stage1/glibc-shim.sh b/src/stage1/glibc-shim.sh
index 49009f9..41192d6 100644
--- a/src/stage1/glibc-shim.sh
+++ b/src/stage1/glibc-shim.sh
@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
-set -eu
+set -euo pipefail
_pkgname=glibc-shim
_pkgver=$(pacman -Qi $_target-glibc | grep '^Version' | awk '{print $3}')
@@ -75,7 +75,7 @@ EOF
# rm -rf "$_makepkgdir"/$_pkgname
fi
-cp -av "$_makepkgdir"/$_pkgname-$_pkgver-$_arch.pkg.tar.xz "$_chrootdir"/packages/$_arch
+cp -alv "$_makepkgdir"/$_pkgname-$_pkgver-$_arch.pkg.tar.xz "$_chrootdir"/packages/$_arch
rm -rf "$_chrootdir"/var/cache/pacman/pkg/*
rm -rf "$_chrootdir"/packages/$_arch/repo.{db,files}*
diff --git a/src/stage1/patches/filesystem.patch b/src/stage1/patches/filesystem.patch
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/stage1/patches/filesystem.patch
diff --git a/src/stage1/repackage_arch_any.sh b/src/stage1/repackage_arch_any.sh
deleted file mode 100644
index 37b08b0..0000000
--- a/src/stage1/repackage_arch_any.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/bash
- ##############################################################################
- # parabola-riscv64-bootstrap #
- # #
- # Copyright (C) 2018 Andreas Grapentin #
- # #
- # This program is free software: you can redistribute it and/or modify #
- # it under the terms of the GNU General Public License as published by #
- # the Free Software Foundation, either version 3 of the License, or #
- # (at your option) any later version. #
- # #
- # This program is distributed in the hope that it will be useful, #
- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
- # GNU General Public License for more details. #
- # #
- # You should have received a copy of the GNU General Public License #
- # along with this program. If not, see <http://www.gnu.org/licenses/>. #
- ##############################################################################
-
-set -eu
-
-_packages=$(cat "$_builddir"/DEPTREE | cut -d' ' -f1)
-
-# we can simply repackage anything with arch=('any'), no compilation needed.
-for _pkgname in $_packages; do
- _pkgarch=$(pacman -Si $_pkgname | grep '^Architecture' | awk '{print $3}')
- [ "x$_pkgarch" == "xany" ] || continue
-
- _pkgver=$(pacman -Qi $_pkgname | grep '^Version' | awk '{print $3}')
- _pkgdir="$_makepkgdir"/$_pkgname/pkg/$_pkgname
-
- msg "makepkg: $_pkgname-$_pkgver-any.pkg.tar.xz"
- msg " remaining pkges: $(cat "$_deptree" | wc -l)"
-
- if [ ! -f "$_makepkgdir"/$_pkgname-$_pkgver-any.pkg.tar.xz ]; then
- rm -rf "$_makepkgdir"/$_pkgname
- mkdir -pv "$_makepkgdir"/$_pkgname
- pushd "$_makepkgdir"/$_pkgname >/dev/null
-
- # download the package
- pacman -Sw --noconfirm --cachedir . $_pkgname
- cp $_pkgname-$_pkgver-any.pkg.tar.xz "$_makepkgdir"/
-
- popd >/dev/null
-
- # rm -rf "$_makepkgdir"/$_pkgname
- fi
-
- cp -av "$_makepkgdir"/$_pkgname-$_pkgver-any.pkg.tar.xz "$_chrootdir"/packages/$_arch
-
- rm -rf "$_chrootdir"/var/cache/pacman/pkg/*
- rm -rf "$_chrootdir"/packages/$_arch/repo.{db,files}*
- repo-add -q -R "$_chrootdir"/packages/$_arch/{repo.db.tar.gz,*.pkg.tar.xz}
- pacman --noscriptlet --noconfirm --force -dd --config "$_chrootdir"/etc/pacman.conf \
- -r "$_chrootdir" -Syy $_pkgname
-
- # remove pkg from deptree
- sed -i "/^$_pkgname :/d; s/ $_pkgname / /" "$_deptree"
-done