Patchwork scripts: export source and patches

login
register
mail settings
Submitter djerome
Date July 12, 2013, 2:28 a.m.
Message ID <51DF69E1.1060606@crosslinux.org>
Download mbox | patch
Permalink /patch/258681/
State New
Headers show

Comments

djerome - July 12, 2013, 2:28 a.m.
This patch gives crosstool-NG the ability to export source code
packages of the target system C library and Linux kernel, and
all patches applied to them.  This helps automate getting source;
very useful for GPL compliance when delivering systems that have
the cross-tool chain glibc.
Thu Jul 11 19:12:18 MST 2013

scripts: Add the ability to export target source and patches.

Signed-off-by: Douglas Jerome <djerome@crosslinux.org>


  CT_DoListTarballExt() {
@@ -596,6 +637,7 @@
      # Do we already have it in *our* tarballs dir?
      if ext="$( CT_GetFileExtension "${basename}" ${first_ext} )"; then
          CT_DoLog DEBUG "Already have '${basename}'"
+        CT_DoMakeTargetManifestEntry "${CT_TARBALLS_DIR}/${basename}${ext}"
          return 0
      fi

@@ -609,6 +651,7 @@
                   "${CT_FORCE_DOWNLOAD}" != "y" ]; then
                  CT_DoLog DEBUG "Got '${basename}' from local storage"
                  CT_DoExecLog ALL ln -s 
"${CT_LOCAL_TARBALLS_DIR}/${basename}${ext}" 
"${CT_TARBALLS_DIR}/${basename}${ext}"
+                CT_DoMakeTargetManifestEntry 
"${CT_TARBALLS_DIR}/${basename}${ext}"
                  return 0
              fi
          done
@@ -693,6 +736,7 @@
      # If not allowed to download from the Internet, don't
      if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then
          CT_DoLog DEBUG "Not allowed to download from the Internet, 
aborting ${file} download"
+        CT_DoDisableTargetManifestEntry
          return 1
      fi

@@ -722,10 +766,12 @@
              if [ -f "${CT_TARBALLS_DIR}/${file}${ext}" ]; then
                  CT_DoLog DEBUG "Got '${file}' from the Internet"
                  CT_SaveLocal "${CT_TARBALLS_DIR}/${file}${ext}"
+                CT_DoMakeTargetManifestEntry 
"${CT_TARBALLS_DIR}/${file}${ext}"
                  return 0
              fi
          done
      done
+    CT_DoDisableTargetManifestEntry

      # Just return error, someone may want to catch and handle the error
      # (eg. glibc/eglibc add-ons can be missing).
