coreboot-kgpe-d16/util/scripts/update_submodules
Paul Menzel 38a906b0e1 util: Make TZ environment variable POSIX compatible
`TZ='UTC'` is not a portable setting for the TZ environment variable.
POSIX says you’re supposed to use something like `TZ='UTC0'` instead.
Although `TZ='UTC'` works when GLIBC is used, this is not necessarily
true on other POSIX platforms. [1][2]

[1] http://lists.alioth.debian.org/pipermail/reproducible-builds/Week-of-Mon-20170918/009289.html
[2] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03

Change-Id: I1dca0b84de0ec0af3a103e2cbbf731512eb59497
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
Reviewed-on: https://review.coreboot.org/21721
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Reviewed-by: Martin Roth <martinroth@google.com>
2017-10-14 11:28:14 +00:00

73 lines
2.2 KiB
Bash
Executable file

#!/bin/bash
# This file is part of the coreboot project.
#
# Copyright (C) 2017 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# Description:
# Check all submodules for updates. If there are more than a minimum
# number of changes, create a commit to update the submodule to the
# new version.
export LANG=C
export LC_ALL=C
export TZ=UTC0
min_commits=10
TOP=${PWD}
SUBMODULES_WITH_UPDATES=0
submodule_dirs=$(git submodule foreach pwd | grep -v Entering)
(
echo "Checking submodules..."
for submodule in $submodule_dirs; do
cd "$submodule" || exit 1
initial_commit_id="$(git log --pretty='%h' -n 1)"
initial_commit_description="$(git log --pretty='%ci - (%s)' -n 1)"
git fetch 2>/dev/null
updated_commit_id="$(git log --pretty='%h' -n 1 origin/master)"
updated_commit_description="$(git log --pretty='%ci - (%s)' -n 1 "${updated_commit_id}")"
if [ "${initial_commit_id}" = "${updated_commit_id}" ]; then
# echo "No updates for ${submodule}"
continue
fi
SUBMODULES_WITH_UPDATES+=1
update_count="$(git log --oneline "${initial_commit_id}..${updated_commit_id}" | wc -l)"
echo "${update_count} new commits for ${submodule}"
if [ "${update_count}" -ge "${min_commits}" ]; then
echo "Creating commit to update ${submodule##*/} submodule"
git checkout "${updated_commit_id}" > /dev/null 2>&1
cd "${TOP}" || exit 1
sleep 1
git add "${submodule}" > /dev/null 2>&1 || exit 1
sleep 1
git commit -s -F- > /dev/null 2>&1 <<EOF
Update ${submodule##*/} submodule to upstream master
Updating from commit id ${initial_commit_id}:
$initial_commit_description
to commit id ${updated_commit_id}:
${updated_commit_description}
This brings in ${update_count} new commits.
EOF
sleep 1
fi
done
if [ "${SUBMODULES_WITH_UPDATES}" = "0" ]; then
echo "No submodules with any updates."
fi
)