|
@@ -1,66 +1,14 @@
|
|
|
#!/bin/bash
|
|
|
# Recommended command-line:
|
|
|
#
|
|
|
-# commit-db.rb list-valid nightly|GIT_DIR=/your/rust/dir/.git sync.sh
|
|
|
-
|
|
|
-git_file_exists() {
|
|
|
- [ "$(git ls-tree --name-only $IO_COMMIT -- $1)" = "$1" ]
|
|
|
-}
|
|
|
-
|
|
|
-git_extract() {
|
|
|
- slashes=${1//[^\/]/}
|
|
|
- git archive $IO_COMMIT $1|tar xf - -C src/$IO_COMMIT --strip-components=${#slashes}
|
|
|
-}
|
|
|
-
|
|
|
-git_commits_ordered() {
|
|
|
- format=$1
|
|
|
- shift
|
|
|
- if [ $# -ge 1 ]; then
|
|
|
- git log --topo-order --no-walk=sorted --date=iso-local --pretty=format:$format "$@"
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
-echo_lines() {
|
|
|
- for i in "$@"; do
|
|
|
- echo $i
|
|
|
- done
|
|
|
-}
|
|
|
-
|
|
|
-get_io_commits() {
|
|
|
- for COMPILER_COMMIT in $COMPILER_COMMITS; do
|
|
|
- IO_COMMIT=$(git log -n1 --pretty=format:%H $COMPILER_COMMIT -- src/libstd/io)
|
|
|
- if ! grep -q $COMPILER_COMMIT mapping.rs; then
|
|
|
- echo "-Mapping(\"$COMPILER_COMMIT\",\"$IO_COMMIT\")" >> mapping.rs
|
|
|
- fi
|
|
|
- echo $IO_COMMIT
|
|
|
- done
|
|
|
-}
|
|
|
-
|
|
|
-get_patch_commits() {
|
|
|
- find $PATCH_DIR -type f -printf %f\\n|cut -d. -f1
|
|
|
-}
|
|
|
-
|
|
|
-prepare_version() {
|
|
|
- mkdir src/$IO_COMMIT
|
|
|
- git_extract src/libstd/io/
|
|
|
- if git_file_exists src/libstd/sys/common/memchr.rs; then
|
|
|
- git_extract src/libstd/sys/common/memchr.rs
|
|
|
- else
|
|
|
- git_extract src/libstd/memchr.rs
|
|
|
- fi
|
|
|
- rm -f src/$IO_COMMIT/stdio.rs src/$IO_COMMIT/lazy.rs
|
|
|
-}
|
|
|
-
|
|
|
-bold_arrow() {
|
|
|
- echo -ne '\e[1;36m==> \e[0m'
|
|
|
-}
|
|
|
+# commit-db.rb list-valid nightly|GIT_DIR=/your/rust/dir/.git ./build-src.sh
|
|
|
|
|
|
prompt_changes() {
|
|
|
local MAIN_GIT_DIR="$GIT_DIR"
|
|
|
local GIT_DIR=./.git CORE_IO_COMMIT=$IO_COMMIT
|
|
|
git init > /dev/null
|
|
|
git add .
|
|
|
- git commit -a -m "rust src import" > /dev/null
|
|
|
+ git commit -m "rust src import" > /dev/null
|
|
|
export CORE_IO_COMMIT
|
|
|
|
|
|
bold_arrow; echo 'No patch found for' $IO_COMMIT
|
|
@@ -72,24 +20,7 @@ prompt_changes() {
|
|
|
bold_arrow; echo -e "Try applying one of those using: \e[1;36mpatch -p1 < ../../patches/COMMIT.patch\e[0m"
|
|
|
bold_arrow; echo -e "Remember to test your changes with: \e[1;36mcargo build\e[0m"
|
|
|
bold_arrow; echo -e "Make your changes now (\e[1;36mctrl-D\e[0m when finished)"
|
|
|
- bash <> /dev/stderr
|
|
|
- while git diff --exit-code > /dev/null; do
|
|
|
- bold_arrow; echo "No changes were made"
|
|
|
- while true; do
|
|
|
- bold_arrow; echo -n "(T)ry again or (A)bort? "
|
|
|
- read answer <> /dev/stderr
|
|
|
- case "$answer" in
|
|
|
- [tT])
|
|
|
- break
|
|
|
- ;;
|
|
|
- [aA])
|
|
|
- bold_arrow; echo "Aborting..."
|
|
|
- exit 1
|
|
|
- ;;
|
|
|
- esac
|
|
|
- done
|
|
|
- bash <> /dev/stderr
|
|
|
- done
|
|
|
+ bash_diff_loop "No changes were made"
|
|
|
bold_arrow; echo "Saving changes as $IO_COMMIT.patch"
|
|
|
git clean -f -x
|
|
|
git diff > ../../patches/$IO_COMMIT.patch
|
|
@@ -103,6 +34,9 @@ if [ ! -t 1 ] || [ ! -t 2 ]; then
|
|
|
fi
|
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
+
|
|
|
+. ./functions.sh
|
|
|
+
|
|
|
PATCH_DIR="$PWD/patches"
|
|
|
COMPILER_COMMITS=$(cat)
|
|
|
IO_COMMITS=$(get_io_commits|sort -u)
|
|
@@ -110,6 +44,9 @@ PATCH_COMMITS=$(get_patch_commits|sort -u)
|
|
|
NEW_COMMITS=$(comm -2 -3 <(echo_lines $IO_COMMITS) <(echo_lines $PATCH_COMMITS))
|
|
|
OLD_COMMITS=$(comm -1 -2 <(echo_lines $IO_COMMITS) <(echo_lines $PATCH_COMMITS))
|
|
|
|
|
|
+set -e
|
|
|
+set -o pipefail
|
|
|
+
|
|
|
find src -mindepth 1 -type d -prune -exec rm -rf {} \;
|
|
|
|
|
|
for IO_COMMIT in $OLD_COMMITS $(git_commits_ordered %H $NEW_COMMITS|tac); do
|
|
@@ -117,6 +54,7 @@ for IO_COMMIT in $OLD_COMMITS $(git_commits_ordered %H $NEW_COMMITS|tac); do
|
|
|
prepare_version
|
|
|
|
|
|
if [ -f patches/$IO_COMMIT.patch ]; then
|
|
|
+ bold_arrow; echo "Patching $IO_COMMIT"
|
|
|
patch -s -p1 -d src/$IO_COMMIT < patches/$IO_COMMIT.patch
|
|
|
else
|
|
|
cd src/$IO_COMMIT
|
|
@@ -126,6 +64,8 @@ for IO_COMMIT in $OLD_COMMITS $(git_commits_ordered %H $NEW_COMMITS|tac); do
|
|
|
fi
|
|
|
done
|
|
|
|
|
|
+OLD_GIT_PERM=$(stat --printf=%a .git)
|
|
|
+trap "chmod $OLD_GIT_PERM .git; exit 1" SIGINT
|
|
|
chmod 000 .git
|
|
|
cargo package
|
|
|
-chmod 755 .git
|
|
|
+chmod $OLD_GIT_PERM .git
|