@@ -1056,6 +1102,7 @@
              for p in "${d}"/*.patch; do
                  if [ -f "${p}" ]; then
                      CT_DoExecLog ALL patch --no-backup-if-mismatch -g0 
-F1 -p1 -f -i "${p}"
+                    CT_DoMakeTargetManifestEntry "${p}" persist
                  fi
              done
              if [ "${CT_PATCH_SINGLE}" = "y" ]; then
@@ -1063,6 +1110,7 @@
              fi
          fi
      done
+    CT_DoDisableTargetManifestEntry

      if [ "${CT_OVERIDE_CONFIG_GUESS_SUB}" = "y" ]; then
          CT_DoLog ALL "Overiding config.guess and config.sub"

--
For unsubscribe information see http://sourceware.org/lists.html#faq

Patch

diff -Naur a/config/global/manifest.in b/config/global/manifest.in
--- a/config/global/manifest.in	1969-12-31 17:00:00.000000000 -0700
+++ b/config/global/manifest.in	2013-06-28 19:28:51.121832505 -0700
@@ -0,0 +1,15 @@ 
+# Options specific to extracting packages
+
+comment "Target Manifest"
+
+config TARGET_MANIFEST
+    bool
+    prompt "Create a manifest of target components"
+    default n
+    help
+      Copy the source target components to a taget manifest directory 
in the
+      target toolchain directory.  This is only for the target 
components that
+      end up in the tool-chain sysroot.
+
+      This is intended to make it easy to get the toolchain target sysroot
+      source components and their patches.
diff -Naur a/config/global.in b/config/global.in
--- a/config/global.in	2013-01-31 13:07:52.000000000 -0700
+++ b/config/global.in	2013-06-28 19:43:55.705523652 -0700
@@ -13,5 +13,6 @@ 
  source "config/global/extract.in"
  source "config/global/build-behave.in"
  source "config/global/logging.in"
+source "config/global/manifest.in"

  endmenu
diff -Naur a/scripts/build/kernel/linux.sh b/scripts/build/kernel/linux.sh
--- a/scripts/build/kernel/linux.sh	2013-01-31 13:07:53.000000000 -0700
+++ b/scripts/build/kernel/linux.sh	2013-06-28 15:14:04.233944903 -0700
@@ -49,6 +49,7 @@ 
              2.6.*)  rel_dir=v2.6;;
              3.*)    rel_dir=v3.x;;
          esac
+        CT_DoEnableTargetManifestEntry "linux" "${CT_MANIFEST_DIR}"
          korg_base="http://ftp.kernel.org/pub/linux/kernel/${rel_dir}"
          CT_GetFile "linux-${CT_KERNEL_VERSION}"         \
                     "${korg_base}"                       \
@@ -78,6 +79,7 @@ 
      if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
          return 0
      fi
+    CT_DoEnableTargetManifestEntry "linux-patch" 
"${CT_MANIFEST_DIR}/linux-patch"
      CT_Patch "linux" "${CT_KERNEL_VERSION}"
  }

diff -Naur a/scripts/build/libc/eglibc.sh b/scripts/build/libc/eglibc.sh
--- a/scripts/build/libc/eglibc.sh	2013-01-31 13:07:53.000000000 -0700
+++ b/scripts/build/libc/eglibc.sh	2013-06-28 15:16:07.185407798 -0700
@@ -103,6 +103,7 @@ 
  # Extract the files required for the libc locales
  do_libc_locales_extract() {
      CT_Extract "eglibc-localedef-${CT_LIBC_VERSION}"
+    CT_DoEnableTargetManifestEntry "eglibc-patch" 
"${CT_MANIFEST_DIR}/eglibc-patch"
      CT_Patch "eglibc" "localedef-${CT_LIBC_VERSION}"
  }

diff -Naur a/scripts/build/libc/glibc-eglibc.sh-common 
b/scripts/build/libc/glibc-eglibc.sh-common
--- a/scripts/build/libc/glibc-eglibc.sh-common	2013-01-31 
13:07:53.000000000 -0700
+++ b/scripts/build/libc/glibc-eglibc.sh-common	2013-06-28 
15:17:40.712238552 -0700
@@ -7,6 +7,7 @@ 
      # Extract the main tarball
      CT_Extract "${CT_LIBC}-${CT_LIBC_VERSION}"
      CT_Pushd "${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}"
+    CT_DoEnableTargetManifestEntry "glibc-patch" 
"${CT_MANIFEST_DIR}/glibc-patch"
      CT_Patch nochdir "${CT_LIBC}" "${CT_LIBC_VERSION}"

      # Extract the add-opns
@@ -34,6 +35,7 @@ 

          CT_DoExecLog FILE ln -s "${addon}" 
"${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"

+        CT_DoEnableTargetManifestEntry "glibc-patch-addon" 
"${CT_MANIFEST_DIR}/glibc-patch-addon"
          CT_Patch nochdir "${CT_LIBC}" "${addon}-${CT_LIBC_VERSION}"

          # Remove the long name since it can confuse configure scripts 
to run
diff -Naur a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh
--- a/scripts/build/libc/glibc.sh	2013-01-31 13:07:53.000000000 -0700
+++ b/scripts/build/libc/glibc.sh	2013-06-28 15:35:39.595750652 -0700
@@ -19,6 +19,7 @@ 
      addons_list=($(do_libc_add_ons_list " "))

      # Main source
+    CT_DoEnableTargetManifestEntry "glibc" "${CT_MANIFEST_DIR}"
      CT_GetFile "glibc-${CT_LIBC_VERSION}"               \
                 {ftp,http}://ftp.gnu.org/gnu/glibc       \
                 ftp://gcc.gnu.org/pub/glibc/releases     \
@@ -32,6 +33,7 @@ 
              nptl)   continue;;
          esac

+        CT_DoEnableTargetManifestEntry "glibc_${addon}" 
"${CT_MANIFEST_DIR}"
          if ! CT_GetFile "glibc-${addon}-${CT_LIBC_VERSION}"     \
                          {ftp,http}://ftp.gnu.org/gnu/glibc      \
                          ftp://gcc.gnu.org/pub/glibc/releases    \
diff -Naur a/scripts/build/libc/mingw.sh b/scripts/build/libc/mingw.sh
--- a/scripts/build/libc/mingw.sh	2013-01-31 13:07:53.000000000 -0700
+++ b/scripts/build/libc/mingw.sh	2013-06-28 15:36:43.848947376 -0700
@@ -2,6 +2,7 @@ 
  # Licensed under the GPL v2. See COPYING in the root of this package

  do_libc_get() {
+    CT_DoEnableTargetManifestEntry "mingw-w64" "${CT_MANIFEST_DIR}"
      CT_GetFile "mingw-w64-v${CT_WINAPI_VERSION}" \
          http://downloads.sourceforge.net/sourceforge/mingw-w64
  }
@@ -9,6 +10,7 @@ 
  do_libc_extract() {
      CT_Extract "mingw-w64-v${CT_WINAPI_VERSION}"
      CT_Pushd "${CT_SRC_DIR}/mingw-w64-v${CT_WINAPI_VERSION}/"
+    CT_DoEnableTargetManifestEntry "mingw-w64-patch" 
"${CT_MANIFEST_DIR}/mingw-w64-patch"
      CT_Patch nochdir mingw-w64 "${CT_WINAPI_VERSION}"
      CT_Popd
  }
diff -Naur a/scripts/build/libc/newlib.sh b/scripts/build/libc/newlib.sh
--- a/scripts/build/libc/newlib.sh	2013-01-31 13:07:53.000000000 -0700
+++ b/scripts/build/libc/newlib.sh	2013-06-28 15:38:16.008795219 -0700
@@ -16,10 +16,12 @@ 
          CT_GetCustom "newlib" "${CT_LIBC_VERSION}"      \
                       "${CT_LIBC_NEWLIB_CUSTOM_LOCATION}"
      else # ! custom location
+        CT_DoEnableTargetManifestEntry "newlib" "${CT_MANIFEST_DIR}"
          CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src}
      fi # ! custom location

      if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
+        CT_DoEnableTargetManifestEntry "avr32headers" "${CT_MANIFEST_DIR}/"
          CT_GetFile "avr32headers" ${avr32headers_src}
      fi
  }
@@ -32,6 +34,7 @@ 
      fi

      CT_Extract "newlib-${CT_LIBC_VERSION}"
+    CT_DoEnableTargetManifestEntry "newlib-patch" 
"${CT_MANIFEST_DIR}/newlib-patch"
      CT_Patch "newlib" "${CT_LIBC_VERSION}"

      if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
diff -Naur a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh
--- a/scripts/build/libc/uClibc.sh	2013-01-31 13:07:53.000000000 -0700
+++ b/scripts/build/libc/uClibc.sh	2013-06-28 15:39:48.210642538 -0700
@@ -15,10 +15,12 @@ 
          CT_GetCustom "uClibc" "${CT_LIBC_VERSION}" \
                       "${CT_LIBC_UCLIBC_CUSTOM_LOCATION}"
      else
+        CT_DoEnableTargetManifestEntry "uclibc" "${CT_MANIFEST_DIR}"
          CT_GetFile "uClibc-${CT_LIBC_VERSION}" ${libc_src}
      fi
      # uClibc locales
      if [ "${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" = "y" ]; then
+        CT_DoEnableTargetManifestEntry "uclibc-locales" 
"${CT_MANIFEST_DIR}"
          CT_GetFile "${uclibc_local_tarball}" ${libc_src}
      fi

@@ -35,6 +37,7 @@ 
      if ! [ "${CT_LIBC_UCLIBC_CUSTOM}" = "y" \
           -a -d "${CT_SRC_DIR}/uClibc-${CT_LIBC_VERSION}" ]; then
          CT_Extract "uClibc-${CT_LIBC_VERSION}"
+        CT_DoEnableTargetManifestEntry "uclibc-patch" 
"${CT_MANIFEST_DIR}/uclibc-patch"
          CT_Patch "uClibc" "${CT_LIBC_VERSION}"
      fi

diff -Naur a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in
--- a/scripts/crosstool-NG.sh.in	2013-01-31 13:07:53.000000000 -0700
+++ b/scripts/crosstool-NG.sh.in	2013-06-28 18:15:35.033791168 -0700
@@ -185,6 +185,12 @@ 
          ;;
  esac

+# Compute target manifest directory
+if [ "${CT_TARGET_MANIFEST:-}" = "y" ]; then
+    CT_MANIFEST_DIR="${CT_INSTALL_DIR}/_target-source"
+    CT_MANIFEST_FILE="${CT_MANIFEST_DIR}/manifest.txt"
+fi
+
  # Compute test suite install directory
  CT_TEST_SUITE_DIR=${CT_INSTALL_DIR}/test-suite

@@ -260,6 +266,10 @@ 
  CT_DoExecLog ALL mkdir -p "${CT_INSTALL_DIR}"
  CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}"
  CT_DoExecLog ALL mkdir -p "${CT_HOST_COMPLIBS_DIR}"
+if [ "${CT_TARGET_MANIFEST:-}" = "y" ]; then
+   CT_DoExecLog ALL mkdir -p "${CT_MANIFEST_DIR}"
+   CT_DoExecLog ALL touch "${CT_MANIFEST_DIR}/manifest.txt"
+fi

  # Only create the state dir if asked for a restartable build
  [ -n "${CT_DEBUG_CT_SAVE_STEPS}" ] && CT_DoExecLog ALL mkdir -p 
"${CT_STATE_DIR}"
diff -Naur a/scripts/functions b/scripts/functions
--- a/scripts/functions	2013-01-31 13:07:53.000000000 -0700
+++ b/scripts/functions	2013-06-28 20:06:53.243302060 -0700
@@ -510,6 +510,47 @@ 
      export LD_LIBRARY_PATH
  }

+# Enable making one entry in the target manifest.
+# Usage: CT_DoEnableTargetManifestEntry <id name> <directory>
+CT_DoEnableTargetManifestEntry() {
+    if [ "${CT_TARGET_MANIFEST:-}" != "y" ]; then
+        return 0
+    fi
+    CT_MANIFEST_ENTRY="$1"
+    CT_MANIFEST_ENTRY_DIR="$2"
+    if [ ! -d "${CT_MANIFEST_ENTRY_DIR}" ]; then
+        CT_DoExecLog FILE mkdir -p "${CT_MANIFEST_ENTRY_DIR}"
+    fi
+}
+
+CT_DoDisableTargetManifestEntry() {
+    if [ "${CT_TARGET_MANIFEST:-}" != "y" ]; then
+        return 0
+    fi
+    CT_MANIFEST_ENTRY=""
+}
+
+# Make one target manifest entry; disable making more until enabled again.
+# Usage: CT_DoMakeTargetManifestEntry <file> [persist]
+CT_DoMakeTargetManifestEntry() {
+    if [ "${CT_TARGET_MANIFEST:-}" != "y" ]; then
+        return 0
+    fi
+    local file="$1"
+    if [ -n "${CT_MANIFEST_ENTRY:-}" -a -d "${CT_MANIFEST_ENTRY_DIR}" 
]; then
+        if [ ! -f "${CT_MANIFEST_FILE}" ]; then
+            CT_DoExecLog FILE touch "${CT_MANIFEST_FILE}"
+        fi
+        echo "${CT_MANIFEST_ENTRY} ${file}" >>"${CT_MANIFEST_FILE}"
+        CT_DoExecLog FILE cp "${file}" "${CT_MANIFEST_ENTRY_DIR}"
+    fi
+    if [ x"${2:-}" == x"persist" ]; then
+        :
+    else
+        CT_MANIFEST_ENTRY=""
+    fi
+}
+
  # Build up the list of allowed tarball extensions
  # Add them in the prefered order; most preferred comes first