summaryrefslogtreecommitdiffstats
path: root/source-builder
diff options
context:
space:
mode:
Diffstat (limited to 'source-builder')
-rwxr-xr-xsource-builder/aarch64-linux-gnu-pkg-config3
-rw-r--r--source-builder/config/binutils-2-1.cfg19
-rw-r--r--source-builder/config/checks.cfg9
-rw-r--r--source-builder/config/dtc-1-1.cfg4
-rw-r--r--source-builder/config/freetype-1.cfg2
-rw-r--r--source-builder/config/gcc-10.cfg20
-rw-r--r--source-builder/config/gcc-12.cfg21
-rw-r--r--source-builder/config/gcc-13.cfg26
-rw-r--r--source-builder/config/gcc-4.3-1.cfg7
-rw-r--r--source-builder/config/gcc-4.4-1.cfg7
-rw-r--r--source-builder/config/gcc-4.5-1.cfg7
-rw-r--r--source-builder/config/gcc-4.6-1.cfg7
-rw-r--r--source-builder/config/gcc-4.7-1.cfg7
-rw-r--r--source-builder/config/gcc-4.8-1.cfg7
-rw-r--r--source-builder/config/gcc-4.9-1.cfg19
-rw-r--r--source-builder/config/gcc-6-1.cfg7
-rw-r--r--source-builder/config/gcc-7-1.cfg7
-rw-r--r--source-builder/config/gcc-7.2-1.cfg7
-rw-r--r--source-builder/config/gcc-9.cfg4
-rw-r--r--source-builder/config/gcc-common-1.cfg67
-rw-r--r--source-builder/config/gdb-7.5-1.cfg3
-rw-r--r--source-builder/config/gdb-common-1.cfg86
-rw-r--r--source-builder/config/glib-2-1.cfg1
-rw-r--r--source-builder/config/gmp.cfg19
-rw-r--r--source-builder/config/grub2.cfg76
-rw-r--r--source-builder/config/gsed-1.cfg107
-rw-r--r--source-builder/config/libtool-2-1.cfg8
-rw-r--r--source-builder/config/mpfr.cfg62
-rw-r--r--source-builder/config/nxlib-1.cfg4
-rw-r--r--source-builder/config/or1ksim-1-1.cfg4
-rw-r--r--source-builder/config/pcre-8-1.cfg2
-rw-r--r--source-builder/config/qemu-common-2.cfg4
-rw-r--r--source-builder/config/sis-2-1.cfg1
-rw-r--r--source-builder/config/swig-4-1.cfg6
-rw-r--r--source-builder/config/texinfo-1.cfg107
-rw-r--r--source-builder/defaults.mc12
-rwxr-xr-xsource-builder/pkg-config36
-rwxr-xr-xsource-builder/sb-rtems-pkg29
-rw-r--r--source-builder/sb/build.py22
-rw-r--r--source-builder/sb/config.py126
-rw-r--r--source-builder/sb/download.py11
-rwxr-xr-xsource-builder/sb/ereport.py4
-rwxr-xr-xsource-builder/sb/execute.py9
-rw-r--r--source-builder/sb/freebsd.py16
-rw-r--r--source-builder/sb/getsources.py30
-rw-r--r--source-builder/sb/git.py12
-rw-r--r--source-builder/sb/linux.py93
-rw-r--r--source-builder/sb/mailer.py194
-rw-r--r--source-builder/sb/options.py35
-rw-r--r--source-builder/sb/path.py28
-rwxr-xr-xsource-builder/sb/pkgconfig.py4
-rwxr-xr-xsource-builder/sb/rtems-build-dep17
-rwxr-xr-xsource-builder/sb/rtems-kernel-config-check127
-rw-r--r--source-builder/sb/rtemspkg.py287
-rw-r--r--source-builder/sb/setbuilder.py147
-rw-r--r--source-builder/sb/simhost.py128
-rw-r--r--source-builder/sb/version.py12
-rwxr-xr-xsource-builder/x86_64-linux-gnu-pkg-config3
58 files changed, 1711 insertions, 418 deletions
diff --git a/source-builder/aarch64-linux-gnu-pkg-config b/source-builder/aarch64-linux-gnu-pkg-config
new file mode 100755
index 0000000..09d7b16
--- /dev/null
+++ b/source-builder/aarch64-linux-gnu-pkg-config
@@ -0,0 +1,3 @@
+#! /bin/sh
+base=$(dirname $0)
+exec ${base}/pkg-config $*
diff --git a/source-builder/config/binutils-2-1.cfg b/source-builder/config/binutils-2-1.cfg
index a49fa2a..890bd74 100644
--- a/source-builder/config/binutils-2-1.cfg
+++ b/source-builder/config/binutils-2-1.cfg
@@ -26,13 +26,22 @@ URL: http://sources.redhat.com/binutils
%define allow_cxc
#
-# Default gold and LTO to disable.
+# Default gold to disable.
#
%ifn %{defined with_gold}
%define with_gold 0
%endif
-%ifn %{defined with_lto}
- %define with_lto 0
+
+#
+# Disable the new default options to check for stack exec and RWX sections
+# instroduced in 2.39.
+#
+%define binutils_extra_config %nil
+%ifn %{defined with_stackexec_warning}
+ %define binutils_extra_config %{binutils_extra_config} --disable-warn-execstack
+%endif
+%ifn %{defined with_rwx_sections_warning}
+ %define binutils_extra_config %{binutils_extra_config} --disable-warn-rwx-segments
%endif
#
@@ -72,14 +81,14 @@ URL: http://sources.redhat.com/binutils
%{?with_deterministic_archives:--enable-deterministic-archives} \
%{?with_64_bit_bfd:--enable-64-bit-bfd} \
%{?with_gold:--enable-gold=yes} \
- %{?with_lto:--enable-lto --enable-plugins}%{!?with_lto:--disable-lto} \
--without-included-gettext \
--disable-win32-registry \
--disable-werror \
--prefix=%{_prefix} --bindir=%{_bindir} \
--exec-prefix=%{_exec_prefix} \
--includedir=%{_includedir} --libdir=%{_libdir} \
- --mandir=%{_mandir} --infodir=%{_infodir}
+ --mandir=%{_mandir} --infodir=%{_infodir} \
+ %{binutils_extra_config}
%{__make} %{?_smp_mflags} all
diff --git a/source-builder/config/checks.cfg b/source-builder/config/checks.cfg
index 93d4c97..da1c1da 100644
--- a/source-builder/config/checks.cfg
+++ b/source-builder/config/checks.cfg
@@ -23,6 +23,8 @@
%{?without_java:%define enable_java 0}
%{?with_objc:%define enable_objc 1}
%{?without_objc:%define enable_objc 0}
+%{?with_newlib_tls:%define enable_newlib_tls 1}
+%{?without_newlib_tls:%define enable_newlib_tls 0}
#
# Default to C++ on.
@@ -72,3 +74,10 @@
%ifn %{defined enable_obsolete}
%define enable_obsolete 0
%endif
+
+#
+# Default to Newlib thread-local storage instead of struct _reent off.
+#
+%ifn %{defined enable_newlib_tls}
+ %define enable_newlib_tls 0
+%endif
diff --git a/source-builder/config/dtc-1-1.cfg b/source-builder/config/dtc-1-1.cfg
index 686a1e0..d42e91e 100644
--- a/source-builder/config/dtc-1-1.cfg
+++ b/source-builder/config/dtc-1-1.cfg
@@ -37,7 +37,7 @@ URL: https://www.devicetree.org/
%{build_build_flags}
- %{__make} PREFIX=%{_prefix}
+ %{__make} PREFIX=%{_prefix} WARNINGS=
cd ${build_top}
@@ -47,6 +47,6 @@ URL: https://www.devicetree.org/
rm -rf $SB_BUILD_ROOT
cd dtc-%{dtc_version}
- %{__make} DESTDIR=$SB_BUILD_ROOT PREFIX=%{_prefix} install
+ %{__make} DESTDIR=$SB_BUILD_ROOT PREFIX=%{_prefix} WARNINGS= install
cd ${build_top}
diff --git a/source-builder/config/freetype-1.cfg b/source-builder/config/freetype-1.cfg
index 95892dd..917f3d9 100644
--- a/source-builder/config/freetype-1.cfg
+++ b/source-builder/config/freetype-1.cfg
@@ -17,7 +17,7 @@ URL: http://www.freetype.org/
#
# freetype Source
#
-%source set freetype http://download.savannah.gnu.org/releases/freetype/freetype-%{freetype_version}.tar.gz
+%source set freetype https://download.savannah.gnu.org/releases/freetype/freetype-old/freetype-%{freetype_version}.tar.gz
#
# Prepare the source code.
#
diff --git a/source-builder/config/gcc-10.cfg b/source-builder/config/gcc-10.cfg
new file mode 100644
index 0000000..d15c4a4
--- /dev/null
+++ b/source-builder/config/gcc-10.cfg
@@ -0,0 +1,20 @@
+#
+# GCC 10
+#
+# This configuration file configure's, make's and install's gcc. It uses
+# newlib, ISL, MPFR, MPC, and GMP in a one-tree build configuration.
+#
+
+%define isl_version 0.18
+%hash sha512 isl-%{isl_version}.tar.bz2 85d0b40f4dbf14cb99d17aa07048cdcab2dc3eb527d2fbb1e84c41b2de5f351025370e57448b63b2b8a8cf8a0843a089c3263f9baee1542d5c2e1cb37ed39d94
+
+%define mpfr_version 3.1.6
+%hash sha512 mpfr-%{mpfr_version}.tar.bz2 0c310dd7956be527884f8059c195a5aca1042b089d0927ac6341e6310b1250a7059bc61aaaab4dfb76c6ab8b67e440878ca203f72674529bbcb46770ed9b6885
+
+%define mpc_version 1.0.3
+%hash sha512 mpc-%{mpc_version}.tar.gz 0028b76df130720c1fad7de937a0d041224806ce5ef76589f19c7b49d956071a683e2f20d154c192a231e69756b19e48208f2889b0c13950ceb7b3cfaf059a43
+
+%define gmp_version 6.2.1
+%hash sha512 gmp-%{gmp_version}.tar.bz2 8904334a3bcc5c896ececabc75cda9dec642e401fb5397c4992c4fabea5e962c9ce8bd44e8e4233c34e55c8010cc28db0545f5f750cbdbb5f00af538dc763be9
+
+%include %{_configdir}/gcc-common-1.cfg
diff --git a/source-builder/config/gcc-12.cfg b/source-builder/config/gcc-12.cfg
new file mode 100644
index 0000000..2885819
--- /dev/null
+++ b/source-builder/config/gcc-12.cfg
@@ -0,0 +1,21 @@
+#
+# GCC 12
+#
+# This configuration file configure's, make's and install's gcc. It uses
+# newlib, ISL, MPFR and MPC in a one-tree build configuration.
+#
+
+%define isl_version 0.24
+%hash sha512 isl-%{isl_version}.tar.bz2 \
+ qrO929qWuAHQ9W0oaflDFXqtUqb25qYXRe3XQCNMY1w4IxryC8PxoI1Bal6XOpDhgkkHjtjkri8dXeV2WHOOlQ==
+
+%define mpfr_version 4.2.0
+%define mpfr_url https://www.mpfr.org/mpfr-%{mpfr_version}
+%hash sha512 mpfr-%{mpfr_version}.tar.bz2 \
+ yyqTFLlONKTqSc4mGYAulCDJguVSWKS8Qj+AJ0BjJkaj1CDn/PNzsZYYOFuLK0Eqv6En6PRzBThjQkysIziTwA==
+
+%define mpc_version 1.2.1
+%hash sha512 mpc-%{mpc_version}.tar.gz \
+ Mnn4E6s39H/cyADkrF8wZBfQf1OVk8pxWHbkPgSJbh1bzsz7KI7ykIo/JLdgdH0NvQOSokubNBvD4SCC5cg27g==
+
+%include %{_configdir}/gcc-common-1.cfg
diff --git a/source-builder/config/gcc-13.cfg b/source-builder/config/gcc-13.cfg
new file mode 100644
index 0000000..19b514a
--- /dev/null
+++ b/source-builder/config/gcc-13.cfg
@@ -0,0 +1,26 @@
+#
+# GCC 13
+#
+# This configuration file configure's, make's and install's gcc. It uses
+# newlib, ISL, MPFR and MPC in a one-tree build configuration.
+#
+
+%define isl_version 0.24
+%hash sha512 isl-%{isl_version}.tar.bz2 \
+ qrO929qWuAHQ9W0oaflDFXqtUqb25qYXRe3XQCNMY1w4IxryC8PxoI1Bal6XOpDhgkkHjtjkri8dXeV2WHOOlQ==
+# See #4657
+%patch add isl -p1 https://devel.rtems.org/raw-attachment/ticket/4657/fix-mac-arm64-isl-config.patch
+%hash sha512 fix-mac-arm64-isl-config.patch \
+ wH/bYFplINGUNYUEcx5jtUAhHvaAOD8cpOxltKxDridodTT9fYGWpNvoOg7PLEKkJUxx5gnuSEp2FFc7xJmi6A==
+
+%define mpfr_version 4.2.1
+%define mpfr_url https://ftp.gnu.org/gnu/mpfr
+%hash sha512 mpfr-%{mpfr_version}.tar.bz2 \
+ yBhCUy7MZjNI3rdADZEa1xkz07Ulovnlrc0EJlycD90fIuyiKfSCcDrH8iLvIJ/J4zndH6R9cq5X9/cLIzanbw==
+
+%define mpc_version 1.3.1
+%define mpc_url https://ftp.gnu.org/gnu/mpc
+%hash sha512 mpc-%{mpc_version}.tar.gz \
+ S6tO9gdvjF39yZ2BC1EQjO1h6ilCugwcky1iQ2ClRz3yDTKzAPx28rpKoql+Hydcn9SUobqfB8TLKtfOrrGulw==
+
+%include %{_configdir}/gcc-common-1.cfg
diff --git a/source-builder/config/gcc-4.3-1.cfg b/source-builder/config/gcc-4.3-1.cfg
index 69ea367..24d4010 100644
--- a/source-builder/config/gcc-4.3-1.cfg
+++ b/source-builder/config/gcc-4.3-1.cfg
@@ -24,13 +24,6 @@
%source set newlib https://sourceware.org/pub/newlib/newlib-%{newlib_version}.tar.gz
#
-# Packages GCC requires
-#
-%source set mpfr http://www.mpfr.org/mpfr-%{mpfr_version}/mpfr-%{mpfr_version}.tar.bz2
-%source set mpc http://www.multiprecision.org/mpc/download/mpc-%{mpc_version}.tar.gz
-%source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2
-
-#
# GCC Common build script.
#
%include %{_configdir}/gcc-common-1.cfg
diff --git a/source-builder/config/gcc-4.4-1.cfg b/source-builder/config/gcc-4.4-1.cfg
index 2c70919..c6ae586 100644
--- a/source-builder/config/gcc-4.4-1.cfg
+++ b/source-builder/config/gcc-4.4-1.cfg
@@ -23,13 +23,6 @@
%source set newlib https://sourceware.org/pub/newlib/newlib-%{newlib_version}.tar.gz
#
-# Packages GCC requires
-#
-%source set mpfr http://www.mpfr.org/mpfr-%{mpfr_version}/mpfr-%{mpfr_version}.tar.bz2
-%source set mpc http://www.multiprecision.org/mpc/download/mpc-%{mpc_version}.tar.gz
-%source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2
-
-#
# GCC Common build script.
#
%include %{_configdir}/gcc-common-1.cfg
diff --git a/source-builder/config/gcc-4.5-1.cfg b/source-builder/config/gcc-4.5-1.cfg
index fbff31c..8a9f8ca 100644
--- a/source-builder/config/gcc-4.5-1.cfg
+++ b/source-builder/config/gcc-4.5-1.cfg
@@ -19,13 +19,6 @@
%source set newlib https://sourceware.org/pub/newlib/newlib-%{newlib_version}.tar.gz
#
-# Packages GCC requires
-#
-%source set mpfr http://www.mpfr.org/mpfr-%{mpfr_version}/mpfr-%{mpfr_version}.tar.bz2
-%source set mpc http://www.multiprecision.org/mpc/download/mpc-%{mpc_version}.tar.gz
-%source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2
-
-#
# GCC Common build script.
#
%include %{_configdir}/gcc-common-1.cfg
diff --git a/source-builder/config/gcc-4.6-1.cfg b/source-builder/config/gcc-4.6-1.cfg
index 98f8d7e..cecfdb5 100644
--- a/source-builder/config/gcc-4.6-1.cfg
+++ b/source-builder/config/gcc-4.6-1.cfg
@@ -23,13 +23,6 @@
%source set newlib https://sourceware.org/pub/newlib/newlib-%{newlib_version}.tar.gz
#
-# Packages GCC requires
-#
-%source set mpfr http://www.mpfr.org/mpfr-%{mpfr_version}/mpfr-%{mpfr_version}.tar.bz2
-%source set mpc http://www.multiprecision.org/mpc/download/mpc-%{mpc_version}.tar.gz
-%source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2
-
-#
# GCC Common build script.
#
%include %{_configdir}/gcc-common-1.cfg
diff --git a/source-builder/config/gcc-4.7-1.cfg b/source-builder/config/gcc-4.7-1.cfg
index 0eac21f..79a50db 100644
--- a/source-builder/config/gcc-4.7-1.cfg
+++ b/source-builder/config/gcc-4.7-1.cfg
@@ -28,13 +28,6 @@
%source set newlib https://sourceware.org/pub/newlib/newlib-%{newlib_version}.tar.gz
#
-# Packages GCC requires
-#
-%source set mpfr http://www.mpfr.org/mpfr-%{mpfr_version}/mpfr-%{mpfr_version}.tar.bz2
-%source set mpc http://www.multiprecision.org/mpc/download/mpc-%{mpc_version}.tar.gz
-%source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2
-
-#
# GCC Common build script.
#
%include %{_configdir}/gcc-common-1.cfg
diff --git a/source-builder/config/gcc-4.8-1.cfg b/source-builder/config/gcc-4.8-1.cfg
index aa62837..b2d4208 100644
--- a/source-builder/config/gcc-4.8-1.cfg
+++ b/source-builder/config/gcc-4.8-1.cfg
@@ -19,13 +19,6 @@
%source set newlib https://sourceware.org/pub/newlib/newlib-%{newlib_version}.tar.gz
#
-# Packages GCC requires
-#
-%source set mpfr http://www.mpfr.org/mpfr-%{mpfr_version}/mpfr-%{mpfr_version}.tar.bz2
-%source set mpc http://www.multiprecision.org/downloads/mpc-%{mpc_version}.tar.gz
-%source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2
-
-#
# GCC Common build script.
#
%include %{_configdir}/gcc-common-1.cfg
diff --git a/source-builder/config/gcc-4.9-1.cfg b/source-builder/config/gcc-4.9-1.cfg
index e28b560..e472e47 100644
--- a/source-builder/config/gcc-4.9-1.cfg
+++ b/source-builder/config/gcc-4.9-1.cfg
@@ -18,21 +18,18 @@
#
%source set newlib https://sourceware.org/pub/newlib/newlib-%{newlib_version}.tar.gz
-#
-# Packages GCC requires
-#
-%source set mpfr http://www.mpfr.org/mpfr-%{mpfr_version}/mpfr-%{mpfr_version}.tar.bz2
-%source set mpc http://www.multiprecision.org/mpc/download/mpc-%{mpc_version}.tar.gz
-%source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2
-
%patch add gcc --rsb-file=Make-lang.in-b09fb02bb4c0d16fc2c842bec4069c033897b5f2.patch -p1 https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff_plain;f=gcc/cp/Make-lang.in;h=b09fb02bb4c0d16fc2c842bec4069c033897b5f2;hp=e98beb1e33e4bcc4943361c559ae71b7eb345346;hb=1e5f1089dec3af328fd03125d6778f666d0bd4e4;hpb=88375bb2ba8b9004a9924cdae894d7ff32972652
-%hash sha512 Make-lang.in-b09fb02bb4c0d16fc2c842bec4069c033897b5f2.patch a47511de21fda0c0c314577ee295b8f2bc9f555084ceca88de12c931ebfe47e5fec349682085a7a1e8637e8e159b8f79188a56d42e54fda2ba5161d5bd3f56ac
+%hash sha512 Make-lang.in-b09fb02bb4c0d16fc2c842bec4069c033897b5f2.patch \
+ h0s+47lNCLhSKUjMuK6qILRHFeNpgsm/MulBzfqv934aPdryogCODhEdPiT5pUV02nMIzvg/kx7wus+8O6zTKQ==
%patch add gcc --rsb-file=cfns.gperf.b09fb02bb4c0d16fc2c842bec4069c033897b5f2.patch -p1 https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff_plain;f=gcc/cp/cfns.gperf;h=b09fb02bb4c0d16fc2c842bec4069c033897b5f2;hp=e98beb1e33e4bcc4943361c559ae71b7eb345346;hb=1e5f1089dec3af328fd03125d6778f666d0bd4e4;hpb=88375bb2ba8b9004a9924cdae894d7ff32972652
-%hash sha512 cfns.gperf.b09fb02bb4c0d16fc2c842bec4069c033897b5f2.patch fdb49abb4f04ba627d6be7b0e0dd9bfdf3eb4b28c045627048bf1c56cabdf2c618cf084991bb847ac60c1eabf582a30ca1e0f4bfd943b9f34efd7e96879d251b
+%hash sha512 cfns.gperf.b09fb02bb4c0d16fc2c842bec4069c033897b5f2.patch \
+ nzj3FPeCC/NcOvuIzyd4EGoJFu3iqn1LUa8ya+P2hstwVLxiHGyvZKHaS1Cb0v7JlRCfhe6eftTZFmEzEqxCqw==
%patch add gcc --rsb-file=cfns.h-b09fb02bb4c0d16fc2c842bec4069c033897b5f2.patch -p1 https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff_plain;f=gcc/cp/cfns.h;h=b09fb02bb4c0d16fc2c842bec4069c033897b5f2;hp=e98beb1e33e4bcc4943361c559ae71b7eb345346;hb=1e5f1089dec3af328fd03125d6778f666d0bd4e4;hpb=88375bb2ba8b9004a9924cdae894d7ff32972652
-%hash sha512 cfns.h-b09fb02bb4c0d16fc2c842bec4069c033897b5f2.patch ec0bd28a8266b136b99db4285c9a088c11fd7ba647dade5fb161308c00cb4189fa665e25ce6b139a7aa9740e97e617fd4e15ca506416dd9316e9fb7202f5c520
+%hash sha512 cfns.h-b09fb02bb4c0d16fc2c842bec4069c033897b5f2.patch \
+ Wl/1Njp/BOUEwxIVBZtElBLT2rSlBO545FuagJHbL/ajxCllSmtM6611QpWke16fzN/SDgyvkgsJxzfk76WaLw==
%patch add gcc --rsb-file=except.c-b09fb02bb4c0d16fc2c842bec4069c033897b5f2.patch -p1 https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff_plain;f=gcc/cp/except.c;h=b09fb02bb4c0d16fc2c842bec4069c033897b5f2;hp=e98beb1e33e4bcc4943361c559ae71b7eb345346;hb=1e5f1089dec3af328fd03125d6778f666d0bd4e4;hpb=88375bb2ba8b9004a9924cdae894d7ff32972652
-%hash sha512 except.c-b09fb02bb4c0d16fc2c842bec4069c033897b5f2.patch ad05ceea98d7ec95fb2312b0f31aa6260f67119d7c796a1b8c1816fbcd2738edb626705594699bec22a2f770892589f6fc296e184d329bcb967ee2587fbfc5ba
+%hash sha512 except.c-b09fb02bb4c0d16fc2c842bec4069c033897b5f2.patch \
+ CyuFSBNswd7W8LVDjeOev7HSrQ19dqNEKiuDwNRn0pf02tAxuerxwONQP2fX5QkqwCNxiPnSwB6yzhu4RVSX/A==
#
# GCC Common build script.
diff --git a/source-builder/config/gcc-6-1.cfg b/source-builder/config/gcc-6-1.cfg
index 842ec35..2a2e3ec 100644
--- a/source-builder/config/gcc-6-1.cfg
+++ b/source-builder/config/gcc-6-1.cfg
@@ -19,13 +19,6 @@
%source set newlib https://sourceware.org/pub/newlib/newlib-%{newlib_version}.tar.gz
#
-# Packages GCC requires
-#
-%source set mpfr http://www.mpfr.org/mpfr-%{mpfr_version}/mpfr-%{mpfr_version}.tar.bz2
-%source set mpc http://www.multiprecision.org/mpc/download/mpc-%{mpc_version}.tar.gz
-%source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2
-
-#
# GCC Common build script.
#
%include %{_configdir}/gcc-common-1.cfg
diff --git a/source-builder/config/gcc-7-1.cfg b/source-builder/config/gcc-7-1.cfg
index 5160968..06a790f 100644
--- a/source-builder/config/gcc-7-1.cfg
+++ b/source-builder/config/gcc-7-1.cfg
@@ -19,13 +19,6 @@
%source set newlib https://sourceware.org/pub/newlib/newlib-%{newlib_version}.tar.gz
#
-# Packages GCC requires
-#
-%source set mpfr https://ftp.gnu.org/gnu/mpfr/mpfr-%{mpfr_version}.tar.bz2
-%source set mpc https://ftp.gnu.org/gnu/mpc/mpc-%{mpc_version}.tar.gz
-%source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2
-
-#
# GCC Common build script.
#
%include %{_configdir}/gcc-common-1.cfg
diff --git a/source-builder/config/gcc-7.2-1.cfg b/source-builder/config/gcc-7.2-1.cfg
index 893a2f5..3f3ee03 100644
--- a/source-builder/config/gcc-7.2-1.cfg
+++ b/source-builder/config/gcc-7.2-1.cfg
@@ -19,13 +19,6 @@
%source set newlib https://sourceware.org/pub/newlib/newlib-%{newlib_version}.tar.gz
#
-# Packages GCC requires
-#
-%source set mpfr https://ftp.gnu.org/gnu/mpfr/mpfr-%{mpfr_version}.tar.bz2
-%source set mpc https://ftp.gnu.org/gnu/mpc/mpc-%{mpc_version}.tar.gz
-%source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2
-
-#
# GCC Common build script.
#
%include %{_configdir}/gcc-common-1.cfg
diff --git a/source-builder/config/gcc-9.cfg b/source-builder/config/gcc-9.cfg
index f8cf69b..e076d63 100644
--- a/source-builder/config/gcc-9.cfg
+++ b/source-builder/config/gcc-9.cfg
@@ -17,8 +17,4 @@
%define gmp_version 6.1.0
%hash sha512 gmp-6.1.0.tar.bz2 3c82aeab9c1596d4da8afac2eec38e429e84f3211e1a572cf8fd2b546493c44c039b922a1133eaaa48bd7f3e11dbe795a384e21ed95cbe3ecc58d7ac02246117
-%source set mpc https://ftp.gnu.org/gnu/mpc/mpc-%{mpc_version}.tar.gz
-%source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2
-%source set mpfr https://ftp.gnu.org/gnu/mpfr/mpfr-%{mpfr_version}.tar.bz2
-
%include %{_configdir}/gcc-common-1.cfg
diff --git a/source-builder/config/gcc-common-1.cfg b/source-builder/config/gcc-common-1.cfg
index 4e13efc..42c8a7b 100644
--- a/source-builder/config/gcc-common-1.cfg
+++ b/source-builder/config/gcc-common-1.cfg
@@ -34,7 +34,7 @@ URL: http://gcc.gnu.org/
# Default LTO to off.
#
%ifn %{defined with_lto}
- %define with_lto 0
+ %define enable_lto 1
%endif
#
@@ -47,14 +47,32 @@ URL: http://gcc.gnu.org/
%endif
#
+# Packages GCC URLs, can be defined for older packages
+#
+%if %{!defined cloog_url}
+ %define cloog_url https://gcc.gnu.org/pub/gcc/infrastructure
+%endif
+%if %{!defined isl_url}
+ %define isl_url https://gcc.gnu.org/pub/gcc/infrastructure
+%endif
+%if %{!defined mpc_url}
+ %define mpc_url https://gcc.gnu.org/pub/gcc/infrastructure
+%endif
+%if %{!defined mpfr_url}
+ %define mpfr_url https://gcc.gnu.org/pub/gcc/infrastructure
+%endif
+
+#
# Packages GCC requires
#
%if %{defined cloog_version}
-%source set cloog https://gcc.gnu.org/pub/gcc/infrastructure/cloog-%{cloog_version}.tar.gz
+%source set cloog %{_url}/cloog-%{cloog_version}.tar.gz
%endif
%if %{defined isl_version}
-%source set isl https://gcc.gnu.org/pub/gcc/infrastructure/isl-%{isl_version}.tar.bz2
+%source set isl %{isl_url}/isl-%{isl_version}.tar.bz2
%endif
+%source set mpc %{mpc_url}/mpc-%{mpc_version}.tar.gz
+%source set mpfr %{mpfr_url}/mpfr-%{mpfr_version}.tar.bz2
#
# Prepare the source code.
@@ -90,7 +108,7 @@ URL: http://gcc.gnu.org/
%source setup cloog -q -D -n cloog-%{cloog_version}
%patch setup cloog -p1
cd ${build_top}
- # Build MPFR one-tree style
+ # Build CLooG one-tree style
%{__rmfile} ${source_dir_gcc}/cloog
%{__ln_s} $PWD/${source_dir_cloog} ${source_dir_gcc}/cloog
%endif
@@ -101,20 +119,11 @@ URL: http://gcc.gnu.org/
%source setup isl -q -D -n isl-%{isl_version}
%patch setup isl -p1
cd ${build_top}
- # Build MPFR one-tree style
+ # Build ISL one-tree style
%{__rmfile} ${source_dir_gcc}/isl
%{__ln_s} $PWD/${source_dir_isl} ${source_dir_gcc}/isl
%endif
- # MPFR
- source_dir_mpfr="mpfr-%{mpfr_version}"
- %source setup mpfr -q -D -n mpfr-%{mpfr_version}
- %patch setup mpfr -p1
- cd ${build_top}
- # Build MPFR one-tree style
- %{__rmfile} ${source_dir_gcc}/mpfr
- %{__ln_s} $PWD/${source_dir_mpfr} ${source_dir_gcc}/mpfr
-
# MPC
source_dir_mpc="mpc-%{mpc_version}"
%source setup mpc -q -D -n mpc-%{mpc_version}
@@ -124,14 +133,14 @@ URL: http://gcc.gnu.org/
%{__rmfile} ${source_dir_gcc}/mpc
%{__ln_s} $PWD/${source_dir_mpc} ${source_dir_gcc}/mpc
- # GMP
- source_dir_gmp="gmp-%{gmp_version}"
- %source setup gmp -q -D -n gmp-%{gmp_version}
- %patch setup gmp -p1
+ # MPFR
+ source_dir_mpfr="mpfr-%{mpfr_version}"
+ %source setup mpfr -q -D -n mpfr-%{mpfr_version}
+ %patch setup mpfr -p1
cd ${build_top}
- # Build GMP one-tree style
- %{__rmfile} ${source_dir_gcc}/gmp
- %{__ln_s} $PWD/${source_dir_gmp} ${source_dir_gcc}/gmp
+ # Build MPFR one-tree style
+ %{__rmfile} ${source_dir_gcc}/mpfr
+ %{__ln_s} $PWD/${source_dir_mpfr} ${source_dir_gcc}/mpfr
echo "%{gcc_version_message}" > ${source_dir_gcc}/gcc/DEV-PHASE
@@ -143,6 +152,10 @@ URL: http://gcc.gnu.org/
%build
build_top=$(pwd)
+ %if %{defined _internal_gsed_path}
+ export PATH=%{_internal_gsed_path}/bin:$PATH
+ %endif
+
%{build_directory}
mkdir -p ${build_dir}
@@ -162,11 +175,8 @@ URL: http://gcc.gnu.org/
%if %{enable_fortran}
languages="$languages,fortran"
%endif
-%if %{enable_java}
- languages="$languages,java"
-%endif
-%if %{enable_objc}
- languages="$languages,objc"
+%if %{enable_lto}
+ languages="$languages,lto"
%endif
%{host_build_flags}
@@ -188,10 +198,11 @@ URL: http://gcc.gnu.org/
--with-newlib \
--disable-nls --without-included-gettext \
--disable-win32-registry \
+ --disable-werror \
--enable-version-specific-runtime-libs \
- %{?with_lto:--enable-lto}%{!?with_lto:--disable-lto} \
--enable-newlib-io-c99-formats \
%{?disable_MAKEINFO:MAKEINFO=missing} \
+ %{?enable_newlib_tls:--enable-newlib-reent-thread-local} \
%{?with_iconv:--enable-newlib-iconv} \
%{?with_iconv:--enable-newlib-iconv-encodings=%{_newlib_iconv_encodings}} \
%{?with_threads:--enable-threads}%{!?with_threads:--disable-threads} \
@@ -208,7 +219,7 @@ URL: http://gcc.gnu.org/
cp ../${source_dir_gcc}/gcc/gsyslimits.h gcc/include/syslimits.h
fi
- %{__make} %{?_smp_mflags} all
+ %{__make} -w %{?_smp_mflags} all
cd ${build_top}
diff --git a/source-builder/config/gdb-7.5-1.cfg b/source-builder/config/gdb-7.5-1.cfg
index e2d141b..aa73e3e 100644
--- a/source-builder/config/gdb-7.5-1.cfg
+++ b/source-builder/config/gdb-7.5-1.cfg
@@ -11,6 +11,9 @@
%define gdb_version 7.5
+%hash sha512 gdb-%{gdb_version}.tar.gz \
+ SnVe8LjmGIwPSX86ZuTsu2eZ5ciCOrxBj8Y/J5ms72y6FM8mhgSQkZMXiC4kxN8GiDYQKhWrhRxnM94Cubvibw==
+
#
# The gdb build instructions. We use 7.xx Release 1.
#
diff --git a/source-builder/config/gdb-common-1.cfg b/source-builder/config/gdb-common-1.cfg
index 397d44d..49bf673 100644
--- a/source-builder/config/gdb-common-1.cfg
+++ b/source-builder/config/gdb-common-1.cfg
@@ -42,8 +42,27 @@
# 2. Does the version of gdb specify a version of python that must be
# used. Override with '%define gdb-python-version python2'.
#
-# 3. Search for 'python2' and if not found search for 'python3'.
+# 3. Search for 'python3' and if not found search for 'python2'.
#
+# User options to help find a suitable python:
+#
+# --with-python2 : name of a python2 command
+#
+# --with-python3 : name of a python2 command
+#
+# --with-python-version : name of a python command with a specific version
+#
+# For example `--with-python-version=python3.6
+#
+%if %{defined with_python2}
+ %define gdb-python2 %{with_python2}
+%endif
+%if %{defined with_python3}
+ %define gdb-python3 %{with_python3}
+%endif
+%if %{defined with_python_version}
+ %define gdb-python-version %{with_python_version}
+%endif
%if %{defined gdb-python2}
%define gdb-enable-python %{gdb_python2}
%else
@@ -53,12 +72,12 @@
%if %{defined gdb-python-version}
%define gdb-enable-python %(command -v %{gdb-python-version} || true)
%else
- %define gdb-enable-python %(command -v python2 || true)
+ %define gdb-enable-python %(command -v python3 || true)
%if %{gdb-enable-python} == %{nil}
- %define gdb-enable-python %(command -v python3 || true)
+ %define gdb-enable-python %(command -v python2 || true)
%endif
%if %{gdb-enable-python} == %{nil}
- %define gdb-enable-python %(command -v python || true})
+ %define gdb-enable-python %(command -v python || true})
%endif
%endif
%if %{gdb-enable-python} == %{nil}
@@ -79,8 +98,13 @@
%endif
%if %{gdb-python-config} == %{nil}
%define gdb-python-config %(command -v %{gdb-enable-python}-config || true)
+ %if %{gdb-python-config} == %{nil}
+ %define gdb-python-config %(command -v %(basename %{gdb-enable-python})-config || true)
+ %endif
%endif
%define gdb-python-ver-mm %(%{gdb-enable-python} --version 2>&1 | sed -e 's/.* //g' | rev | cut -d'.' -f2- | rev)
+%define gdb-python-ver-major %(echo "%{gdb-python-ver-mm}" | sed -e 's/\..*//')
+%define gdb-python-ver-minor %(echo "%{gdb-python-ver-mm}" | sed -e 's/.*\.//')
%define gdb-python-header Python.h
%define gdb-python-ver-header python%{gdb-python-ver-mm}/%{gdb-python-header}
%define gdb-python-ver-lib libpython%{gdb-python-ver-mm}.*
@@ -98,29 +122,39 @@
%if %{gdb-python-header-check} == not-found && !%{_rsb_getting_source}
%error "gdb: python: header file not found: %{gdb-python-ver-header}, please install"
%endif
-#
-# Too hard to find on MacOS (darwin), the header is good enough.
-#
-%ifnos darwin
- %if %{host_ldflags} == %{nil}
- %define gdb-host-libs %{nil}
- %else
- %define gdb-host-libs -L '%{host_ldflags}'
- %endif
- %if %{gdb-python-config} != %{nil}
- %define gdb-python-lib-filter awk 'BEGIN{FS=" "}/python/{for(i=1;i<NF;++i)if(match($i,".*lpython.*")) print "lib"substr($i,3)"*";}'
- %if %{gdb-python-ver-mm} < 3.8
- %define gdb-python-config-lib-check-flags --ldflags
- %else
- %define gdb-python-config-lib-check-flags --ldflags --embed
- %endif
- %define gdb-python-config-libs %(%{gdb-python-config} %{gdb-python-config-lib-check-flags} | %{gdb-python-lib-filter})
- %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-config-libs})
+%if %{host_ldflags} == %{nil}
+ %define gdb-host-libs %{nil}
+%else
+ %define gdb-host-libs -L '%{host_ldflags}'
+%endif
+%if %{gdb-python-config} != %{nil}
+ %define gdb-python-lib-filter awk '{for(i=1;i<NF;++i)if(match($i,".*lpython.*")) print "lib"substr($i,3)"\\*";}'
+ %define gdb-python-libpath-filter awk '{for(i=1;i<NF;++i) if (match($i,"-L.*") == 1) l[substr($i,3)]=1;} END{for(i in l) printf("-L " i " "); printf("\n");}'
+ %if %{gdb-python-ver-major} < 3 || \
+ %{gdb-python-ver-major} == 3 && %{gdb-python-ver-minor} < 8
+ %define gdb-python-config-lib-check-flags --ldflags
%else
- %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-ver-lib})
+ %define gdb-python-config-lib-check-flags --ldflags --embed
%endif
- %if %{gdb-python-lib-check} == not-found && !%{_rsb_getting_source}
- %error "gdb: python: library file not found: %{gdb-python-ver-lib}, please install"
+ %define gdb-python-config-libs %(%{gdb-python-config} %{gdb-python-config-lib-check-flags} | %{gdb-python-lib-filter})
+ %define gdb-python-config-libpath %(%{gdb-python-config} %{gdb-python-config-lib-check-flags} | %{gdb-python-libpath-filter} | uniq)
+ %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} %{gdb-python-config-libpath} -l %{gdb-python-config-libs})
+%else
+ %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-ver-lib})
+%endif
+%if %{gdb-python-lib-check} == not-found && !%{_rsb_getting_source}
+ %error "gdb: python: library file not found: %{gdb-python-ver-lib}, please install"
+%endif
+
+#
+# If in a virtual environment use that as GDB will look 'bin/python' under it
+# Supportted in GDB 13 and later.
+#
+%define gdb_version_major %(echo "%{gdb_version}" | sed -e 's/\..*//')
+%if %{gdb_version_major} >= 13
+ %define python-venv %(echo $VIRTUAL_ENV)
+ %if %{python-venv} != %{nil}
+ %define gdb-enable-python %{python-venv}
%endif
%endif
@@ -173,7 +207,7 @@ URL: http://www.gnu.org/software/gdb/
#
# Source
#
-%source set gdb http://ftp.gnu.org/gnu/gdb/gdb-%{gdb_version}.tar.%{gdb_src_ext}
+%source set gdb https://ftp.gnu.org/gnu/gdb/gdb-%{gdb_version}.tar.%{gdb_src_ext}
#
# Disable Python on Cxc builds for now.
diff --git a/source-builder/config/glib-2-1.cfg b/source-builder/config/glib-2-1.cfg
index 09b43fa..5f80db0 100644
--- a/source-builder/config/glib-2-1.cfg
+++ b/source-builder/config/glib-2-1.cfg
@@ -60,6 +60,7 @@ URL: https://developer.gnome.org/glib/
--build=%{_build} --host=%{_host} \
--with-sysroot=$SYSROOT \
--disable-dtrace \
+ --enable-libmount=no \
--with-pcre=internal
%{_ld_library_path}=$SYSROOT/lib \
diff --git a/source-builder/config/gmp.cfg b/source-builder/config/gmp.cfg
index ffd3b20..352caef 100644
--- a/source-builder/config/gmp.cfg
+++ b/source-builder/config/gmp.cfg
@@ -15,9 +15,23 @@ Release: %{release}
URL: https://gmplib.org/
#
+# Allow the user to override the UURL
+#
+%if %{!defined gmp_url}
+ %define gmp_url https://gmplib.org/download/gmp
+%endif
+
+#
# Source
#
-%source set gmp https://gcc.gnu.org/pub/gcc/infrastructure/gmp-%{gmp_version}.tar.bz2
+%source set gmp %{gmp_url}/gmp-%{gmp_version}.tar.bz2
+
+#
+# Allow extra options
+#
+%if %{!defined gmp_extra_options}
+ %define gmp_extra_options %{nil}
+%endif
#
# Prepare the source code.
@@ -44,7 +58,8 @@ URL: https://gmplib.org/
--exec-prefix=%{_exec_prefix} \
--includedir=%{_includedir} --libdir=%{_libdir} \
--mandir=%{_mandir} --infodir=%{_infodir} \
- --disable-shared
+ --disable-shared \
+ %{gmp_extra_options}
%{__make} %{?_smp_mflags} all
diff --git a/source-builder/config/grub2.cfg b/source-builder/config/grub2.cfg
new file mode 100644
index 0000000..174b846
--- /dev/null
+++ b/source-builder/config/grub2.cfg
@@ -0,0 +1,76 @@
+#
+# GNU GRUB, the GRand Unified Bootloader
+#
+# This configuration file configure's, make's and install's GRUB2.
+#
+
+%define grub2_platform_supported = 1
+
+%ifos darwin
+%undefine grub2_platform_supported
+%{echo "Darwin does not support Grub2 compilation by default."}
+%{echo "If you need Grub2 on Darwin, please install objconv"}
+%{echo "and enable it by removing '%undefine grub2_platform_supported' above"}
+%endif
+
+%if %{defined grub2_platform_supported}
+
+%if %{release} == %{nil}
+%define release 1
+%endif
+
+Name: grub2-%{grub2_version}-%{_host}-%{release}
+Summary: GNU GRUB, the GRand Unified Bootloader v%{grub2_version} for target %{_target} on host %{_host}
+Version: %{grub2_version}
+Release: %{release}
+URL: https://www.gnu.org/software/grub/index.html
+
+#
+# Source
+#
+%source set grub2 https://ftp.gnu.org/gnu/grub/grub-%{grub2_version}.tar.xz
+
+#
+# Prepare the source code.
+#
+%prep
+ build_top=$(pwd)
+
+ %source setup grub2 -q -n grub-%{grub2_version}
+
+ cd ${build_top}
+
+%build
+ build_top=$(pwd)
+
+ cd grub-%{grub2_version}
+
+ %{host_build_flags}
+
+ ./configure \
+ --build=%{_build} --host=%{_host} \
+ --verbose \
+ --prefix=%{_prefix} --bindir=%{_bindir} \
+ --exec-prefix=%{_exec_prefix} \
+ --includedir=%{_includedir} --libdir=%{_libdir} \
+ --mandir=%{_mandir} --infodir=%{_infodir} \
+ --with-platform=%{grub2_platform} \
+ --target=%{grub2_target} \
+ --disable-libzfs \ # broken on FreeBSD and not needed at all
+ --disable-werror # fixes compilation by GCC 12
+
+ %{__make} %{?_smp_mflags} all
+
+ cd ${build_top}
+
+%install
+ build_top=$(pwd)
+
+ rm -rf $SB_BUILD_ROOT
+
+ cd grub-%{grub2_version}
+ %{__make} DESTDIR=$SB_BUILD_ROOT install
+
+ cd ${build_top}
+
+%endif
diff --git a/source-builder/config/gsed-1.cfg b/source-builder/config/gsed-1.cfg
new file mode 100644
index 0000000..9135414
--- /dev/null
+++ b/source-builder/config/gsed-1.cfg
@@ -0,0 +1,107 @@
+#
+# GNU sed 1.xx Version 1.
+#
+# This configuration file configure's, make's and install's GNU's sed
+#
+
+%if %{release} == %{nil}
+ %define release 1
+%endif
+
+%ifn %{defined _internal_gsed}
+ %define _internal_gsed no
+%endif
+
+Name: gsed-%{gsed_version}-%{_host}-%{release}
+Summary: GNU sed v%{gsed_version} for host %{_host}
+Version: %{gsed_version}
+Release: %{release}
+URL: https://www.gnu.org/software/sed/
+
+#
+# Source
+#
+%source set gsed https://ftp.gnu.org/gnu/sed/sed-%{gsed_version}.tar.gz
+
+#
+# Remap the install paths if it is an internal build
+#
+%if %{_internal_gsed} == yes
+ %if !%{defined _internal_gsed_path}
+ %error no gsed internal install path defined
+ %endif
+ %define gsed_prefix %{_internal_gsed_path}
+%else
+ %define gsed_prefix %{_prefix}
+%endif
+
+%define gsed_exec_prefix %{gsed_prefix}
+%define gsed_bindir %{gsed_exec_prefix}/bin
+%define gsed_sbindir %{gsed_exec_prefix}/sbin
+%define gsed_libexecdir %{gsed_exec_prefix}/libexec
+%define gsed_datarootdir %{gsed_prefix}/share
+%define gsed_datadir %{gsed_datarootdir}
+%define gsed_sysconfdir %{gsed_prefix}/etc
+%define gsed_sharedstatedir %{gsed_prefix}/com
+%define gsed_localstatedir %{gsed_prefix}/var
+%define gsed_includedir %{gsed_prefix}/include
+%define gsed_libdir %{gsed_exec_prefix}/%{_lib}
+%define gsed_mandir %{gsed_datarootdir}/man
+%define gsed_infodir %{gsed_datarootdir}/info
+%define gsed_localedir %{gsed_datarootdir}/locale
+
+#
+# Prepare the source code.
+#
+%prep
+ build_top=$(pwd)
+
+ source_dir_gsed="sed-%{gsed_version}"
+ %source setup gsed -q -n sed-%{gsed_version}
+ %patch setup gsed -p1
+
+ cd ${build_top}
+
+%build
+ build_top=$(pwd)
+
+ %if %{defined _internal_gsed_path}
+ export PATH="%{_internal_gsed_path}/bin:${PATH}"
+ %endif
+
+ %{build_directory}
+
+ mkdir -p ${build_dir}
+ cd ${build_dir}
+
+ %{host_build_flags}
+
+ ../${source_dir_gsed}/configure \
+ --prefix=%{gsed_prefix} \
+ --bindir=%{gsed_bindir} \
+ --exec_prefix=%{gsed_exec_prefix} \
+ --includedir=%{gsed_includedir} \
+ --libdir=%{gsed_libdir} \
+ --libexecdir=%{gsed_libexecdir} \
+ --mandir=%{gsed_mandir} \
+ --infodir=%{gsed_infodir} \
+ --datadir=%{gsed_datadir} \
+
+ %{__make} %{?_smp_mflags} all
+
+ cd ${build_top}
+
+%install
+ build_top=$(pwd)
+
+ %{__rmdir} $SB_BUILD_ROOT
+
+ cd ${build_dir}
+
+ %if %{_internal_gsed} == yes
+ %{__make} install
+ %else
+ %{__make} DESTDIR=$SB_BUILD_ROOT install
+ %endif
+
+ cd ${build_top}
diff --git a/source-builder/config/libtool-2-1.cfg b/source-builder/config/libtool-2-1.cfg
index e834e87..52a09f7 100644
--- a/source-builder/config/libtool-2-1.cfg
+++ b/source-builder/config/libtool-2-1.cfg
@@ -4,11 +4,11 @@
# This configuration file configure's, make's and install's libtool
#
-%ifn %{defined _internal_autotools}
+%if %{!defined _internal_autotools}
%define _internal_autotools no
- %ifn %{defined _internal_autotools_path}
- %define _internal_autotools_path %{nil}
- %endif
+%endif
+%if %{!defined _internal_autotools_path}
+ %define _internal_autotools_path %{_prefix}
%endif
Name: libtool-%{libtool_version}-%{_host}-%{release}
diff --git a/source-builder/config/mpfr.cfg b/source-builder/config/mpfr.cfg
new file mode 100644
index 0000000..6d64c1a
--- /dev/null
+++ b/source-builder/config/mpfr.cfg
@@ -0,0 +1,62 @@
+#
+# The GNU Multiple-precision Floating-point computations with correct Rounding (MPFR)
+#
+# This configuration file configure's, make's and install's GMP.
+#
+
+%if %{release} == %{nil}
+%define release 1
+%endif
+
+Name: mpfr-%{mpfr_version}-%{_host}-%{release}
+Summary: The GNU Multiple-precision Floating-point computations with correct Rounding Library (MPFR)
+ v%{mpfr_version} for target %{_target} on host %{_host}
+Version: %{mpfr_version}
+Release: %{release}
+URL: https://www.mpfr.org/
+
+#
+# Source
+#
+%source set mpfr https://www.mpfr.org/mpfr-%{mpfr_version}/mpfr-%{mpfr_version}.tar.bz2
+
+#
+# Prepare the source code.
+#
+%prep
+ build_top=$(pwd)
+
+ %source setup mpfr -q -n mpfr-%{mpfr_version}
+ %patch setup mpfr -p1
+
+ cd ${build_top}
+
+%build
+ build_top=$(pwd)
+
+ cd mpfr-%{mpfr_version}
+
+ %{host_build_flags}
+
+ ./configure \
+ --build=%{_build} --host=%{_host} \
+ --verbose \
+ --prefix=%{_prefix} --bindir=%{_bindir} \
+ --exec-prefix=%{_exec_prefix} \
+ --includedir=%{_includedir} --libdir=%{_libdir} \
+ --mandir=%{_mandir} --infodir=%{_infodir} \
+ --disable-shared
+
+ %{__make} %{?_smp_mflags} all
+
+ cd ${build_top}
+
+%install
+ build_top=$(pwd)
+
+ rm -rf $SB_BUILD_ROOT
+
+ cd mpfr-%{mpfr_version}
+ %{__make} DESTDIR=$SB_BUILD_ROOT install
+
+ cd ${build_top}
diff --git a/source-builder/config/nxlib-1.cfg b/source-builder/config/nxlib-1.cfg
index d177aa4..400f7dc 100644
--- a/source-builder/config/nxlib-1.cfg
+++ b/source-builder/config/nxlib-1.cfg
@@ -17,7 +17,9 @@ URL: http://www.microwindows.org/
#
# nxlib Source
#
-%source set nxlib git://github.com/alex-sever-h/nxlib.git
+%source set nxlib \
+ --rsb-file=nxlib-%{nxlib_version}.tar.gz \
+ https://codeload.github.com/alex-sever-h/nxlib/tar.gz/%{nxlib_version}
#
# Prepare the source code.
diff --git a/source-builder/config/or1ksim-1-1.cfg b/source-builder/config/or1ksim-1-1.cfg
index 468f524..a95f1ee 100644
--- a/source-builder/config/or1ksim-1-1.cfg
+++ b/source-builder/config/or1ksim-1-1.cfg
@@ -17,7 +17,9 @@ URL: https://github.com/openrisc/or1ksim
#
# Source
#
-%source set or1ksim https://github.com/openrisc/or1ksim/archive/or1k-master.zip
+%source set or1ksim \
+ --rsb-file=or1ksim-%{or1ksim_version}.tar.gz \
+ https://codeload.github.com/openrisc/or1ksim/tar.gz/%{or1ksim_version}
#
# Prepare the source code.
diff --git a/source-builder/config/pcre-8-1.cfg b/source-builder/config/pcre-8-1.cfg
index 461967f..8d854d8 100644
--- a/source-builder/config/pcre-8-1.cfg
+++ b/source-builder/config/pcre-8-1.cfg
@@ -20,7 +20,7 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
#
# Source
#
-%source set pcre https://ftp.pcre.org/pub/pcre/pcre-%{pcre_version}.tar.bz2
+%source set pcre https://sourceforge.net/projects/pcre/files/pcre/%{pcre_version}/pcre-%{pcre_version}.tar.bz2/download
#
# Prepare the source code.
diff --git a/source-builder/config/qemu-common-2.cfg b/source-builder/config/qemu-common-2.cfg
index 1dbaf05..56cb8e6 100644
--- a/source-builder/config/qemu-common-2.cfg
+++ b/source-builder/config/qemu-common-2.cfg
@@ -119,12 +119,12 @@ URL: http://www.qemu.org/
PKG_CONFIG_PATH=$SYSROOT/lib/pkgconfig \
PKG_CONFIG_BUILD_TOP_DIR=$SB_TMPROOT \
%{_ld_library_path}=$SYSROOT/lib \
- LDFLAGS="-Wl,-rpath -Wl,/$SB_PREFIX_CLEAN/lib -L$SYSROOT/lib ${VDE_LDFLAGS}" \
- CFLAGS="${CFLAGS} ${VDE_CFLAGS}" \
../${source_dir_qemu}/configure \
--prefix=%{_prefix} \
${CROSS_PREFIX_OPTION} \
--make=%{__make} \
+ --extra-ldflags="-Wl,-rpath -Wl,/$SB_PREFIX_CLEAN/lib -L$SYSROOT/lib ${VDE_LDFLAGS}" \
+ --extra-cflags="${CFLAGS} ${VDE_CFLAGS}" \
%{qemu_target_list} \
${VDE_CONFIG} \
%{qemu_disables}
diff --git a/source-builder/config/sis-2-1.cfg b/source-builder/config/sis-2-1.cfg
index a07b2db..a3b9515 100644
--- a/source-builder/config/sis-2-1.cfg
+++ b/source-builder/config/sis-2-1.cfg
@@ -43,7 +43,6 @@ Release: %{release}
fi
CFLAGS="$SB_CFLAGS" \
./configure \
- --build=%{_build} --host=%{_host} \
--program-prefix="$SIS_PREFIX" \
--prefix=${ac_prefix}
diff --git a/source-builder/config/swig-4-1.cfg b/source-builder/config/swig-4-1.cfg
index 6c10114..82c2cd6 100644
--- a/source-builder/config/swig-4-1.cfg
+++ b/source-builder/config/swig-4-1.cfg
@@ -16,8 +16,10 @@ URL: http://www.swig.org/
#
# Source
#
-%source set swig --rsb-file=swig-rel-%{swig_version}.tar.gz https://github.com/swig/swig/archive/rel-%{swig_version}.tar.gz
-%source set pcre https://ftp.pcre.org/pub/pcre/pcre-%{pcre_version}.tar.bz2
+%source set swig --rsb-file=swig-rel-%{swig_version}.tar.gz \
+ https://github.com/swig/swig/archive/rel-%{swig_version}.tar.gz
+%source set pcre --rsb-file=pcre-%{pcre_version}.tar.bz2 \
+ https://sourceforge.net/projects/pcre/files/pcre/%{pcre_version}/pcre-%{pcre_version}.tar.bz2/download
#
# See if a special swig prefix is provided
diff --git a/source-builder/config/texinfo-1.cfg b/source-builder/config/texinfo-1.cfg
new file mode 100644
index 0000000..d1fc2a0
--- /dev/null
+++ b/source-builder/config/texinfo-1.cfg
@@ -0,0 +1,107 @@
+#
+# GNU texinfo 7.xx Version 1.
+#
+# This configuration file configure's, make's and install's GNU's texinfo
+#
+
+%if %{release} == %{nil}
+ %define release 1
+%endif
+
+%ifn %{defined _internal_texinfo}
+ %define _internal_texinfo no
+%endif
+
+Name: texinfo-%{texinfo_version}-%{_host}-%{release}
+Summary: GNU texinfo v%{texinfo_version} for host %{_host}
+Version: %{texinfo_version}
+Release: %{release}
+URL: https://www.gnu.org/software/texinfo/
+
+#
+# Source
+#
+%source set texinfo https://ftp.gnu.org/gnu/texinfo/texinfo-%{texinfo_version}.tar.gz
+
+#
+# Remap the install paths if it is an internal build
+#
+%if %{_internal_texinfo} == yes
+ %if !%{defined _internal_texinfo_path}
+ %error no texinfo internal install path defined
+ %endif
+ %define texinfo_prefix %{_internal_texinfo_path}
+%else
+ %define texinfo_prefix %{_prefix}
+%endif
+
+%define texinfo_exec_prefix %{texinfo_prefix}
+%define texinfo_bindir %{texinfo_exec_prefix}/bin
+%define texinfo_sbindir %{texinfo_exec_prefix}/sbin
+%define texinfo_libexecdir %{texinfo_exec_prefix}/libexec
+%define texinfo_datarootdir %{texinfo_prefix}/share
+%define texinfo_datadir %{texinfo_datarootdir}
+%define texinfo_sysconfdir %{texinfo_prefix}/etc
+%define texinfo_sharedstatedir %{texinfo_prefix}/com
+%define texinfo_localstatedir %{texinfo_prefix}/var
+%define texinfo_includedir %{texinfo_prefix}/include
+%define texinfo_libdir %{texinfo_exec_prefix}/%{_lib}
+%define texinfo_mandir %{texinfo_datarootdir}/man
+%define texinfo_infodir %{texinfo_datarootdir}/info
+%define texinfo_localedir %{texinfo_datarootdir}/locale
+
+#
+# Prepare the source code.
+#
+%prep
+ build_top=$(pwd)
+
+ source_dir_texinfo="texinfo-%{texinfo_version}"
+ %source setup texinfo -q -n texinfo-%{texinfo_version}
+ %patch setup texinfo -p1
+
+ cd ${build_top}
+
+%build
+ build_top=$(pwd)
+
+ %if %{defined _internal_texinfo_path}
+ export PATH="%{_internal_texinfo_path}/bin:${PATH}"
+ %endif
+
+ %{build_directory}
+
+ mkdir -p ${build_dir}
+ cd ${build_dir}
+
+ %{host_build_flags}
+
+ ../${source_dir_texinfo}/configure \
+ --prefix=%{texinfo_prefix} \
+ --bindir=%{texinfo_bindir} \
+ --exec_prefix=%{texinfo_exec_prefix} \
+ --includedir=%{texinfo_includedir} \
+ --libdir=%{texinfo_libdir} \
+ --libexecdir=%{texinfo_libexecdir} \
+ --mandir=%{texinfo_mandir} \
+ --infodir=%{texinfo_infodir} \
+ --datadir=%{texinfo_datadir} \
+
+ %{__make} %{?_smp_mflags} all
+
+ cd ${build_top}
+
+%install
+ build_top=$(pwd)
+
+ %{__rmdir} $SB_BUILD_ROOT
+
+ cd ${build_dir}
+
+ %if %{_internal_texinfo} == yes
+ %{__make} install
+ %else
+ %{__make} DESTDIR=$SB_BUILD_ROOT install
+ %endif
+
+ cd ${build_top}
diff --git a/source-builder/defaults.mc b/source-builder/defaults.mc
index 8ed7003..6575e35 100644
--- a/source-builder/defaults.mc
+++ b/source-builder/defaults.mc
@@ -98,7 +98,7 @@ _host_cc: none, none, 'gcc'
_host_cxx: none, none, 'g++'
_arch: none, none, '%{_host_arch}'
_topdir: dir, required, '%{_cwd}'
-_configdir: dir, optional, '%{_topdir}/config:%{_sbdir}/config:%{_sbtop}/bare/config'
+_configdir: dir, optional, '%{_topdir}/config:%{_sbdir}/config:%{_sbtop}/bare/config:%{_sbtop}/rtems/config'
_tardir: dir, optional, '%{_topdir}/tar'
_sourcedir: dir, optional, '%{_topdir}/sources'
_patchdir: dir, optional, '%{_topdir}/patches:%{_sbdir}/patches'
@@ -109,6 +109,7 @@ _docdir: dir, none, '%{_defaultdocdir}'
_tmppath: dir, none, '%{_topdir}/build/tmp'
_tmproot: dir, none, '%{_tmppath}/sb-%{_uid}/%{_bset_tmp}'
_tmpcxcroot: dir, none, '%{_tmppath}/sb-%{_uid}-cxc/%{_bset_tmp}'
+_tmpinternal: dir, none, '%{_tmppath}/sb-%{_uid}-internal'
_datadir: dir, none, '%{_prefix}/share'
_defaultdocdir: dir, none, '%{_prefix}/share/doc'
_dry_run: none, none, '0'
@@ -131,7 +132,7 @@ _infodir: dir, none, '%{_datarootdir}/info'
_localedir: dir, none, '%{_datarootdir}/locale'
_localedir: dir, none, '%{_datadir}/locale'
_localstatedir: dir, none, '%{_prefix}/var'
-_pathprepend: none, none, ''
+_pathprepend: none, none, '%{_tmpinternal}/bin'
_pathpostpend: none, none, ''
_prefix: dir, none, '%{_usr}'
_usr: dir, none, '/usr/local'
@@ -179,18 +180,17 @@ __ld: exe, required, '/usr/bin/ld'
__ldconfig: exe, required, '/sbin/ldconfig'
__ln_s: exe, none, 'ln -s'
__make: exe, required, 'make'
-__makeinfo: exe, required, '/usr/bin/makeinfo'
+__makeinfo: exe, optional, '/usr/bin/makeinfo'
__mkdir: exe, required, '/bin/mkdir'
__mkdir_p: exe, none, '/bin/mkdir -p'
__mv: exe, required, '/bin/mv'
__nm: exe, required, '/usr/bin/nm'
-__objcopy: exe, optional, '/usr/bin/objcopy'
-__objdump: exe, optional, '/usr/bin/objdump'
+__objcopy: exe, none, '/usr/bin/objcopy'
+__objdump: exe, none, '/usr/bin/objdump'
__patch_bin: exe, required, '/usr/bin/patch'
__patch_opts: none, none, '%{nil}'
__patch: exe, none, '%{__patch_bin} %{__patch_opts}'
__perl: exe, optional, 'perl'
-__svn: exe, optional, '/usr/bin/svn'
__ranlib: exe, required, 'ranlib'
__rm: exe, required, '/bin/rm'
__rmfile: exe, none, '%{__rm} -f'
diff --git a/source-builder/pkg-config b/source-builder/pkg-config
index 10db546..8d0a174 100755
--- a/source-builder/pkg-config
+++ b/source-builder/pkg-config
@@ -86,6 +86,19 @@ def log(s, lf = True):
sys.stdout.flush()
print(s, end = '', file = out)
+def cflags_filter(cflags, prefixes, include=True):
+ cflags = cflags.split(' ')
+ f_cflags = []
+ for f in cflags:
+ for p in prefixes:
+ if f.startswith(p):
+ f_cflags += [f]
+ if not include:
+ not_f_cflags = [f for f in cflags if f not in f_cflags]
+ f_cflags = not_f_cflags
+ return ' '.join(f_cflags)
+
+
def run(argv):
class version_action(argparse.Action):
@@ -110,6 +123,7 @@ def run(argv):
help = 'Make error messages short.')
opts.add_argument('--silence-errors', dest = 'silence_errors', action = 'store_true',
default = False,
+
help = 'Do not print any errors.')
opts.add_argument('--errors-to-stdout', dest = 'errors_to_stdout', action = 'store_true',
default = False,
@@ -118,6 +132,14 @@ def run(argv):
default = False,
help = 'This prints pre-processor and compile flags required to' \
' compile the package(s)')
+ opts.add_argument('--cflags-only-I', dest = 'cflags_only_i', action = 'store_true',
+ default = False,
+ help = 'This prints the -I part of "--cflags". That is, it defines the header' \
+ 'search path but doesn\'t specify anything else.')
+ opts.add_argument('--cflags-only-other', dest = 'cflags_only_other', action = 'store_true',
+ default = False,
+ help = 'Return all compiler flags, other than the include path flags, ' \
+ 'required to compile against the package.')
opts.add_argument('--libs', dest = 'libs', action = 'store_true',
default = False,
help = 'This option is identical to "--cflags", only it prints the' \
@@ -193,6 +215,20 @@ def run(argv):
log('cflags: %s' % (flags['cflags']))
else:
log('cflags: empty')
+ if args.cflags_only_i:
+ cflags = cflags_filter(flags['cflags'], ['-I', '-system'], True)
+ if len(cflags):
+ print(cflags)
+ log('cflags: %s' % (flags['cflags']))
+ else:
+ log('cflags: empty')
+ if args.cflags_only_other:
+ cflags = cflags_filter(flags['cflags'], ['-I', '-system'], False)
+ if len(cflags):
+ print(cflags)
+ log('cflags: %s' % (flags['cflags']))
+ else:
+ log('cflags: empty')
if args.libs:
if len(flags['libs']):
print(flags['libs'])
diff --git a/source-builder/sb-rtems-pkg b/source-builder/sb-rtems-pkg
new file mode 100755
index 0000000..99ed26c
--- /dev/null
+++ b/source-builder/sb-rtems-pkg
@@ -0,0 +1,29 @@
+#! /usr/bin/env python
+#
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2024 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+from __future__ import print_function
+
+try:
+ import sb.rtemspkg
+ sb.rtemspkg.run()
+except ImportError:
+ import sys
+ print("Incorrect Source Builder installation", file = sys.stderr)
+ sys.exit(1)
diff --git a/source-builder/sb/build.py b/source-builder/sb/build.py
index 16a495b..5b80912 100644
--- a/source-builder/sb/build.py
+++ b/source-builder/sb/build.py
@@ -76,6 +76,14 @@ class script:
def __init__(self):
self.reset()
+ def __str__(self):
+ i = 0
+ text = []
+ for l in self.body:
+ i += 1
+ text += ['script:%3d: %s' % (self.lc + i, l)]
+ return os.linesep.join(text)
+
def reset(self):
self.body = []
self.lc = 0
@@ -103,7 +111,7 @@ class script:
s = None
try:
s = open(path.host(name), 'w')
- s.write('\n'.join(self.body))
+ s.write(os.linesep.join(self.body))
s.close()
os.chmod(path.host(name), stat.S_IRWXU | \
stat.S_IRGRP | stat.S_IXGRP | \
@@ -434,8 +442,8 @@ class build:
def builddir(self):
builddir = self.config.abspath('_builddir')
- self.rmdir(builddir)
if not self.opts.dry_run():
+ self.rmdir(builddir)
self.mkdir(builddir)
def prep(self, package):
@@ -583,12 +591,16 @@ class build:
self.script_build.append('echo "=> ' + name + ': BUILD"')
self.prep(package)
self.build_package(package)
+ self.builddir()
+ build_sn = path.join(self.config.expand('%{_builddir}'), 'do-build')
+ clean_sn = path.join(self.config.expand('%{_builddir}'), 'do-clean')
+ log.trace('script: ' + build_sn)
+ log.trace(str(self.script_build))
+ log.trace('script: ' + clean_sn)
+ log.trace(str(self.script_clean))
if not self.opts.dry_run():
- self.builddir()
- build_sn = path.join(self.config.expand('%{_builddir}'), 'do-build')
log.output('write script: ' + build_sn)
self.script_build.write(build_sn)
- clean_sn = path.join(self.config.expand('%{_builddir}'), 'do-clean')
log.output('write script: ' + clean_sn)
self.script_clean.write(clean_sn)
log.notice('building: %s%s' % (cxc_label, name))
diff --git a/source-builder/sb/config.py b/source-builder/sb/config.py
index 5bc96e2..06762d6 100644
--- a/source-builder/sb/config.py
+++ b/source-builder/sb/config.py
@@ -68,6 +68,13 @@ def _check_nil(value):
istrue = False
return istrue
+def _check_number(value):
+ try:
+ float(value)
+ return True
+ except ValueError:
+ return False
+
class package:
def __init__(self, name, arch, config):
@@ -251,7 +258,7 @@ class file:
re.compile('%select'),
re.compile('%disable') ]
- def __init__(self, name, opts, macros = None):
+ def __init__(self, name, opts, macros = None, load = True):
log.trace('config: %s: initialising' % (name))
self.opts = opts
self.init_name = name
@@ -260,7 +267,8 @@ class file:
self.sf = re.compile(r'%\([^\)]+\)')
self.set_macros(macros)
self._reset(name)
- self.load(name)
+ if load:
+ self.load(name)
def __str__(self):
@@ -778,7 +786,16 @@ class file:
mn = '%{nil}'
if mn:
if mn.lower() in self.macros:
- s = s.replace(m, self.macros[mn.lower()])
+ em = self.macros[mn.lower()]
+ if self.macros.get_type(mn) == 'dir' and ':' in em:
+ ss = []
+ for sp in s.split():
+ if m in sp:
+ sp = ':'.join([sp.replace(mn, ps) for ps in em.split(':')])
+ ss += [sp]
+ s = ' '.join(ss)
+ else:
+ s = s.replace(m, self.macros[mn.lower()])
expanded = True
elif show_warning:
self._error("macro '%s' not found" % (mn))
@@ -915,6 +932,12 @@ class file:
(self.name, self.lc,
self.if_depth,
join_op))
+ # If OR and the previous check was true short circuit the evaluation
+ if join_op == 'or' and cistrue:
+ log.trace('config: %s: %3d: _if[%i]: OR true, short circuit eval' % \
+ (self.name, self.lc,
+ self.if_depth))
+ break
ori = 0
andi = 0
i = len(cls)
@@ -935,10 +958,8 @@ class file:
i = andi
elif andi == 0:
i = ori
- elif ori < andi:
- i = andi
else:
- i = andi
+ i = min(ori, andi)
log.trace('config: %s: %3d: _if[%i]: next OP found at %i' % \
(self.name, self.lc,
self.if_depth,
@@ -996,37 +1017,27 @@ class file:
ifls = (' '.join(ifls[:op_pos]), op, ' '.join(ifls[op_pos + 1:]))
break
if len(ifls) != 3:
- self._error('malformed if: ' + reduce(add, ls, ''))
- if ifls[1] == '==':
- if ifls[0] == ifls[2]:
- istrue = True
- else:
- istrue = False
- elif ifls[1] == '!=' or ifls[1] == '=!':
- if ifls[0] != ifls[2]:
- istrue = True
- else:
- istrue = False
- elif ifls[1] == '>':
- if ifls[0] > ifls[2]:
- istrue = True
- else:
- istrue = False
- elif ifls[1] == '>=' or ifls[1] == '=>':
- if ifls[0] >= ifls[2]:
- istrue = True
- else:
- istrue = False
- elif ifls[1] == '<=' or ifls[1] == '=<':
- if ifls[0] <= ifls[2]:
- istrue = True
- else:
- istrue = False
- elif ifls[1] == '<':
- if ifls[0] < ifls[2]:
- istrue = True
- else:
- istrue = False
+ self._error('malformed if: ' + reduce(add, ls, ''))
+ lhs = ifls[0]
+ operator = ifls[1]
+ rhs = ifls[2]
+ if _check_number(lhs) and _check_number(rhs):
+ log.trace('config: %s: %3d: _if: numeric value check' % \
+ (self.name, self.lc))
+ lhs = float(lhs)
+ rhs = float(rhs)
+ if operator == '==':
+ istrue = lhs == rhs
+ elif operator == '!=' or operator == '=!':
+ istrue = lhs != rhs
+ elif operator == '>':
+ istrue = lhs > rhs
+ elif operator == '>=' or operator == '=>':
+ istrue = lhs >= rhs
+ elif operator == '<=' or operator == '=<':
+ istrue = lhs <= rhs
+ elif operator == '<':
+ istrue = lhs < rhs
else:
self._error('invalid %if operator: ' + reduce(add, ls, ''))
@@ -1344,6 +1355,14 @@ class file:
right = right[:-1]
return end
+ def search_path(confignames):
+ for configname in confignames.split(':'):
+ if not configname.endswith('.cfg'):
+ configname = '%s.cfg' % (configname)
+ if path.exists(configname):
+ return configname
+ return None
+
if self.load_depth == 0:
self._packages[self.package] = package(self.package,
self.define('%{_arch}'),
@@ -1357,7 +1376,7 @@ class file:
#
# Locate the config file. Expand any macros then add the
- # extension. Check if the file exists, therefore directly
+ # extension. Check if the file exists then it is directly
# referenced. If not see if the file contains ':' or the path
# separator. If it does split the path else use the standard config dir
# path in the defaults.
@@ -1365,32 +1384,13 @@ class file:
exname = self.expand(name)
- #
- # Macro could add an extension.
- #
- if exname.endswith('.cfg'):
- configname = exname
- else:
- configname = '%s.cfg' % (exname)
- name = '%s.cfg' % (name)
-
- if ':' in configname:
- cfgname = path.basename(configname)
- else:
- cfgname = common_end(configname, name)
+ configname = search_path(exname)
+ if configname is None:
+ configname = search_path(self.expand(path.join('%{_configdir}', exname)))
+ if configname is None:
+ raise error.general('no config file found: %s' % (','.join(exname.split(':'))))
- if not path.exists(configname):
- if ':' in configname:
- configdirs = path.dirname(configname).split(':')
- else:
- configdirs = self.define('_configdir').split(':')
- for cp in configdirs:
- configname = path.join(path.abspath(cp), cfgname)
- if path.exists(configname):
- break
- configname = None
- if configname is None:
- raise error.general('no config file found: %s' % (cfgname))
+ name = path.basename(configname)
try:
log.trace('config: %s: _open: %s' % (self.name, path.host(configname)))
diff --git a/source-builder/sb/download.py b/source-builder/sb/download.py
index 410edeb..0201675 100644
--- a/source-builder/sb/download.py
+++ b/source-builder/sb/download.py
@@ -85,6 +85,8 @@ def _hash_check(file_, absfile, macros, remove = True):
hash = hash.split()
if len(hash) != 2:
raise error.internal('invalid hash format: %s' % (file_))
+ if hash[0] == 'NO-HASH':
+ return not failed
try:
hashlib_algorithms = hashlib.algorithms
except:
@@ -132,9 +134,7 @@ def _hash_check(file_, absfile, macros, remove = True):
if hasher is not None:
del hasher
else:
- if version.released():
- raise error.general('%s: no hash found in released RSB' % (file_))
- log.warning('%s: no hash found' % (file_))
+ raise error.general('%s: no hash found' % (file_))
return not failed
def _local_path(source, pathkey, config):
@@ -191,7 +191,7 @@ def _http_parser(source, pathkey, config, opts):
#
# Wipe out everything special in the file name.
#
- source['file'] = re.sub(r'[^a-zA-Z0-9.\-]+', '-', source['file'])
+ source['file'] = re.sub(r'[^a-zA-Z0-9.\-_]+', '-', source['file'])
max_file_len = 127
if len(source['file']) > max_file_len:
raise error.general('file name length is greater than %i (maybe use --rsb-file=FILE option): %s' % \
@@ -481,7 +481,8 @@ def _git_downloader(url, local, config, opts):
else:
repo.clean(['-f', '-d'])
repo.reset('--hard')
- repo.checkout('master')
+ default_branch = repo.default_branch()
+ repo.checkout(default_branch)
for a in us[1:]:
_as = a.split('=')
if _as[0] == 'branch' or _as[0] == 'checkout':
diff --git a/source-builder/sb/ereport.py b/source-builder/sb/ereport.py
index d8fb5f6..52ee2eb 100755
--- a/source-builder/sb/ereport.py
+++ b/source-builder/sb/ereport.py
@@ -54,7 +54,9 @@ def generate(name, opts, header = None, footer = None):
name = name.replace('/', '-')
with open(name, 'w') as l:
l.write(os.linesep.join(r))
- log.notice(' See error report: %s' % (name))
+ log.notice(os.linesep.join([' See error report: %s' % (name),
+ ' Note: In some cases the error appears only in',
+ ' the complete build log (see --log option)']))
except:
log.stderr('error: failure to create error report')
raise
diff --git a/source-builder/sb/execute.py b/source-builder/sb/execute.py
index 3db9abc..b491c47 100755
--- a/source-builder/sb/execute.py
+++ b/source-builder/sb/execute.py
@@ -27,6 +27,7 @@
from __future__ import print_function
import functools
+import codecs
import io
import os
import re
@@ -181,6 +182,10 @@ class execute(object):
if trace_threads:
print('execute:_readthread: start')
+ if sys.stdout.encoding is not None:
+ decoder = codecs.getincrementaldecoder(sys.stdout.encoding)()
+ else:
+ decoder = None
count = 0
line = ''
try:
@@ -200,8 +205,8 @@ class execute(object):
_output_line(line + '\n', exe, prefix, out, count)
break
# str and bytes are the same type in Python2
- if type(data) is not str and type(data) is bytes:
- data = data.decode(sys.stdout.encoding)
+ if decoder is not None and type(data) is not str and type(data) is bytes:
+ data = decoder.decode(data)
last_ch = data[-1]
sd = (line + data).split('\n')
if last_ch != '\n':
diff --git a/source-builder/sb/freebsd.py b/source-builder/sb/freebsd.py
index 472f670..628ef22 100644
--- a/source-builder/sb/freebsd.py
+++ b/source-builder/sb/freebsd.py
@@ -101,22 +101,24 @@ def load():
cxx = '/usr/bin/clang++'
if check.check_exe(cxx, cxx):
raise error.general('no valid c++ found')
- #
- # Assume the compiler is clang and so we need to increase
- # bracket depth build build the gcc ARM compiler.
- #
- defines['build_cflags'] = '-O2 -pipe -fbracket-depth=1024'
- defines['build_cxxflags'] = '-O2 -pipe -fbracket-depth=1024'
cvs = 'cvs'
if check.check_exe(cvs, cvs):
defines['__cvs'] = cvs
+ defines['build_cflags'] = '-O2 -pipe'
+ defines['build_cxxflags'] = '-O2 -pipe'
+ if fb_version <= 12:
+ #
+ # Assume the compiler is clang and so we need to increase
+ # bracket depth build build the gcc ARM compiler.
+ #
+ defines['build_cflags'] += ' -fbracket-depth=1024'
+ defines['build_cxxflags'] += ' -fbracket-depth=1024'
#
# Fix the mess iconv is on FreeBSD 10.0 and higher.
#
defines['iconv_includes'] = ('none', 'none', '%{host_includes} %{host_ldflags}')
if fb_version >= 12:
defines['iconv_prefix'] = ('none', 'none', '%{_usr}')
-
#
# On 11.0+ makeinfo and install-info have moved to /usr/local/...
#
diff --git a/source-builder/sb/getsources.py b/source-builder/sb/getsources.py
index d348da4..eb5c855 100644
--- a/source-builder/sb/getsources.py
+++ b/source-builder/sb/getsources.py
@@ -60,7 +60,9 @@ def run(args = sys.argv):
default = version.version())
argsp.add_argument('--list-hosts', help = 'List the hosts.',
action = 'store_true')
- argsp.add_argument('--list-bsets', help = 'List the hosts.',
+ argsp.add_argument('--list-bsets', help = 'List the buildsets.',
+ action = 'store_true')
+ argsp.add_argument('--list-root-bsets', help = 'List the toplevel or root buildsets.',
action = 'store_true')
argsp.add_argument('--download-dir', help = 'Download directory.',
type = str)
@@ -71,8 +73,14 @@ def run(args = sys.argv):
argsp.add_argument('--log', help = 'Log file.',
type = str,
default = simhost.log_default('getsource'))
+ argsp.add_argument('--stop-on-error', help = 'Stop on error.',
+ action = 'store_true')
argsp.add_argument('--trace', help = 'Enable trace logging for debugging.',
action = 'store_true')
+ argsp.add_argument('--used', help = 'Save the used buildset and config files.',
+ type = str, default = None)
+ argsp.add_argument('--unused', help = 'Save the unused buildset and config files.',
+ type = str, default = None)
argsp.add_argument('bsets', nargs='*', help = 'Build sets.')
argopts = argsp.parse_args(args[1:])
@@ -84,10 +92,14 @@ def run(args = sys.argv):
opts = simhost.load_options(args, argopts, extras = ['--with-download'])
configs = build.get_configs(opts)
+ stop_on_error = argopts.stop_on_error
+
if argopts.list_hosts:
simhost.list_hosts()
elif argopts.list_bsets:
simhost.list_bset_files(opts, configs)
+ elif argopts.list_root_bsets:
+ simhost.list_root_bset_files(opts, configs)
else:
if argopts.clean:
if argopts.download_dir is None:
@@ -95,11 +107,11 @@ def run(args = sys.argv):
if path.exists(argopts.download_dir):
log.notice('Cleaning source directory: %s' % (argopts.download_dir))
path.removeall(argopts.download_dir)
- all_bsets = simhost.get_bset_files(configs)
if len(argopts.bsets) == 0:
- bsets = all_bsets
+ bsets = simhost.get_root_bset_files(opts, configs)
else:
bsets = argopts.bsets
+ deps = copy.copy(simhost.strip_common_prefix(bsets))
for bset in bsets:
b = None
try:
@@ -108,11 +120,23 @@ def run(args = sys.argv):
b = simhost.buildset(bset, configs, opts)
get_sources_error = False
b.build(host)
+ deps += b.deps()
del b
except error.general as gerr:
+ if stop_on_error:
+ raise
log.stderr(str(gerr))
log.stderr('Build FAILED')
b = None
+ deps = sorted(list(set(deps)))
+ if argopts.used:
+ with open(argopts.used, 'w') as o:
+ o.write(os.linesep.join(deps))
+ if argopts.unused:
+ cfgs_bsets = \
+ [cb for cb in simhost.get_config_bset_files(opts, configs) if not cb in deps]
+ with open(argopts.unused, 'w') as o:
+ o.write(os.linesep.join(cfgs_bsets))
except error.general as gerr:
if get_sources_error:
log.stderr(str(gerr))
diff --git a/source-builder/sb/git.py b/source-builder/sb/git.py
index 237e690..0aa4da9 100644
--- a/source-builder/sb/git.py
+++ b/source-builder/sb/git.py
@@ -226,6 +226,18 @@ class repo:
hash = l1[len('commit '):]
return hash
+ def default_branch(self):
+ ec, output = self._run(['remote', 'show'])
+ if ec == 0:
+ origin = output.split('\n')[0]
+ ec, output = self._run(['remote', 'show', origin])
+ if ec == 0:
+ for l in output.split('\n'):
+ l = l.strip()
+ if l.startswith('HEAD branch: '):
+ return l[len('HEAD branch: '):]
+ return None
+
if __name__ == '__main__':
import os.path
import sys
diff --git a/source-builder/sb/linux.py b/source-builder/sb/linux.py
index d89377b..45f88b0 100644
--- a/source-builder/sb/linux.py
+++ b/source-builder/sb/linux.py
@@ -28,6 +28,7 @@ import pprint
import os
from . import path
+from . import log
def load():
uname = os.uname()
@@ -56,40 +57,11 @@ def load():
}
# platform.dist() was removed in Python 3.8
- if hasattr(platform, 'dist'):
- # Works for LSB distros
- try:
- distro = platform.dist()[0]
- distro_ver = float(platform.dist()[1])
- except ValueError:
- # Non LSB distro found, use failover"
- pass
- else:
- distro = ''
-
- # Non LSB - fail over to issue
- if distro == '':
- try:
- issue = open('/etc/issue').read()
- distro = issue.split(' ')[0]
- distro_ver = float(issue.split(' ')[2])
- except:
- pass
-
- # Manage distro aliases
- if distro in ['centos']:
- distro = 'redhat'
- elif distro in ['fedora']:
- if distro_ver < 17:
- distro = 'redhat'
- elif distro in ['centos', 'fedora']:
- distro = 'redhat'
- elif distro in ['Ubuntu', 'ubuntu', 'MX', 'LinuxMint', 'linuxmint']:
- distro = 'debian'
- elif distro in ['Arch']:
- distro = 'arch'
- elif distro in ['SuSE']:
- distro = 'suse'
+ # The distro module (introduced in Python 3.6, back-ported to 2.6)
+ # is preferred.
+ distro = ''
+ distro_like = ''
+ distro_ver = 0
variations = {
'debian' : { '__bzip2': ('exe', 'required', '/bin/bzip2'),
@@ -118,10 +90,63 @@ def load():
'__sed': ('exe', 'required', '/bin/sed') },
}
+ try:
+ import distro as distro_mod
+ distro = distro_mod.id()
+ distro_like = distro_mod.like()
+ try:
+ distro_ver = float(distro_mod.version())
+ except ValueError:
+ pass
+ except:
+ pass
+
+ if distro == '' and hasattr(platform, 'dist'):
+ distro = platform.dist()[0]
+ try:
+ distro_ver = float(platform.dist()[1])
+ except ValueError:
+ pass
+
+ # Non LSB - last resort, try issue
+ if distro == '':
+ try:
+ with open('/etc/issue') as f:
+ issue = f.read().split(' ')
+ distro = issue[0]
+ distro_ver = float(issue[2])
+ except:
+ pass
+
+ if distro:
+ distro = distro.lower()
+ if distro_like:
+ distro_like = distro_like.lower().split(' ')[0]
+
+ # Some additional distro aliases
+ if distro in ['centos']:
+ distro_like = 'redhat'
+ elif distro in ['fedora']:
+ if distro_ver < 17:
+ distro_like = 'redhat'
+ elif distro in ['ubuntu', 'mx', 'linuxmint']:
+ distro_like = 'debian'
+
+ if not (distro in variations) and (distro_like in variations):
+ distro = distro_like
+ # Versions don't carry over to likes; e.g. linuxmint 21.6 != debian 21.6.
+ distro_ver = 0
+
if distro in variations:
for v in variations[distro]:
if path.exists(variations[distro][v][2]):
defines[v] = variations[distro][v]
+ else:
+ log.warning('Unrecognized OS distro; assuming defaults for grep, sed, etc.')
+ try:
+ distro_mod
+ except:
+ log.warning("The 'distro' package may fix this problem; try 'pip install distro'.")
defines['_build'] = defines['_host']
defines['_build_vendor'] = defines['_host_vendor']
diff --git a/source-builder/sb/mailer.py b/source-builder/sb/mailer.py
index ff25df5..aafe6d6 100644
--- a/source-builder/sb/mailer.py
+++ b/source-builder/sb/mailer.py
@@ -1,21 +1,33 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2013 Chris Johns (chrisj@rtems.org)
+# Copyright 2013-2016 Chris Johns (chrisj@rtems.org)
+# Copyright (C) 2021 On-Line Applications Research Corporation (OAR)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Manage emailing results or reports.
@@ -28,18 +40,72 @@ import smtplib
import socket
from . import error
+from . import execute
from . import options
from . import path
+_options = {
+ '--mail' : 'Send email report or results.',
+ '--use-gitconfig': 'Use mail configuration from git config.',
+ '--mail-to' : 'Email address to send the email to.',
+ '--mail-from' : 'Email address the report is from.',
+ '--smtp-host' : 'SMTP host to send via.',
+ '--smtp-port' : 'SMTP port to send via.',
+ '--smtp-user' : 'User for SMTP authentication.',
+ '--smtp-password': 'Password for SMTP authentication.'
+}
+
def append_options(opts):
- opts['--mail'] = 'Send email report or results.'
- opts['--smtp-host'] = 'SMTP host to send via.'
- opts['--mail-to'] = 'Email address to send the email too.'
- opts['--mail-from'] = 'Email address the report is from.'
+ for o in _options:
+ opts[o] = _options[o]
+
+def add_arguments(argsp):
+ argsp.add_argument('--mail', help = _options['--mail'], action = 'store_true')
+ argsp.add_argument('--use-gitconfig', help = _options['--use-gitconfig'], action = 'store_true')
+ no_add = ['--mail', '--use-gitconfig']
+ for o in [opt for opt in list(_options) if opt not in no_add]:
+ argsp.add_argument(o, help = _options[o], type = str)
class mail:
def __init__(self, opts):
self.opts = opts
+ self.gitconfig_lines = None
+ if opts.find_arg('--use-gitconfig') is not None:
+ # Read the output of `git config --list` instead of reading the
+ # .gitconfig file directly because Python 2 ConfigParser does not
+ # accept tabs at the beginning of lines.
+ e = execute.capture_execution()
+ exit_code, proc, output = e.open('git config --list', shell=True)
+ if exit_code == 0:
+ self.gitconfig_lines = output.split(os.linesep)
+
+ def _args_are_macros(self):
+ return isinstance(self.opts, options.command_line)
+
+ def _get_arg(self, arg):
+ if self._args_are_macros():
+ value = self.opts.find_arg(arg)
+ if value is not None:
+ value = self.opts.find_arg(arg)[1]
+ else:
+ if arg.startswith('--'):
+ arg = arg[2:]
+ arg = arg.replace('-', '_')
+ if arg in vars(self.opts):
+ value = vars(self.opts)[arg]
+ else:
+ value = None
+ return value
+
+ def _get_from_gitconfig(self, variable_name):
+ if self.gitconfig_lines is None:
+ return None
+
+ for line in self.gitconfig_lines:
+ if line.startswith(variable_name):
+ ls = line.split('=')
+ if len(ls) >= 2:
+ return ls[1]
def from_address(self):
@@ -52,9 +118,15 @@ class mail:
l = l[:l.index('\n')]
return l.strip()
- addr = self.opts.get_arg('--mail-from')
+ addr = self._get_arg('--mail-from')
if addr is not None:
- return addr[1]
+ return addr
+ addr = self._get_from_gitconfig('user.email')
+ if addr is not None:
+ name = self._get_from_gitconfig('user.name')
+ if name is not None:
+ addr = '%s <%s>' % (name, addr)
+ return addr
mailrc = None
if 'MAILRC' in os.environ:
mailrc = os.environ['MAILRC']
@@ -63,9 +135,8 @@ class mail:
if mailrc is not None and path.exists(mailrc):
# set from="Joe Blow <joe@blow.org>"
try:
- mrc = open(mailrc, 'r')
- lines = mrc.readlines()
- mrc.close()
+ with open(mailrc, 'r') as mrc:
+ lines = mrc.readlines()
except IOError as err:
raise error.general('error reading: %s' % (mailrc))
for l in lines:
@@ -76,40 +147,99 @@ class mail:
addr = fa[fa.index('=') + 1:].replace('"', ' ').strip()
if addr is not None:
return addr
- addr = self.opts.defaults.get_value('%{_sbgit_mail}')
+ if self._args_are_macros():
+ addr = self.opts.defaults.get_value('%{_sbgit_mail}')
+ else:
+ raise error.general('no valid from address for mail')
return addr
def smtp_host(self):
- host = self.opts.get_arg('--smtp-host')
+ host = self._get_arg('--smtp-host')
if host is not None:
- return host[1]
- host = self.opts.defaults.get_value('%{_mail_smtp_host}')
+ return host
+ host = self._get_from_gitconfig('sendemail.smtpserver')
+ if host is not None:
+ return host
+ if self._args_are_macros():
+ host = self.opts.defaults.get_value('%{_mail_smtp_host}')
if host is not None:
return host
return 'localhost'
+ def smtp_port(self):
+ port = self._get_arg('--smtp-port')
+ if port is not None:
+ return port
+ port = self._get_from_gitconfig('sendemail.smtpserverport')
+ if port is not None:
+ return port
+ if self._args_are_macros():
+ port = self.opts.defaults.get_value('%{_mail_smtp_port}')
+ return port
+
+ def smtp_user(self):
+ user = self._get_arg('--smtp-user')
+ if user is not None:
+ return user
+ user = self._get_from_gitconfig('sendemail.smtpuser')
+ return user
+
+ def smtp_password(self):
+ password = self._get_arg('--smtp-password')
+ if password is not None:
+ return password
+ password = self._get_from_gitconfig('sendemail.smtppass')
+ return password
+
def send(self, to_addr, subject, body):
from_addr = self.from_address()
msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % \
(from_addr, to_addr, subject) + body
- if type(to_addr) is str:
- to_addr = to_addr.split(',')
- if type(to_addr) is not list:
- raise error.general('invalid to_addr type')
+ port = self.smtp_port()
+
try:
- s = smtplib.SMTP(self.smtp_host())
- s.sendmail(from_addr, to_addr, msg)
+ s = smtplib.SMTP(self.smtp_host(), port, timeout=10)
+
+ password = self.smtp_password()
+ # If a password is provided, assume that authentication is required.
+ if password is not None:
+ user = self.smtp_user()
+ if user is None:
+ user = from_addr
+ s.starttls()
+ s.login(user, password)
+
+ s.sendmail(from_addr, [to_addr], msg)
except smtplib.SMTPException as se:
raise error.general('sending mail: %s' % (str(se)))
except socket.error as se:
raise error.general('sending mail: %s' % (str(se)))
+ def send_file_as_body(self, to_addr, subject, name, intro = None):
+ try:
+ with open(name, 'r') as f:
+ body = f.readlines()
+ except IOError as err:
+ raise error.general('error reading mail body: %s' % (name))
+ if intro is not None:
+ body = intro + body
+ self.send(to_addr, from_addr, body)
+
if __name__ == '__main__':
import sys
+ from . import macros
optargs = {}
+ rtdir = 'source-builder'
+ defaults = '%s/defaults.mc' % (rtdir)
append_options(optargs)
- opts = options.load(sys.argv, optargs = optargs, defaults = 'defaults.mc')
+ opts = options.command_line(base_path = '.',
+ argv = sys.argv,
+ optargs = optargs,
+ defaults = macros.macros(name = defaults, rtdir = rtdir),
+ command_path = '.')
+ options.load(opts)
m = mail(opts)
print('From: %s' % (m.from_address()))
print('SMTP Host: %s' % (m.smtp_host()))
- m.send(m.from_address(), 'Test mailer.py', 'This is a test')
+ if '--mail' in sys.argv:
+ m.send(m.from_address(), 'Test mailer.py', 'This is a test')
diff --git a/source-builder/sb/options.py b/source-builder/sb/options.py
index d6bffd0..05ad208 100644
--- a/source-builder/sb/options.py
+++ b/source-builder/sb/options.py
@@ -46,7 +46,7 @@ basepath = 'sb'
#
# Save the host and POSIX state.
#
-host_windows = False
+host_windows = os.name == 'nt'
host_posix = True
class command_line:
@@ -103,6 +103,10 @@ class command_line:
self.defaults[self._long_opts[lo][0]] = ('none',
'none',
self._long_opts[lo][3])
+ # Set the _uid field, performance improvement on Unix
+ if not host_windows:
+ self.defaults['_uid'] = str(os.getuid())
+ self.defaults['_gid'] = str(os.getgid())
def __str__(self):
def _dict(dd):
@@ -235,7 +239,7 @@ class command_line:
print('--with-<label> : Add the --with-<label> to the build')
print('--without-<label> : Add the --without-<label> to the build')
print('--rtems-tools path : Path to an install RTEMS tool set')
- print('--rtems-bsp arc/bsp : Standard RTEMS architecure and BSP specifier')
+ print('--rtems-bsp arch/bsp : Standard RTEMS architecure and BSP specifier')
print('--rtems-version ver : The RTEMS major/minor version string')
if self.optargs:
for a in self.optargs:
@@ -517,6 +521,15 @@ class command_line:
return None
return self.parse_args(arg)
+ def find_arg(self, arg):
+ if self.optargs is None or arg not in self.optargs:
+ raise error.internal('bad arg: %s' % (arg))
+ for a in self.args:
+ sa = a.split('=')
+ if sa[0].startswith(arg):
+ return sa
+ return None
+
def with_arg(self, label, default = 'not-found'):
# the default if there is no option for without.
result = default
@@ -582,7 +595,22 @@ class command_line:
self.opts['no-install'] = '1'
def info(self):
- s = ' Command Line: %s%s' % (' '.join(self.argv), os.linesep)
+ # Filter potentially sensitive mail options out.
+ filtered_args = [
+ arg for arg in self.argv
+ if all(
+ smtp_opt not in arg
+ for smtp_opt in [
+ '--smtp-host',
+ '--mail-to',
+ '--mail-from',
+ '--smtp-user',
+ '--smtp-password',
+ '--smtp-port'
+ ]
+ )
+ ]
+ s = ' Command Line: %s%s' % (' '.join(filtered_args), os.linesep)
s += ' Python: %s' % (sys.version.replace('\n', ''))
return s
@@ -610,6 +638,7 @@ class command_line:
if len(ab) != 2:
raise error.general('invalid --rtems-bsp option')
self.args.append('--target=%s-rtems%s' % (ab[0], rtems_version))
+ self.args.append('--with-rtems-arch=%s' % (ab[0]))
self.args.append('--with-rtems-bsp=%s' % (ab[1]))
def load(args, optargs = None, defaults = '%{_sbdir}/defaults.mc', logfile = True):
diff --git a/source-builder/sb/path.py b/source-builder/sb/path.py
index b27cf14..d9e926e 100644
--- a/source-builder/sb/path.py
+++ b/source-builder/sb/path.py
@@ -58,7 +58,7 @@ def host(path):
def shell(path):
if isinstance(path, bytes):
- path = path.decode('ascii')
+ path = path.decode('utf8')
if path is not None:
if windows or windows_posix:
path = path.encode('ascii', 'ignore').decode('ascii')
@@ -71,6 +71,20 @@ def shell(path):
path = path.replace('//', '/')
return path
+def host_encode(dpath):
+ '''Encoding the path was present in the RSB however on a ZFS pool I am
+ seeing a failure with a go test in gcc:
+ gcc/testsuite/go.test/test/fixedbugs/issue27836.dir
+ Not encoding works however I am not sure why the encoding was added
+ so the following keeps the encoding and falls back to not encoded
+ if there is an error.0
+ '''
+ try:
+ return host(dpath).encode('utf8')
+ except:
+ pass
+ return dpath
+
def basename(path):
path = shell(path)
return shell(os.path.basename(host(path)))
@@ -189,11 +203,11 @@ def removeall(path):
# get to the max path length on Windows.
#
def _isdir(path):
- hpath = host(path)
+ hpath = host_encode(path)
return os.path.isdir(hpath) and not os.path.islink(hpath)
def _remove_node(path):
- hpath = host(path)
+ hpath = host_encode(path)
if not os.path.islink(hpath) and not os.access(hpath, os.W_OK):
os.chmod(hpath, stat.S_IWUSR)
if _isdir(path):
@@ -216,7 +230,7 @@ def removeall(path):
_remove_node(dir)
path = shell(path)
- hpath = host(path)
+ hpath = host_encode(path)
if os.path.exists(hpath):
_remove(path)
@@ -317,11 +331,11 @@ def get_size(path, depth = -1):
# get to the max path length on Windows.
#
def _isdir(path):
- hpath = host(path)
+ hpath = host_encode(path)
return os.path.isdir(hpath) and not os.path.islink(hpath)
def _node_size(path):
- hpath = host(path)
+ hpath = host_encode(path)
size = 0
if not os.path.islink(hpath):
size = os.path.getsize(hpath)
@@ -345,7 +359,7 @@ def get_size(path, depth = -1):
return size
path = shell(path)
- hpath = host(path)
+ hpath = host_encode(path)
size = 0
if os.path.exists(hpath):
diff --git a/source-builder/sb/pkgconfig.py b/source-builder/sb/pkgconfig.py
index 198ec80..bfe769f 100755
--- a/source-builder/sb/pkgconfig.py
+++ b/source-builder/sb/pkgconfig.py
@@ -90,7 +90,7 @@ class package(object):
get_recursion = ['cflags', 'libs']
no_dup_flags = ['-I', '-l', '-L']
dual_opts = ['-D', '-U', '-I', '-l', '-L']
- lib_list_splitter = re.compile('[\s,]+')
+ lib_list_splitter = re.compile(r'[\s,]+')
loaded_prefixes = None
loaded = {}
@@ -514,7 +514,7 @@ class package(object):
return None
s = ''
if self.file_:
- mre = re.compile('\$\{[^\}]+\}')
+ mre = re.compile(r'\$\{[^\}]+\}')
s = self.fields[label.lower()]
expanded = True
tm = False
diff --git a/source-builder/sb/rtems-build-dep b/source-builder/sb/rtems-build-dep
index 48a0823..71c8890 100755
--- a/source-builder/sb/rtems-build-dep
+++ b/source-builder/sb/rtems-build-dep
@@ -154,13 +154,16 @@ if [ ${op} = "library" ]; then
awk 'BEGIN {FS="-L"} {for (i=0;++i<=NF;) if (length($i) > 0) print $i;}')
for p in ${lib_paths_1} ${lib_paths_2}
do
- if [ ${verbose} = yes ]; then
- echo "Library: ${p}/${name}"
- fi
- if ls ${p}/${name} 1> /dev/null 2>&1; then
- echo "found"
- exit 0
- fi
+ for lname in ${name} lib${name}.a
+ do
+ if [ ${verbose} = yes ]; then
+ echo "Library: ${p}/${lname}"
+ fi
+ if ls ${p}/${lname} 1> /dev/null 2>&1; then
+ echo "found"
+ exit 0
+ fi
+ done
done
echo "not-found"
exit 0
diff --git a/source-builder/sb/rtems-kernel-config-check b/source-builder/sb/rtems-kernel-config-check
new file mode 100755
index 0000000..2256925
--- /dev/null
+++ b/source-builder/sb/rtems-kernel-config-check
@@ -0,0 +1,127 @@
+#! /usr/bin/env python
+"""
+SPDX-License-Identifier: BSD-2-Clause
+
+COPYRIGHT (C) 2021 On-Line Applications Research Corporation (OAR).
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+"""
+
+from __future__ import print_function
+
+import argparse
+import os.path
+import sys
+
+try:
+ import ConfigParser
+ configparser = ConfigParser # used for python2
+except ImportError:
+ try:
+ import configparser # used for python3
+ except ImportError:
+ print("Could not import configparser. Exiting...", file=sys.stderr)
+ sys.exit(1)
+
+
+def run():
+ parser = argparse.ArgumentParser()
+ parser.add_argument("config", help="path to config file")
+ parser.add_argument(
+ "-a",
+ "--arch",
+ help="return target architecture specified in the config",
+ action="store_true")
+ parser.add_argument("-b",
+ "--bsp",
+ help="return BSP specified in the config",
+ action="store_true")
+ parser.add_argument(
+ "-c",
+ "--arch-bsp",
+ help="return target architecture and BSP specified in the config",
+ action="store_true")
+ parser.add_argument("-v",
+ "--rtems-version",
+ help="version of RTEMS",
+ type=int,
+ default=6)
+ parser.add_argument("-t",
+ "--tests",
+ help="Build tests is true",
+ action="store_true")
+ args = parser.parse_args()
+ config = configparser.ConfigParser()
+
+ if args.config[-4:] != ".ini":
+ print("The config file is missing an *.ini extension.",
+ file=sys.stderr)
+ sys.exit(1)
+
+ if not os.path.exists(args.config):
+ print("Config file not found: " + args.config, file=sys.stderr)
+ sys.exit(1)
+
+ try:
+ config.read(args.config)
+ except configparser.MissingSectionHeaderError:
+ print("There is no section header in the config file", file=sys.stderr)
+ sys.exit(1)
+ except configparser.ParsingError:
+ print("An exception occured when parsing the config file",
+ file=sys.stderr)
+ sys.exit(1)
+ except:
+ print("An unknown exception occured", file=sys.stderr)
+
+ for arch_bsp in config.sections():
+ if len(arch_bsp.split("/")) != 2:
+ print("arch/bsp section in config is missing '/'", file=sys.stderr)
+ sys.exit(1)
+
+ if (args.arch or args.bsp) and args.arch_bsp:
+ args.arch = False
+
+ if args.arch:
+ print(' '.join([ab.split('/')[0] for ab in config.sections()]))
+ return
+
+ if args.bsp:
+ print(' '.join([ab.split('/')[1] for ab in config.sections()]))
+ return
+
+ if args.arch_bsp:
+ print(' '.join([arch_bsp for arch_bsp in config.sections()]))
+ return
+
+ if args.tests:
+ for sec in ["DEFAULT"] + config.sections():
+ for item in config[sec].items():
+ if item[0] == 'buld_tests' or item[0] == 'build_samples':
+ print("True")
+ return
+ print("False")
+ return
+
+
+if __name__ == "__main__":
+ run()
diff --git a/source-builder/sb/rtemspkg.py b/source-builder/sb/rtemspkg.py
new file mode 100644
index 0000000..492eb59
--- /dev/null
+++ b/source-builder/sb/rtemspkg.py
@@ -0,0 +1,287 @@
+#
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2024 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+#
+# This code builds a package compiler tool suite given a tool set. A tool
+# set lists the various tools. These are specific tool configurations.
+#
+
+from __future__ import print_function
+
+import argparse
+import base64
+import copy
+import datetime
+import hashlib
+import os
+import sys
+
+try:
+ from . import build
+ from . import download
+ from . import error
+ from . import git
+ from . import log
+ from . import path
+ from . import simhost
+ from . import version
+except KeyboardInterrupt:
+ print('abort: user terminated', file=sys.stderr)
+ sys.exit(1)
+except:
+ raise
+
+#
+# RTEMS Packages we maintian a git hash of in the RSB
+#
+rpc_label = 0
+rpc_config = 1
+rpc_version = 2
+rpc_repo = 3
+rpc_repo_name = 4
+rpc_branch = 5
+rpc_snapshot = 6
+rpc_package = 7
+rtems_pkg_cfgs = [
+ [
+ 'RTEMS Tools', 'tools/rtems-tools-%{rtems_version}.cfg',
+ 'rtems_tools_version', 'git://git.rtems.org/rtems-tools',
+ 'rtems-tools.git', 'master',
+ 'https://git.rtems.org/rtems-tools/snapshot/rtems-tools-%{rtems_tools_version}.tar.bz2',
+ 'rtems-tools-%{rtems_tools_version}.tar.bz2'
+ ],
+ [
+ 'RTEMS Kernel', 'tools/rtems-kernel-%{rtems_version}.cfg',
+ 'rtems_kernel_version', 'git://git.rtems.org/rtems', 'rtems.git',
+ 'master',
+ 'https://git.rtems.org/rtems/snapshot/rtems-%{rtems_kernel_version}.tar.bz2',
+ 'rtems-kernel-%{rtems_kernel_version}.tar.bz2'
+ ],
+ [
+ 'RTEMS LibBSD', 'tools/rtems-libbsd-%{rtems_version}.cfg',
+ 'rtems_libbsd_version', 'git://git.rtems.org/rtems-libbsd',
+ 'rtems-libbsd.git', '6-freebsd-12',
+ 'https://git.rtems.org/rtems-libbsd/snapshot/rtems-libbsd-%{rtems_libbsd_version}.tar.%{rtems_libbsd_ext}',
+ 'rtems-libbsd-%{rtems_libbsd_version}.tar.%{rtems_libbsd_ext}'
+ ],
+ [
+ 'RTEMS Net Legacy', 'tools/rtems-net-legacy-%{rtems_version}.cfg',
+ 'rtems_net_version', 'git://git.rtems.org/rtems-net-legacy',
+ 'rtems-net-legacy.git', 'main',
+ 'https://git.rtems.org/rtems-net-legacy/snapshot/rtems-net-legacy-%{rtems_net_version}.tar.%{rtems_net_ext}',
+ 'rtems-net-legacy-%{rtems_net_version}.tar.%{rtems_net_ext}'
+ ],
+ [
+ 'RTEMS Net Services', 'net/net-services-1.cfg',
+ 'rtems_net_services_version', 'git://git.rtems.org/rtems-net-services',
+ 'rtems-net-services.git', 'master',
+ 'https://git.rtems.org/rtems-net-services/snapshot/rtems-net-services-%{rtems_net_services_version}.tar.%{rtems_net_services_ext}',
+ 'rtems-net-services-%{rtems_net_services_version}.tar.%{rtems_net_services_ext}'
+ ],
+]
+
+
+def clean_line(line):
+ line = line[0:-1]
+ b = line.find('#')
+ if b >= 0:
+ line = line[1:b] + ('\\' if line[-1] == '\\' else '')
+ return line.strip()
+
+
+def clean_and_pack(line, last_line):
+ leading_ws = ' ' if len(line) > 0 and line[0].isspace() else ''
+ line = clean_line(line)
+ if len(last_line) > 0:
+ line = last_line + leading_ws + line
+ return line
+
+
+def config_patch(configdir, config, version_label, config_hash, repo_hash,
+ checksum):
+ for cd in configdir.split(':'):
+ cf = path.join(cd, config)
+ if path.exists(cf):
+ try:
+ with open(cf) as f:
+ lines = f.readlines()
+ except IOError as err:
+ raise error.general('config: %s: read error: %s' %
+ (config, str(err)))
+ new_config = []
+ new_lines = []
+ last_line = ''
+ for line in lines:
+ new_lines += [line]
+ line = clean_and_pack(line, last_line)
+ if len(line) > 0:
+ if line[-1] == '\\':
+ last_line = line[:-1]
+ continue
+ last_line = ''
+ if version_label in line and not 'rsb_version' in line:
+ if line.startswith('%define ' + version_label):
+ new_lines = [
+ '%define ' + version_label + ' ' + repo_hash +
+ os.linesep
+ ]
+ elif line.startswith('%hash '):
+ ls = line.split()
+ if len(ls) != 4:
+ raise error.general('invalid %hash: ' + line)
+ new_lines = [
+ ' '.join(ls[0:3]) + ' \\' + os.linesep,
+ ' ' + checksum + os.linesep
+ ]
+ new_config += new_lines
+ new_lines = []
+ try:
+ with open(cf, 'w') as f:
+ f.writelines(new_config)
+ except IOError as err:
+ raise error.general('config: %s: write error: %s' %
+ (config, str(err)))
+ return
+ raise error.general('could not find: ' + config)
+
+
+def checksum_sha512_base64(tarball):
+ hasher = hashlib.new('sha512')
+ try:
+ with open(path.host(tarball), 'rb') as f:
+ hasher.update(f.read())
+ except IOError as err:
+ log.notice('hash: %s: read error: %s' % (file_, str(err)))
+ except:
+ raise
+ raise error.general('cannot hash the tar file')
+ hash_hex = hasher.hexdigest()
+ hash_base64 = base64.b64encode(hasher.digest()).decode('utf-8')
+ return hash_base64
+
+
+def run(args=sys.argv):
+ ec = 0
+ output = []
+ try:
+ #
+ # The RSB options support cannot be used because it loads the defaults
+ # for the host which we cannot do here.
+ #
+ description = 'RTEMS Track Dependencies a build set has for all hosts.'
+
+ argsp = argparse.ArgumentParser(prog='sb-rtems-pkg',
+ description=description)
+ argsp.add_argument('--rtems-version',
+ help='Set the RTEMS version.',
+ type=str,
+ default=version.version())
+ argsp.add_argument('--log',
+ help='Log file.',
+ type=str,
+ default=simhost.log_default('rtems-pkg'))
+ argsp.add_argument('--trace',
+ help='Enable trace logging for debugging.',
+ action='store_true')
+ argsp.add_argument('--dry-run',
+ help='Dry run, do not update the configurations',
+ action='store_true')
+ argsp.add_argument('bsets', nargs='*', help='Build sets.')
+
+ argopts = argsp.parse_args(args[1:])
+
+ simhost.load_log(argopts.log)
+ log.notice('RTEMS Source Builder - RTEMS Package Update, %s' %
+ (version.string()))
+ log.tracing = argopts.trace
+
+ opts = simhost.load_options(args, argopts, extras=['--with-download'])
+ opts.defaults['_rsb_getting_source'] = '1'
+ opts.defaults[
+ 'rtems_waf_build_root_suffix'] = '%{waf_build_root_suffix}'
+ opts.defaults['rtems_version'] = argopts.rtems_version
+
+ for cfg in rtems_pkg_cfgs:
+ b = None
+ try:
+ bopts = copy.copy(opts)
+ bmacros = copy.copy(opts.defaults)
+ b = build.build(cfg[rpc_config], False, bopts, bmacros)
+ git_hash_key = b.macros.find(cfg[rpc_version])
+ if len(git_hash_key) == 0:
+ raise error.general(cfg[rpc_label] +
+ ': cannot find version macro')
+ source_dir = b.macros.expand('%{_sourcedir}')
+ config_hash = b.macros.expand('%{' + cfg[rpc_version] + '}')
+ repo_path = path.join(source_dir, cfg[rpc_repo_name])
+ download.get_file(
+ cfg[rpc_repo] + '?fetch?checkout=' + cfg[rpc_branch],
+ repo_path, bopts, b)
+ repo = git.repo(repo_path)
+ repo_hash = repo.head()
+ if config_hash != repo_hash:
+ update = True
+ update_str = 'UPDATE'
+ else:
+ update = False
+ update_str = 'matching'
+ print(cfg[rpc_label] + ': ' + update_str + ' config:' +
+ config_hash + ' repo:' + repo_hash)
+ b.macros[cfg[rpc_version]] = repo_hash
+ tarball = b.macros.expand(cfg[rpc_package])
+ b.macros.set_write_map('hashes')
+ b.macros[tarball] = 'NO-HASH NO-HASH'
+ b.macros.unset_write_map()
+ tarball_path = path.join(source_dir,
+ b.macros.expand(cfg[rpc_package]))
+ download.get_file(b.macros.expand(cfg[rpc_snapshot]),
+ tarball_path, bopts, b)
+ tarball_hash = checksum_sha512_base64(tarball_path)
+ if update and not argopts.dry_run:
+ config_patch(b.macros.expand('%{_configdir}'),
+ b.macros.expand(cfg[rpc_config]),
+ cfg[rpc_version], config_hash, repo_hash,
+ tarball_hash)
+ del b
+ except error.general as gerr:
+ log.stderr(str(gerr))
+ log.stderr('Configuration load FAILED')
+ b = None
+ except error.general as gerr:
+ log.stderr(str(gerr))
+ log.stderr('Build FAILED')
+ ec = 1
+ except error.internal as ierr:
+ log.stderr(str(ierr))
+ log.stderr('Internal Build FAILED')
+ ec = 1
+ except error.exit as eerr:
+ pass
+ except KeyboardInterrupt:
+ log.notice('abort: user terminated')
+ ec = 1
+ except:
+ raise
+ log.notice('abort: unknown error')
+ ec = 1
+ sys.exit(ec)
+
+
+if __name__ == "__main__":
+ run()
diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py
index b0e2b23..46d7fe7 100644
--- a/source-builder/sb/setbuilder.py
+++ b/source-builder/sb/setbuilder.py
@@ -30,11 +30,14 @@ import glob
import operator
import os
import sys
+import tarfile
+
import textwrap
try:
from . import build
from . import check
+ from . import config
from . import error
from . import log
from . import mailer
@@ -223,6 +226,9 @@ class buildset:
def installing(self):
return self.install_mode() == 'installing'
+ def installable(self):
+ return not self.opts.no_install() and self.installing()
+
def staging(self):
return not self.installing()
@@ -259,21 +265,31 @@ class buildset:
self.root_copy(_build.config.expand('%{buildroot}'),
_build.config.expand('%{_tmproot}'))
- def bset_tar(self, _build):
- tardir = _build.config.expand('%{_tardir}')
- if (self.opts.get_arg('--bset-tar-file') or self.opts.canadian_cross()) \
- and not _build.macros.get('%{_disable_packaging}'):
+ def bset_tar(self, stagingroot):
+ if self.opts.get_arg('--bset-tar-file') or self.opts.canadian_cross():
+ # Use a config to expand the macros because it supports all
+ # expansions, ie %{_cwd}
+ cfg = config.file(self.bset, self.opts, self.macros, load=False)
+ prefix = cfg.expand('%{_prefix}')
+ tardir = cfg.expand('%{_tardir}')
path.mkdir(tardir)
- tar = path.join(tardir,
- _build.config.expand('%s.tar.bz2' % \
- (_build.main_package().name())))
- log.notice('tarball: %s' % (os.path.relpath(path.host(tar))))
+ tarname = path.join(tardir,
+ path.basename('%s.tar.bz2' % (self.bset)))
+ log.notice('tarfile: %s' % (os.path.relpath(path.host(tarname))))
if not self.opts.dry_run():
- tmproot = _build.config.expand('%{_tmproot}')
- cmd = _build.config.expand('"cd ' + tmproot + \
- ' && %{__tar} -cf - . | %{__bzip2} > ' + \
- tar + '"')
- _build.run(cmd, shell_opts = '-c', cwd = tmproot)
+ tar = None
+ try:
+ tar = tarfile.open(tarname, 'w:bz2')
+ for filedir in sorted(path.listdir(stagingroot)):
+ src = path.join(stagingroot, filedir)
+ dst = path.join(prefix, filedir)
+ log.trace('tar: %s -> %s' % (src, dst))
+ tar.add(src, dst)
+ except OSError as oe:
+ raise error.general('tarfile: %s: %s' % (self.bset, oe))
+ finally:
+ if tar is not None:
+ tar.close()
def parse(self, bset):
@@ -284,6 +300,14 @@ class buildset:
line = line[1:b]
return line.strip()
+ def _clean_and_pack(line, last_line):
+ leading_ws = ' ' if len(line) > 0 and line[0].isspace() else ''
+ line = _clean(line)
+ if len(last_line) > 0:
+ line = last_line + leading_ws + line
+ return line
+
+ bset = macro_expand(self.macros, bset)
bsetname = bset
if not path.exists(bsetname):
@@ -305,25 +329,37 @@ class buildset:
try:
lc = 0
+ ll = ''
for l in bset:
lc += 1
- l = _clean(l)
+ l = _clean_and_pack(l, ll)
if len(l) == 0:
continue
+ if l[-1] == '\\':
+ ll = l[0:-1]
+ continue
+ ll = ''
log.trace('_bset: : %s: %03d: %s' % (self.bset, lc, l))
ls = l.split()
if ls[0][-1] == ':' and ls[0][:-1] == 'package':
self.bset_pkg = ls[1].strip()
self.macros['package'] = self.bset_pkg
- elif ls[0][0] == '%':
+ elif ls[0][0] == '%' and (len(ls[0]) > 1 and ls[0][1] != '{'):
def err(msg):
raise error.general('%s:%d: %s' % (self.bset, lc, msg))
- if ls[0] == '%define':
+ if ls[0] == '%define' or ls[0] == '%defineifnot' :
+ name = ls[1].strip()
+ value = None
if len(ls) > 2:
- self.macros.define(ls[1].strip(),
- ' '.join([f.strip() for f in ls[2:]]))
- else:
- self.macros.define(ls[1].strip())
+ value = ' '.join([f.strip() for f in ls[2:]])
+ if ls[0] == '%defineifnot':
+ if self.macros.defined(name):
+ name = None
+ if name is not None:
+ if value is not None:
+ self.macros.define(name, value)
+ else:
+ self.macros.define(name)
elif ls[0] == '%undefine':
if len(ls) > 2:
raise error.general('%s:%d: %undefine requires ' \
@@ -336,7 +372,7 @@ class buildset:
elif ls[0] == '%hash':
sources.hash(ls[1:], self.macros, err)
else:
- l = l.strip()
+ l = macro_expand(self.macros, l.strip())
c = build.find_config(l, self.configs)
if c is None:
raise error.general('%s:%d: cannot find file: %s' % (self.bset,
@@ -397,19 +433,11 @@ class buildset:
interrupted = False
#
- # If this is the outter most buildset it's files are installed. Nested
- # build sets staged their installed file. The staged files are install
- # when the outtter most build finishes.
- #
- if nesting_count != 1:
- if self.installing():
- self.macros['install_mode'] = 'staging'
-
- #
- # Only the outter build set can have staging to install. Get the staging
- # root via the config because it could require a valid config.
+ # If installing switch to staging. Not sure if this is still
+ # needed.
#
- have_staging = False
+ if nesting_count > 1 and self.installing():
+ self.macros['install_mode'] = 'staging'
try:
configs = self.load()
@@ -417,7 +445,7 @@ class buildset:
log.trace('_bset: %2d: %s: configs: %s' % (nesting_count,
self.bset, ', '.join(configs)))
- if nesting_count == 1 and len(configs) > 1:
+ if nesting_count == 1:
#
# Prepend staging areas, bin directory to the
# path. Lets the later package depend on the earlier
@@ -449,8 +477,6 @@ class buildset:
'=' * (74 - len(configs[s]))))
bs = buildset(configs[s], self.configs, opts, macros)
bs.build(deps, nesting_count, mail)
- if self.installing():
- have_staging = True
del bs
elif configs[s].endswith('.cfg'):
if mail:
@@ -480,8 +506,6 @@ class buildset:
copy.copy(self.macros),
format = 'xml',
mail = mail)
- if s == len(configs) - 1 and not have_errors:
- self.bset_tar(b)
else:
deps += b.config.includes()
builds += [b]
@@ -514,23 +538,22 @@ class buildset:
#
# Installing or staging ...
#
- log.trace('_bset: %2d: %s: deps:%r no-install:%r' % \
+ log.trace('_bset: %2d: mode: %s: deps:%r no-install:%r' % \
(nesting_count, self.install_mode(),
deps is None, self.opts.no_install()))
- log.trace('_bset: %2d: %s: builds: %s' % \
+ log.trace('_bset: %2d: mode: %s: builds: %s' % \
(nesting_count, self.install_mode(),
', '.join([b.name() for b in builds])))
- if deps is None and not self.opts.no_install() and not have_errors:
+ if deps is None and not have_errors:
for b in builds:
- log.trace('_bset: : %s: %r' % (self.install_mode(),
- b.installable()))
+ log.trace('_bset: : %s: installable=%r build-installable=%r' % \
+ (self.install_mode(), self.installable(), b.installable()))
if b.installable():
prefix = b.config.expand('%{_prefix}')
buildroot = path.join(b.config.expand('%{buildroot}'), prefix)
- if self.staging():
- prefix = b.config.expand('%{stagingroot}')
- self.install(self.install_mode(), b.name(), buildroot, prefix)
-
+ self.install('staging', b.name(), buildroot, b.config.expand('%{stagingroot}'))
+ if self.installable():
+ self.install('installing', b.name(), buildroot, prefix)
#
# Sizes ...
#
@@ -584,16 +607,20 @@ class buildset:
del b
#
- # If builds have been staged install into the finaly prefix.
+ # If builds have been staged install into the final prefix.
#
- if have_staging and not self.opts.no_install() and not have_errors:
+ if self.installing() and not have_errors:
stagingroot = macro_expand(self.macros, '%{stagingroot}')
have_stagingroot = path.exists(stagingroot)
- log.trace('_bset: %2d: install staging, present: %s' % \
- (nesting_count, have_stagingroot))
+ do_install = not self.opts.no_install()
+ if do_install:
+ log.trace('_bset: %2d: install staging, present: %s' % \
+ (nesting_count, have_stagingroot))
if have_stagingroot:
prefix = macro_expand(self.macros, '%{_prefix}')
- self.install(self.install_mode(), self.bset, stagingroot, prefix)
+ if do_install:
+ self.install(self.install_mode(), self.bset, stagingroot, prefix)
+ self.bset_tar(stagingroot)
staging_size = path.get_size(stagingroot)
if not self.opts.no_clean() or self.opts.always_clean():
log.notice('clean staging: %s' % (self.bset))
@@ -673,6 +700,16 @@ def list_bset_cfg_files(opts, configs):
return True
return False
+def list_host(opts):
+ if opts.get_arg('--list-host'):
+ print('Host operating system information:')
+ print('Operating system: %s' % macro_expand(opts.defaults, '%{_os}'))
+ print('Number of processors: %s' % macro_expand(opts.defaults, '%{_ncpus}'))
+ print('Build architecture: %s' % macro_expand(opts.defaults, '%{_host_arch}'))
+ print('Host triplet: %s' % macro_expand(opts.defaults, '%{_host}'))
+ return True
+ return False
+
def run():
import sys
ec = 0
@@ -683,6 +720,7 @@ def run():
'--list-bsets': 'List available build sets',
'--list-configs': 'List available configuration files.',
'--list-deps': 'List the dependent files.',
+ '--list-host': 'List host information and the host triplet.',
'--bset-tar-file': 'Create a build set tar file',
'--pkg-tar-files': 'Create package tar files',
'--no-report': 'Do not create a package report.',
@@ -695,6 +733,8 @@ def run():
'log' : '',
'reports': [],
'failure': None }
+ # Request this now to generate any errors.
+ smtp_host = mail['mail'].smtp_host()
to_addr = opts.get_arg('--mail-to')
if to_addr is not None:
mail['to'] = to_addr[1]
@@ -718,7 +758,8 @@ def run():
deps = []
else:
deps = None
- if not list_bset_cfg_files(opts, configs):
+
+ if not list_bset_cfg_files(opts, configs) and not list_host(opts):
prefix = macro_expand(opts.defaults, '%{_prefix}')
if opts.canadian_cross():
opts.disable_install()
diff --git a/source-builder/sb/simhost.py b/source-builder/sb/simhost.py
index 1ff98e8..f58a66d 100644
--- a/source-builder/sb/simhost.py
+++ b/source-builder/sb/simhost.py
@@ -36,6 +36,7 @@ try:
from . import log
from . import macros
from . import path
+ from . import shell
from . import sources
from . import version
except KeyboardInterrupt:
@@ -122,7 +123,6 @@ profiles = {
'_var': ('dir', 'optional', '/usr/local/var') },
}
-
class log_capture(object):
def __init__(self):
self.log = []
@@ -154,6 +154,18 @@ def find_bset_config(bset_config, macros):
raise error.general('no build set file found: %s' % (bset_config))
return name
+def macro_expand(macros, _str):
+ cstr = None
+ while cstr != _str:
+ cstr = _str
+ _str = macros.expand(_str)
+ _str = shell.expand(macros, _str)
+ return _str
+
+def strip_common_prefix(files):
+ commonprefix = os.path.commonprefix(files)
+ return sorted(list(set([f[len(commonprefix):] for f in files])))
+
#
# A skinny options command line class to get the configs to load.
#
@@ -252,10 +264,10 @@ class options(object):
a += 1
return None
- def rtems_bsp(self):
+ def rtems_bsp(self, arch='arch'):
self.defaults['rtems_version'] = str(version.version())
- self.defaults['_target'] = 'arch-rtems'
- self.defaults['rtems_host'] = 'rtems-arch'
+ self.defaults['_target'] = arch + '-rtems'
+ self.defaults['rtems_host'] = 'rtems-' + arch
self.defaults['with_rtems_bsp'] = 'rtems-bsp'
def sb_git(self):
@@ -383,8 +395,19 @@ class buildset:
rebased += [i]
return rebased
+ def root(self):
+ for i in self._includes:
+ si = i.split(':')
+ if len(si) == 2:
+ if si[1] == 'root':
+ return si[0]
+ return None
+
def includes(self):
- return sorted(list(set(self._includes)))
+ return [i for i in self._includes if not i.endswith(':root')]
+
+ def deps(self):
+ return strip_common_prefix([i.split(':')[0] for i in self.includes()])
def errors(self):
return sorted(list(set(self._errors)))
@@ -393,7 +416,7 @@ class buildset:
if not _build.disabled():
_build.make()
- def parse(self, bset):
+ def parse(self, bset, expand=True):
#
# Ouch, this is a copy of the setbuilder.py code.
@@ -409,7 +432,7 @@ class buildset:
bsetname = find_bset_config(bset, self.macros)
try:
- log.trace('_bset: %s: open: %s' % (self.bset, bsetname))
+ log.trace('_bset: %s: open: %s %s' % (self.bset, bsetname, expand))
bsetf = open(path.host(bsetname), 'r')
except IOError as err:
raise error.general('error opening bset file: %s' % (bsetname))
@@ -432,19 +455,26 @@ class buildset:
if ls[0][-1] == ':' and ls[0][:-1] == 'package':
self.bset_pkg = ls[1].strip()
self.macros['package'] = self.bset_pkg
- elif ls[0][0] == '%':
+ elif ls[0][0] == '%' and (len(ls[0]) > 1 and ls[0][1] != '{'):
def err(msg):
raise error.general('%s:%d: %s' % (self.bset, lc, msg))
- if ls[0] == '%define':
+ if ls[0] == '%define' or ls[0] == '%defineifnot' :
+ name = ls[1].strip()
+ value = None
if len(ls) > 2:
- self.macros.define(ls[1].strip(),
- ' '.join([f.strip() for f in ls[2:]]))
- else:
- self.macros.define(ls[1].strip())
+ value = ' '.join([f.strip() for f in ls[2:]])
+ if ls[0] == '%defineifnot':
+ if self.macros.defined(name):
+ name = None
+ if name is not None:
+ if value is not None:
+ self.macros.define(name, value)
+ else:
+ self.macros.define(name)
elif ls[0] == '%undefine':
if len(ls) > 2:
- raise error.general('%s:%d: %undefine requires just the name' \
- % (self.bset, lc))
+ raise error.general('%s:%d: %undefine requires ' \
+ 'just the name' % (self.bset, lc))
self.macros.undefine(ls[1].strip())
elif ls[0] == '%include':
configs += self.parse(ls[1].strip())
@@ -453,12 +483,18 @@ class buildset:
elif ls[0] == '%hash':
sources.hash(ls[1:], self.macros, err)
else:
- l = l.strip()
- c = build.find_config(l, self.configs)
- if c is None:
- raise error.general('%s:%d: cannot find file: %s'
- % (self.bset, lc, l))
- configs += [c + ':' + self.parent]
+ try:
+ l = macro_expand(self.macros, l.strip())
+ except:
+ if expand:
+ raise
+ l = None
+ if l is not None:
+ c = build.find_config(l, self.configs)
+ if c is None:
+ raise error.general('%s:%d: cannot find file: %s'
+ % (self.bset, lc, l))
+ configs += [c + ':' + self.parent]
finally:
bsetf.close()
self.parent = parent
@@ -523,7 +559,7 @@ class buildset:
nesting_count += 1
- log.trace('_bset: %s for %s: make' % (self.bset, host))
+ log.trace('_bset: %2d: %s for %s: make' % (nesting_count, self.bset, host))
log.notice('Build Set: %s for %s' % (self.bset, host))
mail_subject = '%s on %s' % (self.bset,
@@ -538,7 +574,7 @@ class buildset:
try:
configs = self.load()
- log.trace('_bset: %s: configs: %s' % (self.bset, ','.join(configs)))
+ log.trace('_bset: %2d: %s: configs: %s' % (nesting_count, self.bset, ','.join(configs)))
sizes_valid = False
builds = []
@@ -556,14 +592,14 @@ class buildset:
self.set_host_details(host, opts, macros)
config, parent = configs[s].split(':', 2)
if config.endswith('.bset'):
- log.trace('_bset: == %2d %s' % (nesting_count + 1, '=' * 75))
+ log.trace('_bset: %2d: %s' % (nesting_count + 1, '=' * 75))
bs = buildset(config, self.configs, opts, macros)
bs.build(host, nesting_count)
self._includes += \
self._rebase_includes(bs.includes(), parent)
del bs
elif config.endswith('.cfg'):
- log.trace('_bset: -- %2d %s' % (nesting_count + 1, '-' * 75))
+ log.trace('_bset: %2d: %s' % (nesting_count + 1, '-' * 75))
try:
b = build.build(config,
False,
@@ -579,7 +615,7 @@ class buildset:
#
# Dump post build macros.
#
- log.trace('_bset: macros post-build')
+ log.trace('_bset: %2d: macros post-build' % (nesting_count))
log.trace(str(macros))
else:
raise error.general('invalid config type: %s' % (config))
@@ -589,13 +625,16 @@ class buildset:
if self.build_failure is None:
self.build_failure = b.name()
self._includes += b.includes()
- self._errors += [find_bset_config(config, opts.defaults) + ':' + parent] + self._includes
+ self._errors += \
+ [find_bset_config(config, opts.defaults) + ':' + parent] + self._includes
raise
#
# Clear out the builds ...
#
for b in builds:
del b
+ self._includes += \
+ [find_bset_config(c.split(':')[0], self.macros) + ':' + self.bset for c in configs]
except error.general as gerr:
if not build_error:
log.stderr(str(gerr))
@@ -616,9 +655,9 @@ def list_hosts():
max_os_len = max(len(h) for h in hosts)
max_host_len = max(len(profiles[h]['_host'][2]) for h in hosts)
for h in hosts:
- print('%*s: %-*s %s' % (max_os_len, h, max_host_len,
- profiles[h]['_host'][2],
- profiles[h]['_host'][2]))
+ log.notice('%*s: %-*s %s' % (max_os_len, h, max_host_len,
+ profiles[h]['_host'][2],
+ profiles[h]['_host'][2]))
def get_files(configs, ext, localpath):
files = []
@@ -635,14 +674,39 @@ def get_config_files(configs, localpath = False):
def get_bset_files(configs, localpath = False):
return get_files(configs, '.bset', localpath)
+def get_config_bset_files(opts, configs):
+ cbs = get_config_files(configs) + get_bset_files(configs)
+ return strip_common_prefix([find_bset_config(cb, opts.defaults) for cb in cbs])
+
+def get_root_bset_files(opts, configs, localpath = False):
+ bsets = get_bset_files(configs, localpath)
+ incs = {}
+ for bs in bsets:
+ bset = buildset(bs, configs, opts)
+ cfgs = [find_bset_config(c.split(':')[0], bset.macros) for c in bset.parse(bs, False)]
+ incs[bset.root()] = bset.includes() + cfgs
+ roots = sorted(incs.keys())
+ for inc in incs:
+ for i in incs[inc]:
+ si = i.split(':')
+ if len(si) > 0 and si[0] in roots:
+ roots.remove(si[0])
+ return roots
+
def get_root(configs):
return configs['root']
+def list_root_bset_files(opts, configs):
+ for p in configs['paths']:
+ log.notice('Examining: %s' % (os.path.relpath(p)))
+ for r in strip_common_prefix(get_root_bset_files(opts, configs)):
+ log.notice(' %s' % (r))
+
def list_bset_files(opts, configs):
for p in configs['paths']:
- print('Examining: %s' % (os.path.relpath(p)))
+ log.notice('Examining: %s' % (os.path.relpath(p)))
for b in get_bset_files(configs):
- print(' %s' % (b[:b.rfind('.')]))
+ log.notice(' %s' % (b[:b.rfind('.')]))
def load_log(logfile):
log.default = log.log(streams = [logfile])
diff --git a/source-builder/sb/version.py b/source-builder/sb/version.py
index 29d2dc5..eb6a17d 100644
--- a/source-builder/sb/version.py
+++ b/source-builder/sb/version.py
@@ -89,9 +89,13 @@ _version_str = '%s.%s' % (_version, _revision)
_released = False
_git = False
_is_loaded = False
+_top_dir = None
def _top():
- top = path.dirname(sys.argv[0])
+ if _top_dir is None:
+ top = path.dirname(sys.argv[0])
+ else:
+ top = _top_dir
if len(top) == 0:
top = '.'
return top
@@ -106,7 +110,7 @@ def _load_released_version_config():
import configparser
except ImportError:
import ConfigParser as configparser
- v = configparser.SafeConfigParser()
+ v = configparser.ConfigParser()
try:
v.read(path.host(ver))
except Exception as e:
@@ -183,6 +187,10 @@ def _load_git_version():
_is_loaded = True
return _git
+def set_top(top):
+ global _top_dir
+ _top_dir = top
+
def load_release_settings(section, error = False):
vc, v = _load_released_version_config()
items = []
diff --git a/source-builder/x86_64-linux-gnu-pkg-config b/source-builder/x86_64-linux-gnu-pkg-config
new file mode 100755
index 0000000..09d7b16
--- /dev/null
+++ b/source-builder/x86_64-linux-gnu-pkg-config
@@ -0,0 +1,3 @@
+#! /bin/sh
+base=$(dirname $0)
+exec ${base}/pkg-config $*