From ee983f5f92aedbadaac9c756568c8fd6c04d58bc Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sun, 11 Jun 2017 22:14:48 -0700 Subject: Downloading packages using new framework Signed-off-by: Alexey Neyman diff --git a/TODO b/TODO index 99c1bda..ee4979c 100644 --- a/TODO +++ b/TODO @@ -9,11 +9,8 @@ A (slightly) ordered set of tasks for crosstool-NG. Written in a cryptic languag -- Alexey Neyman (@stilor) -[ ] updates - [ ] linux - [ ] mingw-w64 - [ ] newlib - [ ] gcc-linaro +[ ] retire wiki-samples + [ ] Fix displaying the versions in case devel is used (custom location/repo) - display "devel" or "custom" in those cases [ ] clean up GDB versions - no X.Y if X.Y.1 is present [ ] Check other packages, leave only the most recent on each branch [ ] arm_neon.h - offer as a companion "library" for the target diff --git a/maintainer/gen-versions.sh b/maintainer/gen-versions.sh index cd99432..325715a 100755 --- a/maintainer/gen-versions.sh +++ b/maintainer/gen-versions.sh @@ -428,7 +428,6 @@ check_obsolete_experimental() enter_fork() { local fork="${1}" - local -A dflt_branch=( [git]="master" [svn]="/trunk" ) local versions local only_obsolete only_experimental @@ -436,7 +435,8 @@ enter_fork() info[obsolete]= info[experimental]= info[repository]= - info[repository_cset]=HEAD + info[repository_branch]= + info[repository_cset]= info[fork]=${fork} info[name]=${fork} info[mirrors]= @@ -453,8 +453,7 @@ enter_fork() if [ -n "${info[repository]}" ]; then info[vcs]=${info[repository]%% *} - info[repository_url]=${info[repository]##* } - info[repository_dflt_branch]=${dflt_branch[${info[vcs]}]} + info[repository_url]=${info[repository]#* } fi info[versionlocked]=`kconfigize "${info[versionlocked]}"` diff --git a/maintainer/kconfig-versions.template b/maintainer/kconfig-versions.template index 9343f18..b3e8a90 100644 --- a/maintainer/kconfig-versions.template +++ b/maintainer/kconfig-versions.template @@ -1,30 +1,36 @@ # # DO NOT EDIT! This file is automatically generated. # + +# The component directory name +config @@masterpfx@@_DIR_NAME + string + default "@@master@@" + #!if [ "@@nforks@@" -ge 2 ] choice - bool "Show @@master@@ versions from" + bool "Show @@master@@ versions from" #!foreach fork config @@masterpfx@@_USE_@@originpfx@@ - bool "@@origin@@" + bool "@@origin@@" #!if [ -n "@@only_obsolete@@" ] - depends on OBSOLETE + depends on OBSOLETE #!end-if #!if [ -n "@@only_experimental@@" ] - depends on EXPERIMENTAL + depends on EXPERIMENTAL #!end-if - help + help @@originhelp@@ #!end-foreach endchoice config @@masterpfx@@_USE - string + string #!foreach fork - default "@@pfx@@" if @@masterpfx@@_USE_@@originpfx@@ + default "@@pfx@@" if @@masterpfx@@_USE_@@originpfx@@ #!end-foreach #!end-if @@ -34,78 +40,121 @@ config @@masterpfx@@_USE if @@masterpfx@@_USE_@@originpfx@@ #!end-if +config @@pfx@@_PKG_NAME + string + default "@@name@@" + #!// If a project makes official releases, using "bleeding edge" #!// from a development repository is experimental. However, there #!// are projects that consider its HEAD a "rolling release". For #!// those, checking out from a repository is the regular method. -#!if [ -n "@@all_versions@@" ] -if EXPERIMENTAL -#!end-if choice - bool "Source of @@name@@" + bool "Source of @@name@@" #!if [ -n "@@all_versions@@" ] config @@pfx@@_SRC_RELEASE - bool "Released tarball" - help - Download a released tarball. + bool "Released tarball" + help + Download a released tarball. #!end-if -#!if [ -n "@@repository@@" ] config @@pfx@@_SRC_DEVEL - bool "Vendor repository" - help - Check out from vendor repository at: - @@repository_url@@ + bool "Vendor/custom repository" +#!if [ -n "@@all_versions@@" ] + depends on EXPERIMENTAL +#!end-if + help + Check out from a repository. +#!if [ -n "@@repository@@" ] + Default is the vendor repository at @@repository_url@@ +#!end-if if @@pfx@@_SRC_DEVEL +choice + bool "VCS type" +#!if [ -n "@@repository@@" ] + default @@pfx@@_DEVEL_VCS_@@vcs@@ +#!end-if + help + Version control system from which the sources will be checked out. + The default value points to the development repository for @@name@@. + +config @@pfx@@_DEVEL_VCS_git + bool "Git" + +config @@pfx@@_DEVEL_VCS_svn + bool "Subversion" + +config @@pfx@@_DEVEL_VCS_hg + bool "Mercurial" + +config @@pfx@@_DEVEL_VCS_cvs + bool "CVS" + +endchoice + config @@pfx@@_DEVEL_VCS - string - default "@@vcs@@" + string + default "git" if @@pfx@@_DEVEL_VCS_git + default "svn" if @@pfx@@_DEVEL_VCS_svn + default "hg" if @@pfx@@_DEVEL_VCS_hg + default "cvs" if @@pfx@@_DEVEL_VCS_cvs config @@pfx@@_DEVEL_URL - string - default "@@repository_url@@" + string "Repository URL" +#!if [ -n "@@repository@@" ] + default "@@repository_url@@" +#!end-if + help + Repository URL. + + For CVS, enter both the value of CVS root and the module name, separated + by a space. config @@pfx@@_DEVEL_BRANCH - string "Branch to check out" - default "@@repository_dflt_branch@@" - help - Git: branch to be checked out - Subversion: directories to append to the repository URL. + string "Branch/tag to check out" + default "@@repository_branch@@" + help + Git/CVS: branch/tag to be checked out + Subversion: directories to append to the repository URL (i.e. branch or tag) + Mercurial: official guide recommends using separate repositories to maintain + stable branches. You likely need to change the repository URL, rather than + enter anything here. config @@pfx@@_DEVEL_REVISION - string "Revision/changeset" - default "@@repository_cset@@" - help - Commit ID or revision ID to check out. + string "Revision/changeset" + default "@@repository_cset@@" + help + Commit ID or revision ID to check out. + Git: enter the commit ID to check out a commit. + CVS: enter the date in "YYYY/MM/DD HH:MM:SS" format (UTC) to check out certain date. + Subversion: enter the revision. endif -#!end-if config @@pfx@@_SRC_CUSTOM - bool "Custom location" - depends on EXPERIMENTAL - help - Custom directory or tarball. + bool "Custom location" + depends on EXPERIMENTAL + help + Custom directory or tarball. if @@pfx@@_SRC_CUSTOM config @@pfx@@_CUSTOM_LOCATION - string "Custom source location" - help - Path to the directory or tarball with the sources. + string "Custom source location" + help + Path to the directory or tarball with the sources. endif endchoice -#!if [ -n "@@all_versions@@" ] -endif -config @@pfx@@_MIRRORS_ARRAY +#!if [ -n "@@all_versions@@" ] +config @@pfx@@_MIRRORS string default "@@mirrors@@" + #!end-if #!// Below, we explicitly select all milestones to which a given version @@ -117,7 +166,7 @@ config @@pfx@@_MIRRORS_ARRAY #!// #!if [ -n "@@all_versions@@" -a -z "@@versionlocked@@" ] choice - bool "Version of @@name@@" + bool "Version of @@name@@" help For a released version, select the version of @@name@@ to download and build. For sources out of the vendor repository or from a custom @@ -136,16 +185,16 @@ config @@pfx@@_VERY_NEW #!foreach version config @@pfx@@_V_@@kcfg@@ - bool "@@ver@@@@ver_postfix@@" + bool "@@ver@@@@ver_postfix@@" #!if [ "@@obsolete@@" = "yes" ] - depends on OBSOLETE + depends on OBSOLETE #!end-if #!if [ "@@experimental@@" = "yes" ] - depends on EXPERIMENTAL + depends on EXPERIMENTAL #!end-if #!foreach milestone #!if [ "@@version_cmp_milestone@@" -ge 0 ] - select @@masterpfx@@_@@ms_kcfg@@_or_later + select @@masterpfx@@_@@ms_kcfg@@_or_later #!end-if #!if [ "@@version_cmp_milestone@@" -gt 0 ] depends on !@@masterpfx@@_REQUIRE_@@ms_kcfg@@_or_older @@ -176,23 +225,23 @@ config @@pfx@@_V_@@kcfg@@ #!end-foreach #!end-if -#!if [ "@@nforks@@" -ge 2 ] -endif -#!end-if - config @@pfx@@_VERSION - string + string #!foreach version - default "@@ver@@" if @@pfx@@_V_@@kcfg@@ + default "@@ver@@" if @@pfx@@_V_@@kcfg@@ #!end-foreach - default "unknown" + default "unknown" + +#!if [ "@@nforks@@" -ge 2 ] +endif +#!end-if #!end-foreach #!foreach milestone #!// Milestones selected by a chosen version of this package config @@masterpfx@@_@@ms_kcfg@@_or_later - bool + bool #!// Milestone requirements selected by other packages that restrict #!// the choices in this package diff --git a/packages/binutils/package.desc b/packages/binutils/package.desc index 6854ee9..ae3d2f1 100644 --- a/packages/binutils/package.desc +++ b/packages/binutils/package.desc @@ -1,4 +1,4 @@ repository='git git://sourceware.org/git/binutils-gdb.git' -mirrors='$(CT_Mirrors GNU binutils) $(CT_Mirrors GCC_GNU binutils) $(CT_Mirrors sourceware)' +mirrors='$(CT_Mirrors GNU binutils) $(CT_Mirrors sourceware)' origin='GNU' milestones='2.23' diff --git a/packages/duma/package.desc b/packages/duma/package.desc index efedb9e..5b5ae8a 100644 --- a/packages/duma/package.desc +++ b/packages/duma/package.desc @@ -1,2 +1,2 @@ -repository='cvs :pserver:anonymous@duma.cvs.sourceforge.net:/cvsroot/duma' +repository='cvs :pserver:anonymous@duma.cvs.sourceforge.net:/cvsroot/duma duma' mirrors='http://downloads.sourceforge.net/project/duma/duma/${CT_DUMA_VERSION}' diff --git a/packages/gdb/package.desc b/packages/gdb/package.desc index b9855a5..90cef6a 100644 --- a/packages/gdb/package.desc +++ b/packages/gdb/package.desc @@ -1,4 +1,4 @@ origin='GNU' -repository='git ssh://sourceware.org/git/binutils-gdb.git' +repository='git git://sourceware.org/git/binutils-gdb.git' mirrors='$(CT_Mirrors GNU gdb) $(CT_Mirrors sourceware gdb)' milestones='7.0 7.2' diff --git a/packages/linux/package.desc b/packages/linux/package.desc index e34f9e4..6e3a0f4 100644 --- a/packages/linux/package.desc +++ b/packages/linux/package.desc @@ -1,2 +1,2 @@ repository='git git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git' -mirrors='$(CT_Mirrors linux ${CT_LINUX_VERSION})' +mirrors='$(CT_Mirrors kernel.org linux ${CT_LINUX_VERSION})' diff --git a/scripts/build/libc/mingw-w64.sh b/scripts/build/libc/mingw-w64.sh new file mode 100644 index 0000000..295b313 --- /dev/null +++ b/scripts/build/libc/mingw-w64.sh @@ -0,0 +1,215 @@ +# Copyright 2012 Yann Diorcet +# Licensed under the GPL v2. See COPYING in the root of this package + +do_libc_get() { + CT_Fetch MINGW_W64 +} + +do_libc_extract() { + CT_ExtractPatch MINGW_W64 +} + +do_set_mingw_install_prefix(){ + MINGW_INSTALL_PREFIX=/usr/${CT_TARGET} + if [[ ${CT_MINGW_W64_VERSION} == 2* ]]; then + MINGW_INSTALL_PREFIX=/usr + fi +} + +do_libc_start_files() { + local -a sdk_opts + + CT_DoStep INFO "Installing C library headers" + + case "${CT_MINGW_DIRECTX}:${CT_MINGW_DDK}" in + y:y) sdk_opts+=( "--enable-sdk=all" );; + y:) sdk_opts+=( "--enable-sdk=directx" );; + :y) sdk_opts+=( "--enable-sdk=ddk" );; + :) ;; + esac + + if [ "${CT_MINGW_SECURE_API}" = "y" ]; then + sdk_opts+=( "--enable-secure-api" ) + fi + + CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-headers" + + CT_DoLog EXTRA "Configuring Headers" + + do_set_mingw_install_prefix + CT_DoExecLog CFG \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/mingw-w64/mingw-w64-headers/configure" \ + --build=${CT_BUILD} \ + --host=${CT_TARGET} \ + --prefix=${MINGW_INSTALL_PREFIX} \ + "${sdk_opts[@]}" + + CT_DoLog EXTRA "Compile Headers" + CT_DoExecLog ALL make + + CT_DoLog EXTRA "Installing Headers" + CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR} + + CT_Popd + + # It seems mingw is strangely set up to look into /mingw instead of + # /usr (notably when looking for the headers). This symlink is + # here to workaround this, and seems to be here to last... :-/ + CT_DoExecLog ALL ln -sv "usr/${CT_TARGET}" "${CT_SYSROOT_DIR}/mingw" + + CT_EndStep +} + +do_check_mingw_vendor_tuple() +{ + if [ "${CT_MINGW_W64_VERSION%%.*}" -ge 4 ]; then + CT_DoStep INFO "Checking configured vendor tuple" + if [ ${CT_TARGET_VENDOR} == w64 ]; then + CT_DoLog EXTRA "The tuple is set to '${CT_TARGET_VENDOR}', as recommended by mingw-64 developers." + else + CT_DoLog WARN "The tuple vendor is '${CT_TARGET_VENDOR}', not equal to 'w64' and might break the toolchain!" + fi + CT_EndStep + fi +} + +do_mingw_tools() +{ + local f + + for f in "${CT_MINGW_TOOL_LIST_ARRAY[@]}"; do + CT_mkdir_pushd "${f}" + if [ ! -d "${CT_SRC_DIR}/mingw-w64/mingw-w64-tools/${f}" ]; then + CT_DoLog WARN "Skipping ${f}: not found" + CT_Popd + continue + fi + + CT_DoLog EXTRA "Configuring ${f}" + CT_DoExecLog CFG \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/mingw-w64/mingw-w64-tools/${f}/configure" \ + --build=${CT_BUILD} \ + --host=${CT_HOST} \ + --target=${CT_TARGET} \ + --program-prefix=${CT_TARGET}- \ + --prefix="${CT_PREFIX_DIR}" + + # mingw-w64 has issues with parallel builds, see do_libc + CT_DoLog EXTRA "Building ${f}" + CT_DoExecLog ALL make + CT_DoLog EXTRA "Installing ${f}" + CT_DoExecLog ALL make install + CT_Popd + done +} + +do_mingw_pthreads() +{ + local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count multi_target + local libprefix + local rcflags dlltoolflags + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'" + + libprefix="${MINGW_INSTALL_PREFIX}/lib/${multi_os_dir}" + CT_SanitizeVarDir libprefix + + CT_SymlinkToolsMultilib + + # DLLTOOLFLAGS does not appear to be currently used by winpthread package, but + # the master package uses this variable and describes this as one of the changes + # needed for i686 in mingw-w64-doc/howto-build/mingw-w64-howto-build-adv.txt + case "${multi_target}" in + i[3456]86-*) + rcflags="-F pe-i386" + dlltoolflags="-m i386" + ;; + x86_64-*) + rcflags="-F pe-x86-64" + dlltoolflags="-m i386:x86_64" + ;; + *) + CT_Abort "Tuple ${multi_target} is not supported by mingw-w64" + ;; + esac + + CT_DoLog EXTRA "Configuring mingw-w64-winpthreads" + + CT_DoExecLog CFG \ + CFLAGS="${multi_flags}" \ + CXXFLAGS="${multi_flags}" \ + RCFLAGS="${rcflags}" \ + DLLTOOLFLAGS="${dlltoolflags}" \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/mingw-w64/mingw-w64-libraries/winpthreads/configure" \ + --with-sysroot=${CT_SYSROOT_DIR} \ + --prefix=${MINGW_INSTALL_PREFIX} \ + --libdir=${libprefix} \ + --build=${CT_BUILD} \ + --host=${multi_target} + + # mingw-w64 has issues with parallel builds, see do_libc + CT_DoLog EXTRA "Building mingw-w64-winpthreads" + CT_DoExecLog ALL make + + CT_DoLog EXTRA "Installing mingw-w64-winpthreads" + CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR} + + CT_EndStep +} + +do_libc() +{ + do_check_mingw_vendor_tuple + + CT_DoStep INFO "Building mingw-w64" + + CT_DoLog EXTRA "Configuring mingw-w64-crt" + + CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-crt" + + do_set_mingw_install_prefix + CT_DoExecLog CFG \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/mingw-w64/mingw-w64-crt/configure" \ + --with-sysroot=${CT_SYSROOT_DIR} \ + --prefix=${MINGW_INSTALL_PREFIX} \ + --build=${CT_BUILD} \ + --host=${CT_TARGET} + + # mingw-w64-crt has a missing dependency occasionally breaking the + # parallel build. See https://github.com/crosstool-ng/crosstool-ng/issues/246 + # Do not pass ${JOBSFLAGS} - build serially. + CT_DoLog EXTRA "Building mingw-w64-crt" + CT_DoExecLog ALL make + + CT_DoLog EXTRA "Installing mingw-w64-crt" + CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR} + CT_EndStep + + if [ "${CT_THREADS}" = "posix" ]; then + CT_DoStep INFO "Building mingw-w64-winpthreads" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-winpthreads" + CT_IterateMultilibs do_mingw_pthreads pthreads-multilib + CT_Popd + CT_EndStep + fi + + if [ "${CT_MINGW_TOOLS}" = "y" ]; then + CT_DoStep INFO "Installing mingw-w64 companion tools" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-tools" + do_mingw_tools + CT_Popd + CT_EndStep + fi +} + +do_libc_post_cc() { + : +} diff --git a/scripts/build/libc/mingw.sh b/scripts/build/libc/mingw.sh deleted file mode 100644 index 295b313..0000000 --- a/scripts/build/libc/mingw.sh +++ /dev/null @@ -1,215 +0,0 @@ -# Copyright 2012 Yann Diorcet -# Licensed under the GPL v2. See COPYING in the root of this package - -do_libc_get() { - CT_Fetch MINGW_W64 -} - -do_libc_extract() { - CT_ExtractPatch MINGW_W64 -} - -do_set_mingw_install_prefix(){ - MINGW_INSTALL_PREFIX=/usr/${CT_TARGET} - if [[ ${CT_MINGW_W64_VERSION} == 2* ]]; then - MINGW_INSTALL_PREFIX=/usr - fi -} - -do_libc_start_files() { - local -a sdk_opts - - CT_DoStep INFO "Installing C library headers" - - case "${CT_MINGW_DIRECTX}:${CT_MINGW_DDK}" in - y:y) sdk_opts+=( "--enable-sdk=all" );; - y:) sdk_opts+=( "--enable-sdk=directx" );; - :y) sdk_opts+=( "--enable-sdk=ddk" );; - :) ;; - esac - - if [ "${CT_MINGW_SECURE_API}" = "y" ]; then - sdk_opts+=( "--enable-secure-api" ) - fi - - CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-headers" - - CT_DoLog EXTRA "Configuring Headers" - - do_set_mingw_install_prefix - CT_DoExecLog CFG \ - ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/mingw-w64/mingw-w64-headers/configure" \ - --build=${CT_BUILD} \ - --host=${CT_TARGET} \ - --prefix=${MINGW_INSTALL_PREFIX} \ - "${sdk_opts[@]}" - - CT_DoLog EXTRA "Compile Headers" - CT_DoExecLog ALL make - - CT_DoLog EXTRA "Installing Headers" - CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR} - - CT_Popd - - # It seems mingw is strangely set up to look into /mingw instead of - # /usr (notably when looking for the headers). This symlink is - # here to workaround this, and seems to be here to last... :-/ - CT_DoExecLog ALL ln -sv "usr/${CT_TARGET}" "${CT_SYSROOT_DIR}/mingw" - - CT_EndStep -} - -do_check_mingw_vendor_tuple() -{ - if [ "${CT_MINGW_W64_VERSION%%.*}" -ge 4 ]; then - CT_DoStep INFO "Checking configured vendor tuple" - if [ ${CT_TARGET_VENDOR} == w64 ]; then - CT_DoLog EXTRA "The tuple is set to '${CT_TARGET_VENDOR}', as recommended by mingw-64 developers." - else - CT_DoLog WARN "The tuple vendor is '${CT_TARGET_VENDOR}', not equal to 'w64' and might break the toolchain!" - fi - CT_EndStep - fi -} - -do_mingw_tools() -{ - local f - - for f in "${CT_MINGW_TOOL_LIST_ARRAY[@]}"; do - CT_mkdir_pushd "${f}" - if [ ! -d "${CT_SRC_DIR}/mingw-w64/mingw-w64-tools/${f}" ]; then - CT_DoLog WARN "Skipping ${f}: not found" - CT_Popd - continue - fi - - CT_DoLog EXTRA "Configuring ${f}" - CT_DoExecLog CFG \ - ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/mingw-w64/mingw-w64-tools/${f}/configure" \ - --build=${CT_BUILD} \ - --host=${CT_HOST} \ - --target=${CT_TARGET} \ - --program-prefix=${CT_TARGET}- \ - --prefix="${CT_PREFIX_DIR}" - - # mingw-w64 has issues with parallel builds, see do_libc - CT_DoLog EXTRA "Building ${f}" - CT_DoExecLog ALL make - CT_DoLog EXTRA "Installing ${f}" - CT_DoExecLog ALL make install - CT_Popd - done -} - -do_mingw_pthreads() -{ - local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count multi_target - local libprefix - local rcflags dlltoolflags - - for arg in "$@"; do - eval "${arg// /\\ }" - done - - CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'" - - libprefix="${MINGW_INSTALL_PREFIX}/lib/${multi_os_dir}" - CT_SanitizeVarDir libprefix - - CT_SymlinkToolsMultilib - - # DLLTOOLFLAGS does not appear to be currently used by winpthread package, but - # the master package uses this variable and describes this as one of the changes - # needed for i686 in mingw-w64-doc/howto-build/mingw-w64-howto-build-adv.txt - case "${multi_target}" in - i[3456]86-*) - rcflags="-F pe-i386" - dlltoolflags="-m i386" - ;; - x86_64-*) - rcflags="-F pe-x86-64" - dlltoolflags="-m i386:x86_64" - ;; - *) - CT_Abort "Tuple ${multi_target} is not supported by mingw-w64" - ;; - esac - - CT_DoLog EXTRA "Configuring mingw-w64-winpthreads" - - CT_DoExecLog CFG \ - CFLAGS="${multi_flags}" \ - CXXFLAGS="${multi_flags}" \ - RCFLAGS="${rcflags}" \ - DLLTOOLFLAGS="${dlltoolflags}" \ - ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/mingw-w64/mingw-w64-libraries/winpthreads/configure" \ - --with-sysroot=${CT_SYSROOT_DIR} \ - --prefix=${MINGW_INSTALL_PREFIX} \ - --libdir=${libprefix} \ - --build=${CT_BUILD} \ - --host=${multi_target} - - # mingw-w64 has issues with parallel builds, see do_libc - CT_DoLog EXTRA "Building mingw-w64-winpthreads" - CT_DoExecLog ALL make - - CT_DoLog EXTRA "Installing mingw-w64-winpthreads" - CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR} - - CT_EndStep -} - -do_libc() -{ - do_check_mingw_vendor_tuple - - CT_DoStep INFO "Building mingw-w64" - - CT_DoLog EXTRA "Configuring mingw-w64-crt" - - CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-crt" - - do_set_mingw_install_prefix - CT_DoExecLog CFG \ - ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/mingw-w64/mingw-w64-crt/configure" \ - --with-sysroot=${CT_SYSROOT_DIR} \ - --prefix=${MINGW_INSTALL_PREFIX} \ - --build=${CT_BUILD} \ - --host=${CT_TARGET} - - # mingw-w64-crt has a missing dependency occasionally breaking the - # parallel build. See https://github.com/crosstool-ng/crosstool-ng/issues/246 - # Do not pass ${JOBSFLAGS} - build serially. - CT_DoLog EXTRA "Building mingw-w64-crt" - CT_DoExecLog ALL make - - CT_DoLog EXTRA "Installing mingw-w64-crt" - CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR} - CT_EndStep - - if [ "${CT_THREADS}" = "posix" ]; then - CT_DoStep INFO "Building mingw-w64-winpthreads" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-winpthreads" - CT_IterateMultilibs do_mingw_pthreads pthreads-multilib - CT_Popd - CT_EndStep - fi - - if [ "${CT_MINGW_TOOLS}" = "y" ]; then - CT_DoStep INFO "Installing mingw-w64 companion tools" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-tools" - do_mingw_tools - CT_Popd - CT_EndStep - fi -} - -do_libc_post_cc() { - : -} diff --git a/scripts/functions b/scripts/functions index 50802dd..af1b108 100644 --- a/scripts/functions +++ b/scripts/functions @@ -5,7 +5,7 @@ # Licensed under the GPL v2. See COPYING in the root of this package CT_LoadConfig() { - local o + local o oldvals vals # Parse the configuration file # It has some info about the logging facility, so include it early @@ -200,7 +200,7 @@ CT_LogEnable() { exec 6>&1 7>&2 8<&0 CT_BUILD_LOG="${CT_TOP_DIR}/build.log" CT_LOG_ENABLED=y - if [ "$clean" = "yes" ]; then + if [ "$clean" = "yes" ]; then rm -f "${CT_BUILD_LOG}" fi exec >>"${CT_BUILD_LOG}" @@ -283,7 +283,7 @@ CT_DoLog() { _prog_bar_cpt=$(((_prog_bar_cpt+1)%40)) fi elif [ ${cur_l} -le ${CT_LOG_LEVEL_WARN} ]; then - printf "[%-5s]%*s%s%s\n" "${cur_L}" "${indent}" " " "${line}" + printf "[%-5s]%*s%s%s\n" "${cur_L}" "${indent}" " " "${line}" >&2 fi done ) @@ -874,24 +874,39 @@ CT_GetFile() { # Prerequisite: either the server does not require password, # or the user must already be logged in. # 'tag' is the tag to retrieve. Must be specified, but can be empty. -# If dirname is specified, then module will be renamed to dirname -# prior to building the tarball. -# Usage: CT_GetCVS [dirname[=subdir]] -# Note: if '=subdir' is given, then it is used instead of 'module'. +# are passed as a single argument, space-separated. +# Usage: CT_GetCVS CT_GetCVS() { - local basename="$1" - local uri="$2" - local module="$3" - local tag="${4:+-r ${4}}" - local dirname="$5" - local tmp_dir + local basename="${1}" + local uri="${2%% *}" + local module="${2##* }" + local tag="${3}" + local date="${4}" + local tmp_dir version + + # If date is not give, use current. Otherwise, check if format is correct. + # We don't support fancy CVS specifications like "1 day ago", as we'll need + # to convert them to some stable representation like 20170617231304. + if [ -z "${date}" ]; then + date=`LANG=C TZ=UTC date '+%Y/%m/%d %H:%M:%S'` + else + case "${date}" in + [12][0-9][0-9][0-9]/[01][0-9]/[0-3][0-9]\ [0-2][0-9]:[0-5][0-9]:[0-5][0-9]) + ;; + *) + CT_Abort "${basename}: invalid date format ${date}" + ;; + esac + fi + version="${tag:-trunk}-${date//[^0-9]/}" # First try locally, then the mirror - if CT_GetFile "${basename}"; then + if CT_GetFile "${basename}-${version}" .tar.bz2; then # Got it! Return early! :-) return 0 fi + CT_DoLog EXTRA "Retrieving '${basename}-${version}' (cvs)" if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then CT_DoLog WARN "Downloads forbidden, not trying cvs retrieval" return 1 @@ -900,20 +915,11 @@ CT_GetCVS() { CT_MktempDir tmp_dir CT_Pushd "${tmp_dir}" - CT_DoExecLog ALL cvs -z 9 -d "${uri}" co -P ${tag} "${module}" - if [ -n "${dirname}" ]; then - case "${dirname}" in - *=*) - CT_DoExecLog DEBUG mv "${dirname#*=}" "${dirname%%=*}" - CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${dirname%%=*}" - ;; - *) - CT_DoExecLog ALL mv "${module}" "${dirname}" - CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${dirname:-${module}}" - ;; - esac - fi - CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}.tar.bz2" + CT_DoExecLog ALL cvs -z 9 -d "${uri}" co -P ${tag:+-r ${tag}} -D "${date} UTC" "${module}" + CT_DoExecLog ALL mv "${module}" "${basename}-${version}" + CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}-${version}.tar.bz2" \ + "${basename}-${version}" + CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}-${version}.tar.bz2" CT_Popd CT_DoExecLog ALL rm -rf "${tmp_dir}" @@ -924,14 +930,28 @@ CT_GetCVS() { # Prerequisite: either the server does not require password, # or the user must already be logged in. # 'rev' is the revision to retrieve -# Usage: CT_GetSVN [rev] +# Usage: CT_GetSVN [rev] CT_GetSVN() { - local basename="$1" - local uri="$2" - local rev="$3" + local basename="${1}" + local uri="${2}" + local branch="${3:-/trunk}" + local rev="${4}" + local version + + # If revision is not given, find the most recent + if [ -z "${rev}" ]; then + # '--show-item revision' only exists in SVN 1.9+ + rev=`svn info "${uri}" | sed -n 's/^Revision: //p'` + fi + + # Construct version from branch/revision + version="${branch//\//_}" + version="${version#_}" + version="${version%_}" + version="${version}-${rev}" # First try locally, then the mirror - if CT_GetFile "${basename}"; then + if CT_GetFile "${basename}-${version}" .tar.bz2; then # Got it! Return early! :-) return 0 fi @@ -941,78 +961,128 @@ CT_GetSVN() { return 1 fi + CT_DoLog EXTRA "Retrieving '${basename}-${version}' (svn)" CT_MktempDir tmp_dir CT_Pushd "${tmp_dir}" - if ! CT_DoExecLog ALL svn export ${rev:+-r ${rev}} "${uri}" "${basename}"; then - CT_DoLog WARN "Could not retrieve '${basename}'" + if ! CT_DoExecLog ALL svn export ${rev:+-r ${rev}} "${uri}${branch}" \ + "${basename}-${version}"; then + CT_DoLog WARN "Could not retrieve '${basename}-${version}'" return 1 fi - CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${basename}" - CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}.tar.bz2" + CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}-${version}.tar.bz2" \ + "${basename}-${version}" + CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}-${version}.tar.bz2" + + CT_Popd + CT_DoExecLog ALL rm -rf "${tmp_dir}" +} + +# Check out from Mercurial (Hg) +# Usage: CT_GetHg +CT_GetHg() +{ + local basename="${1}" + local uri="${2}" + local branch="${3}" + local cset="${4}" + + if [ -n "${branch}" -a -n "${cset}" ]; then + CT_Abort "${basename}: cannot specify both branch and changeset for Mercurial" + fi + + # Mercurial cannot query remote branches except the default, so we'll have + # to clone if cset is not known and a branch is given. + if [ -z "${branch}" ]; then + # Mercurial does not allow querying bran + cset=`hg identify "${uri}"` + else + CT_DoLog WARN "${basename}: Mercurial cannot query non-default branch, will clone" + fi + if [ -n "${cset}" ]; then + if CT_GetFile "${basename}-${cset}" .tar.bz2; then + # Got it + return 0 + fi + fi + + if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then + CT_DoLog WARN "Downloads forbidden, not trying hg retrieval" + return 1 + fi + + CT_MktempDir tmp_dir + CT_Pushd "${tmp_dir}" + CT_DoExecLog ALL hg clone "${uri}" "${basename}" + CT_Pushd "${basename}" + if [ -n "${branch}" ]; then + CT_DoExecLog ALL hg update "${branch}" + fi + if [ -z "${cset}" ]; then + cset=`hg identify -i` + else + CT_DoExecLog ALL hg update "${cset}" + fi + CT_DoLog EXTRA "Retrieving '${basename}-${cset}' (hg)" + CT_DoExecLog ALL rm -rf .hg + CT_Popd + CT_DoExecLog ALL mv "${basename}" "${basename}-${cset}" + CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}-${cset}.tar.bz2" \ + "${basename}-${cset}" + CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}-${cset}.tar.bz2" CT_Popd CT_DoExecLog ALL rm -rf "${tmp_dir}" } # Clone a git tree -# Tries the given URLs in turn until one can get cloned. No tarball will be created. # Prerequisites: either the server does not require password, # or the user has already taken any action to authenticate to the server. -# The cloned tree will *not* be stored in the local tarballs dir! -# cset_or_ref can be a branch or tag, if specified as 'ref=name' # In this case, 'git ls-remote' is used to get the sha1 and can also # be used to get a list valid refs (e.g. HEAD, refs/heads/master, refs/tags/v3.3.0) -# Usage: CT_GetGit +# Usage: CT_GetGit CT_GetGit() { local basename="${1}" - local cset_or_ref="${2}" - local url="${3}" - local _out_cset="${4}" - - local ref=$(echo "${cset_or_ref}" | ${sed} -n 's/^ref=\(.*\)/\1/p') - if [ -n "$ref" ]; then - local matches=$(git ls-remote --exit-code "$url" --refs "${ref}") - local result=$? - CT_TestAndAbort "Failed to find git ref ${ref} at ${url}" "${result}" != "0" - if [ $( echo "$matches" | wc -l) -gt 1 ]; then + local url="${2}" + local ref="${3}" + local cset="${4}" + + if [ -n "${ref}" -a -n "${cset}" ]; then + CT_Abort "${basename}: cannot specify both branch and changeset for Git" + fi + + ref="${ref:-master}" + if [ -z "${cset}" ]; then + local matches=$(git ls-remote --exit-code "${url}" --refs "${ref}" || echo "not found") + + # Cannot test $?, setting a trap on ERR prevents bash from returning the + # status code. + if [ "${matches}" = "not found" ]; then + CT_Abort "Failed to find git ref ${ref} at ${url}" + fi + if [ $(echo "${matches}" | wc -l) -gt 1 ]; then CT_DoLog WARN "Ambiguous ref ${ref} at ${url}, using first" fi - local cset=$(echo "$matches" | head -n1 | cut -c1-6) + cset=$(echo "$matches" | head -n1 | cut -c1-8) CT_DoLog DEBUG "ref ${ref} at ${url} has cset of ${cset}" else - local cset=${cset_or_ref} CT_DoLog DEBUG "cset ${cset}" fi - if [ -n "${_out_cset}" ]; then - eval ${_out_cset}=\${cset} - fi - local dir="${CT_TARBALLS_DIR}/${basename}-${cset}.git" local file="${basename}-${cset}.tar.gz" local dest="${CT_TARBALLS_DIR}/${file}" local tmp="${CT_TARBALLS_DIR}/${file}.tmp-dl" - # Do we already have it? - if CT_GetLocal "${file}"; then - echo ${cset} + if CT_GetFile "${basename}-${cset}" .tar.gz; then return 0 fi - # Nope... if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then CT_DoLog WARN "Downloads forbidden, not trying git retrieval" return 1 fi - # Add URLs on the LAN mirror - # We subvert the normal download method, just to look for - # looking at the local mirror - if CT_GetFile "${basename}-${cset}" .tar.gz; then - return 0 - fi - CT_DoLog EXTRA "Retrieving '${basename}-${cset}' (git)" # Remove potential left-over from a previous run @@ -1030,7 +1100,6 @@ CT_GetGit() { CT_SaveLocal "${dest}" CT_DoExecLog ALL rm -rf "${tmp}.tar.gz" "${tmp}.tar" "${tmp}" "${dir}" CT_Popd - echo ${cset} return 0 else # Woops... @@ -1102,7 +1171,6 @@ CT_Extract() { .tar.gz|.tgz) gzip -dc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f -;; .tar) CT_DoExecLog FILE tar "${tar_opts[@]}" -f "${full_file}";; .zip) CT_DoExecLog FILE unzip "${@}" "${full_file}";; - /.git) CT_ExtractGit "${basename}" "${@}";; *) CT_DoLog WARN "Don't know how to handle '${basename}${ext}': unknown extension" return 1 ;; @@ -1118,51 +1186,6 @@ CT_Extract() { CT_Popd } -# Create a working git clone of a local git repository -# Usage: CT_ExtractGit [ref] -# where 'ref' is the reference to use: -# the full name of a branch, like "remotes/origin/branch_name" -# a date as understandable by git, like "YYYY-MM-DD[ hh[:mm[:ss]]]" -# a tag name -# If 'ref' is not given, the current repository HEAD will be used -CT_ExtractGit() { - local basename="${1}" - local ref="${2}" - local repo - local ref_type - - # pushd now to be able to get git revlist in case ref is a date - repo="${CT_TARBALLS_DIR}/${basename}" - CT_Pushd "${repo}" - - # What kind of reference is ${ref} ? - if [ -z "${ref}" ]; then - ref_type=head - ref=$(git rev-list -n1 HEAD) - elif git tag |{grep} -E "^${ref}$" >/dev/null 2>&1; then - ref_type=tag - elif git branch -a --no-color |${grep} -E "^. ${ref}$" >/dev/null 2>&1; then - ref_type=branch - elif date -d "${ref}" >/dev/null 2>&1; then - ref_type=date - ref=$(git rev-list -n1 --before="${ref}") - else - CT_Abort "Reference '${ref}' is an incorrect git reference: neither tag, branch nor date" - fi - - CT_Popd - - CT_DoExecLog FILE rmdir "${basename}" - case "${ref_type}" in - branch) CT_DoExecLog FILE git clone -b "${ref}" "${repo}" "${basename}" ;; - *) CT_DoExecLog FILE git clone "${repo}" "${basename}" - CT_Pushd "${basename}" - CT_DoExecLog FILE git checkout "${ref}" - CT_Popd - ;; - esac -} - # Patches the specified component # See CT_Extract, above, for explanations on 'nochdir' # Usage: CT_Patch [nochdir] @@ -1882,7 +1905,7 @@ CT_MultilibFixupLDSO() } # List the download mirrors. Usage: -# CT_Mirrors ORGANIZATION PROJECT +# CT_Mirrors ORGANIZATION PROJECT [...] CT_Mirrors() { local org="${1}" @@ -1903,17 +1926,23 @@ CT_Mirrors() echo "http://gcc.gnu.org/pub/${project}/releases${subdir}" ;; Linaro) - local version="${3}" - base yymm + eval "local version=\"\${${3}}\"" + local base yymm base="${version%%-*}" yymm="${version##*-??}" - echo "https://releases.linaro.org/components/toolchain/${comp}-linaro/${version}" - echo "https://releases.linaro.org/archive/${yymm}/components/toolchain/${comp}-linaro/${base}" - echo "https://releases.linaro.org/archive/${yymm}/components/toolchain/${comp}-linaro" + echo "https://releases.linaro.org/components/toolchain/${project}-linaro/${version}" + echo "https://releases.linaro.org/archive/${yymm}/components/toolchain/${project}-linaro/${base}" + echo "https://releases.linaro.org/archive/${yymm}/components/toolchain/${project}-linaro" ;; - linux) - local version="${3}" + kernel.org) + if [ "${project}" != "linux" ]; then + CT_Abort "Unsupported project" + fi + local version="${CT_LINUX_VERSION}" case "${version}" in + '') + # Ignore, this happens before .config is fully evaluated + ;; [34].*) echo "http://www.kernel.org/pub/linux/kernel/v${version%%.*}.x" ;; @@ -1927,7 +1956,7 @@ CT_Mirrors() esac ;; *) - CT_Abort "Unsupported Linux kernel version" + CT_Abort "Unsupported Linux kernel version '${version}'" ;; esac ;; @@ -1936,3 +1965,62 @@ CT_Mirrors() ;; esac } + +# Helper: run another action after setting local variables +CT_PackageRun() +{ + local sym="${1}" + local run="${2}" + local v + + # Get rid of our arguments + shift 2 + + # Variables that are per-project + for v in USE DIR_NAME; do + eval "local CT_${v}=\${CT_${sym}_${v}}" + done + + # If CT_USE is not set, we only have one fork to handle + CT_USE="${CT_USE:-${sym}}" + + # Variables that are per-fork + for v in PKG_NAME VERSION SRC_RELEASE MIRRORS SRC_DEVEL SRC_CUSTOM \ + DEVEL_VCS DEVEL_URL DEVEL_BRANCH DEVEL_REVISION CUSTOM_LOCATION; do + eval "local CT_${v}=\${CT_${CT_USE}_${v}}" + done + + ${run} "$@" +} + +# Closure for fetching the sources +CT_DoFetch() +{ + if [ "${CT_SRC_RELEASE}" = "y" ]; then + CT_GetFile "${CT_PKG_NAME}-${CT_VERSION}" ${CT_MIRRORS} + elif [ "${CT_SRC_DEVEL}" = "y" ]; then + local -A fetchfn=( [git]=CT_GetGit [svn]=CT_GetSVN [hg]=CT_GetHg [cvs]=CT_GetCVS ) + + if [ -z "${CT_DEVEL_REVISION}" -a "${CT_FORBID_DOWNLOAD}" = "y" ]; then + CT_Abort "${CT_PKG_NAME}: cannot find most recent revisions with downloads prohibited" + fi + if [ -n "${fetchfn[${CT_DEVEL_VCS}]}" ]; then + ${fetchfn[${CT_DEVEL_VCS}]} "${CT_PKG_NAME}" "${CT_DEVEL_URL}" \ + "${CT_DEVEL_BRANCH}" "${CT_DEVEL_REVISION}" + else + CT_Abort "${CT_PKG_NAME}: Unsupported VCS: ${CT_DEVEL_VCS}" + fi + elif [ "${CT_SRC_CUSTOM}" = "y" ]; then + # Will be handled during extraction/patching + :; + else + CT_Abort "No known source for ${CT_DIR_NAME}" + fi +} + +# Obtain the sources for a component, either from a tarball, version control system +# or a custom location. +CT_Fetch() +{ + CT_PackageRun "${1}" CT_DoFetch +} diff --git a/scripts/showSamples.sh b/scripts/showSamples.sh index b11a8d6..726ea2e 100644 --- a/scripts/showSamples.sh +++ b/scripts/showSamples.sh @@ -11,6 +11,9 @@ # GREP_OPTIONS screws things up. export GREP_OPTIONS= +# Dummy version which is invoked from .config +CT_Mirrors() { :; } + # Dump a single sample # Note: we use the specific .config.sample config file dump_single_sample() { @@ -20,7 +23,6 @@ dump_single_sample() { [ "$1" = "-v" ] && verbose=1 && shift [ "$1" = "-w" ] && wiki=1 && shift local sample="$1" - # TBD use CT_LoadConfig . $(pwd)/.config.sample # libc needs some love -- cgit v0.10.2-6-g49f6