Skip to contentSkip to conversation

buildroot-test: misc enhancenments (branch yem/reproduce)

PATCH New Yann E. MORIN 2 participants 4 messages Apr 12, 2015

lore
Share & tools
lore
#0 lore raw

v2 cover buildroot-test: misc enhancenments (branch yem/reproduce)

Hello All!

This small series fixes the br-reproduce script wrt. the URLs accepted by the server.

Changes v1 -> v2:
- fix ugly POSIX shell syntax in favour of readable bashism (Thomas)
- fix quoting (Thomas)

Regards,
Yann E. MORIN.

The following changes since commit a7226db951d7e542b8a6b9b13e94a29a22879aff:

autbuild-run: fix legal-info (2015-04-06 23:17:13 +0200)

are available in the git repository at:

git://git.busybox.net/~ymorin/git/buildroot-test yem/reproduce

for you to fetch changes up to 4ec90d83a1df3ac770250375cbd7617dc2b6fe63:

br-reproduce-build: fix URL of gitid (2015-04-12 14:40:24 +0200)

----------------------------------------------------------------
Yann E. MORIN (2):
br-reproduce-build: quote variables
br-reproduce-build: fix URL of gitid

 utils/br-reproduce-build | 39 +++++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH v2 1/2 br-reproduce-build: quote variables

Even though we do not really support building in a path that contains spaces (or other weird characters), it's still better to quote variables.

---
 utils/br-reproduce-build | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
utils/br-reproduce-build +12 -12
index 01d1b7a..0ecfb54 100755
@@ -16,30 +16,30 @@ if [ $# -ne 1 ] ; then
     exit 1 ;
 fi
 
-BUILD_ID=$1
+BUILD_ID="$1"
 
-BUILD_DIR=${OUTPUT_DIR}/${BUILD_ID}
+BUILD_DIR="${OUTPUT_DIR}/${BUILD_ID}"
 
-mkdir -p ${BUILD_DIR}
+mkdir -p "${BUILD_DIR}"
 if [ $? -ne 0 ] ; then
     echo "Cannot create output directory"
     exit 1
 fi
 
-wget -O ${BUILD_DIR}/config http://autobuild.buildroot.org/results/${BUILD_ID}/config
+wget -O "${BUILD_DIR}/config" "http://autobuild.buildroot.org/results/${BUILD_ID}/config"
 if [ $? -ne 0 ] ; then
     echo "Cannot get configuration for build ${BUILD_ID}"
-    rm -f ${BUILD_DIR}
+    rm -f "${BUILD_DIR}"
     exit 1
 fi
 
-wget -O ${BUILD_DIR}/gitid http://autobuild.buildroot.org/results/${BUILD_ID}/gitid
+wget -O "${BUILD_DIR}/gitid" "http://autobuild.buildroot.org/results/${BUILD_ID}/gitid"
 
-cd ${BUILD_DIR}
-git clone ${BASE_GIT} buildroot
+cd "${BUILD_DIR}"
+git clone "${BASE_GIT}" buildroot
 if [ $? -ne 0 ] ; then
     echo "Cannot clone Buildroot Git repository"
-    rm -rf ${BUILD_DIR}
+    rm -rf "${BUILD_DIR}"
     exit 1
 fi
 
@@ -50,17 +50,17 @@ git remote set-url origin git://git.busybox.net/buildroot
 git fetch
 if [ $? -ne 0 ] ; then
     echo "Cannot fetch Buildroot official Git repository"
-    rm -rf ${BUILD_DIR}
+    rm -rf "${BUILD_DIR}"
     exit 1
 fi
 
 git checkout $(cat ../gitid)
 if [ $? -ne 0 ] ; then
     echo "Cannot checkout commit " $(cat ../gitid)
-    rm -rf ${BUILD_DIR}
+    rm -rf "${BUILD_DIR}"
     exit 1
 fi
 
 mkdir ../output
-cp ${BUILD_DIR}/config ../output/.config
+cp "${BUILD_DIR}/config" ../output/.config
 make 2>&1 O=../output | tee logfile
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/2 br-reproduce-build: fix URL of gitid

In reply to Yann E. MORIN

The canonical URL to the results on the autobuilder server wants the sha1 to be prefixed with the first three letters of the sha1, like so:

    b52/b52c54eafc2ea8814bb49850823e55d8e034d33d

Currently, this is done by a redirect on the server, but it is broken, so that requests that do not conform to that scheme return empty results. See for example the difference between those two calls:

    wget -O OK 'http://autobuild.buildroot.org/results/b2c/b2cefd7d362c12ed99b708d11b988704778d450c/defconfig'
    wget -O KO 'http://autobuild.buildroot.org/results/b2cefd7d362c12ed99b708d11b988704778d450c/defconfig'

So, currently, passing only the sah1 on the command line of br-reproduce would not work, because the sha1 is used as-is to construct the URL. To make it work, a user had to pass the sha1 prefixed with the first three chars.

However, this is not very convenient.

Fix that:
- internally reconstruct the canonical URL;
- still accept a prefix-sha1 on the command line (for users that got used to that behaviour).

---
Changes v1 -> v2:
- use bashism to extract the first three chars, instead of the more complex but POSIX-compliant construct (Thomas)

---
 utils/br-reproduce-build | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
utils/br-reproduce-build +16 -1
index 0ecfb54..17d61f5 100755
@@ -16,10 +16,25 @@ if [ $# -ne 1 ] ; then
     exit 1 ;
 fi
 
-BUILD_ID="$1"
+# The location where the results are stored on the server is
+# of the form 'xxx/xxxyyyyyyyy', where 'xxx' are the first
+# three chars of the sha1, and 'xxxyyyyyyyy' is the full sha1.
+#
+# We accept the user to pass either the full sha1, or the full
+# sha1 prefixed with the 'xxx' part. So we just extract the sha1
+# from the value passed by the user
+BUILD_ID="${1#*/}"
 
+# The build directory is only made of the full sha1, without the
+# leading 'xxx/' part
 BUILD_DIR="${OUTPUT_DIR}/${BUILD_ID}"
 
+# Now, we construct the BUILD-ID as it is expected to be on the server:
+# - extract the first three chars of the sha1: use some shell triclery:
+# - prepend those three chars and a '/' to the full sha1
+BUILD_ID_SHORT="${BUILD_ID:0:3}"
+BUILD_ID="${BUILD_ID_SHORT}/${BUILD_ID}"
+
 mkdir -p "${BUILD_DIR}"
 if [ $? -ne 0 ] ; then
     echo "Cannot create output directory"
Signature · 1 line
1.9.1
#3 lore raw

v2 cover buildroot-test: misc enhancenments (branch yem/reproduce)

In reply to Yann E. MORIN

Dear Yann E. MORIN,

Quoted 3 lines · Yann E. MORIN

Yann E. MORIN (2):
br-reproduce-build: quote variables
br-reproduce-build: fix URL of gitid

Both applied, thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com