summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Grapentin <andreas@grapentin.org>2018-02-10 10:36:07 +0100
committerAndreas Grapentin <andreas@grapentin.org>2018-02-10 10:36:07 +0100
commitdd313cff902916d465a0c43adfce2873fe5ad50c (patch)
tree22f89f67deb265e453594f766df5dbd47cefa402
parentb06ab9385ed56f73e69af1f9c60944a4b930aa48 (diff)
building dependency tree on demand, preparing to repackage arch=(any)
-rwxr-xr-xsrc/stage1.sh9
-rw-r--r--src/stage1/create_makepkg.sh26
-rw-r--r--src/stage1/create_package_tree.sh58
-rw-r--r--src/stage1/repackage_arch_any.sh23
4 files changed, 79 insertions, 37 deletions
diff --git a/src/stage1.sh b/src/stage1.sh
index 66f644a..e8c4563 100755
--- a/src/stage1.sh
+++ b/src/stage1.sh
@@ -20,9 +20,6 @@
set -eu
-# create base package tree
-# . src/stage1/create_package_tree.sh
-
_chrootdir="$_builddir"/$_arch-root
_makepkgdir="$_builddir"/$_arch-makepkg
@@ -37,3 +34,9 @@ _shims="gcc-libs glibc ca-certificates-utils"
for s in $_shims; do
. src/stage1/$s-shim.sh
done
+
+# create base package tree
+. src/stage1/create_package_tree.sh
+
+# simply repackage anything with arch=('any')
+. src/stage1/repackage_arch_any.sh
diff --git a/src/stage1/create_makepkg.sh b/src/stage1/create_makepkg.sh
index 3e09197..0440dac 100644
--- a/src/stage1/create_makepkg.sh
+++ b/src/stage1/create_makepkg.sh
@@ -22,15 +22,27 @@ set -eu
msg "preparing a $_arch cross makepkg environment"
-# create required directories
-mkdir -pv "$_makepkgdir"
+if [ ! -f "$_makepkgdir"/makepkg-$_arch.sh ]; then
+ # create required directories
+ mkdir -pv "$_makepkgdir"/makepkg-$_arch
+ pushd "$_makepkgdir"/makepkg-$_arch >/dev/null
-# create a modified makepkg
-cp -v /usr/bin/makepkg "$_makepkgdir"/makepkg-$_arch
+ _pkgver=$(pacman -Qi pacman | grep '^Version' | cut -d':' -f2 | tr -d [:space:])
-# 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" \
- "$_makepkgdir"/makepkg-$_arch
+ # fetch pacman package to excract makepkg
+ pacman -Sw --noconfirm --cachedir . pacman
+ mkdir tmp && bsdtar -C tmp -xf pacman-$_pkgver-*.pkg.tar.xz
+
+ # install makepkg
+ 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" \
+ "$_makepkgdir"/makepkg-$_arch.sh
+
+ popd >/dev/null
+ # rm -rf "$_makepkgdir"/makepkg-$_arch
+fi
# create temporary makepkg.conf
cat > "$_makepkgdir"/makepkg-$_arch.conf << EOF
diff --git a/src/stage1/create_package_tree.sh b/src/stage1/create_package_tree.sh
index b4fdec4..f93b85c 100644
--- a/src/stage1/create_package_tree.sh
+++ b/src/stage1/create_package_tree.sh
@@ -22,33 +22,37 @@ set -eu
msg "creating transitive dependency tree for $_groups"
-declare -A _tree
-
-_frontier=($(pacman -Sg $_groups | cut -d' ' -f2))
-while [ ${#_frontier[@]} -gt 0 ]; do
- # pop pkg from frontier
- _pkg=$(echo ${_frontier[0]})
- _frontier=("${_frontier[@]:1}")
- # if seen before, skip, otherwise create entry in dependency tree
- [[ -v _tree[$_pkg] ]] && continue
- _tree[$_pkg]=""
- # iterate dependencies for pkg
- _deps="$(echo $(pacman -Si $_pkg | grep '^Depends' | cut -d':' -f2 | sed 's/None//'))"
- for dep in $_deps; 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)
- # add dependency to tree and frontier
- _tree[$_pkg]="${_tree[$_pkg]} $realdep"
- _frontier+=($realdep)
+_deptree="$_builddir"/DEPTREE
+
+if [ ! -f "$_deptree" ]; then
+ declare -A _tree
+
+ _frontier=($(pacman -Sg $_groups | cut -d' ' -f2))
+ while [ ${#_frontier[@]} -gt 0 ]; do
+ # pop pkg from frontier
+ _pkg=$(echo ${_frontier[0]})
+ _frontier=("${_frontier[@]:1}")
+ # if seen before, skip, otherwise create entry in dependency tree
+ [[ -v _tree[$_pkg] ]] && continue
+ _tree[$_pkg]=""
+ # iterate dependencies for pkg
+ _deps="$(echo $(pacman -Si $_pkg | grep '^Depends' | cut -d':' -f2 | sed 's/None//'))"
+ for dep in $_deps; 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)
+ # add dependency to tree and frontier
+ _tree[$_pkg]="${_tree[$_pkg]} $realdep"
+ _frontier+=($realdep)
+ done
done
-done
-# log package dependency tree
-_deptree="$_builddir"/DEPTREE
-echo "" > "$_deptree"
-for i in "${!_tree[@]}"; do
- echo " ${i} : [${_tree[$i]} ]" >> "$_deptree"
-done
-echo "total pkges: ${#_tree[@]}"
+ # log package dependency tree
+ echo "" > "$_deptree"
+ for i in "${!_tree[@]}"; do
+ echo " ${i} : [${_tree[$i]} ]" >> "$_deptree"
+ done
+fi
+
+echo "total pkges: $(cat "$_deptree" | wc -l)"
diff --git a/src/stage1/repackage_arch_any.sh b/src/stage1/repackage_arch_any.sh
new file mode 100644
index 0000000..4629908
--- /dev/null
+++ b/src/stage1/repackage_arch_any.sh
@@ -0,0 +1,23 @@
+#!/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
+
+