summaryrefslogtreecommitdiff
path: root/src/stage4/makepkg.sh
blob: 602c238a27b998382ad3071480013caed3098aaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/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/>.   #
 ##############################################################################

prepare_stage4_makepkg() {
  mkdir -p "$BUILDDIR"/config

  cat > "$BUILDDIR"/config/pacman-bootstrap.conf << EOF
[options]
Architecture = $CARCH
[libre]
Server = file://$TOPBUILDDIR/stage4/packages/\$repo/os/\$arch
[core]
Server = file://$TOPBUILDDIR/stage4/packages/\$repo/os/\$arch
[extra]
Server = file://$TOPBUILDDIR/stage4/packages/\$repo/os/\$arch
[community]
Server = file://$TOPBUILDDIR/stage4/packages/\$repo/os/\$arch
[native]
Server = file://$TOPBUILDDIR/stage3/packages/\$arch
EOF

  cat > "$BUILDDIR"/config/pacman.conf << EOF
[options]
Architecture = $CARCH
[libre]
Server = file:///repos/\$repo/os/\$arch
[core]
Server = file:///repos/\$repo/os/\$arch
[extra]
Server = file:///repos/\$repo/os/\$arch
[community]
Server = file:///repos/\$repo/os/\$arch
[native]
Server = file:///native/\$arch
EOF

  cat "$SRCDIR"/makepkg.conf.in > "$BUILDDIR"/config/makepkg.conf
  cat >> "$BUILDDIR"/config/makepkg.conf << EOF
CARCH="$CARCH"
CHOST="$CHOST"
CFLAGS="${PLATFORM_CFLAGS[*]} -O2 -pipe -fstack-protector-strong -fno-plt"
CXXFLAGS="${PLATFORM_CFLAGS[*]} -O2 -pipe -fstack-protector-strong -fno-plt"
MAKEFLAGS="-j$(($(nproc) + 1))"
EOF

  local repo
  for repo in libre core extra community; do
    local repodir="$PKGDEST/../$repo/os/$CARCH"
    check_repo "$repodir" "$repo" || make_repo "$repodir" "$repo"
  done

  # patch libremakepkg to update config.sub/config.guess
  cat "$(command -v libremakepkg)" > "$BUILDDIR/libremakepkg.sh"
  chmod +x "$BUILDDIR/libremakepkg.sh"

  if [ "x${REGEN_CONFIG_FRAGMENTS:-no}" == "xyes" ]; then
	  local url="https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain"
    sed -i "/Boring\\/mundane/i \\
update_config_fragments() {\\
	find \$1/build -iname 'config*.sub' -print -exec curl \"$url;f=config.sub;hb=HEAD\" -o {} \\\\;\\
	find \$1/build -iname 'config*.guess' -print -exec curl \"$url;f=config.guess;hb=HEAD\" -o {} \\\\;\\
}\\
hook_pre_build+=(update_config_fragments)" "$BUILDDIR/libremakepkg.sh"
  fi

  # patch libremakepkg to disable checks
  sed -i 's/makepkg_args=(.*noconfirm[^)]*/& --nocheck/' "$BUILDDIR/libremakepkg.sh"
}