/src/openssl/release.sh: make sure to cd to the correct directory first
[msysgit/mtrensch.git] / src / openssl / release.sh
blob15d29244424e21f4bac01a8286c9d38954723d28
1 #!/bin/sh
3 cd "$(dirname "$0")"
5 VERSION=0.9.8k
6 DIR=openssl-$VERSION
7 URL=http://www.openssl.org/source/$DIR.tar.gz
8 FILE=${URL##*/}
10 die () {
11 echo "$*" >&2
12 exit 1
15 replace_symlinks_with_copies () {
16 BRANCH=$1
17 SYMLINKS="$(git ls-tree -r $BRANCH: | sed -n 's/^120000.\{47\}//p')" &&
18 if test -z "$SYMLINKS"
19 then
20 die "No symlinks found? You need to update your /git/."
21 else
22 (export GIT_INDEX_FILE=.git/tmp &&
23 git read-tree $BRANCH &&
24 i=1 &&
25 total=$(echo "$SYMLINKS" | wc -l) &&
26 UPDATES="$(echo "$SYMLINKS" |
27 while read path
29 printf "\rProcessing symlink ($i/$total)" >&2 &&
30 i=$(($i+1)) &&
31 BASEDIR="${path%/*}/" &&
32 TARGET="$(git cat-file blob $BRANCH:$path)" &&
33 while test "$TARGET" != "${TARGET#../}"
35 BASEDIR="$(echo "$BASEDIR" |
36 sed 's|[^/]*/$||')" &&
37 TARGET="${TARGET#../}"
38 done &&
39 git ls-files --stage "$BASEDIR$TARGET" |
40 sed "s| .*$| $path|"
41 done)" &&
42 echo "$UPDATES" | git update-index --index-info &&
43 TREE=$(git write-tree) &&
44 COMMIT=$(echo "Replace symlinks with copies" |
45 git commit-tree $TREE -p $BRANCH) &&
46 git update-ref refs/heads/$BRANCH $COMMIT)
51 apply_patches () {
52 test $(ls ../patches/*.patch | wc -l) = \
53 $(($(git rev-list HEAD | wc -l)-2)) && return
54 git am ../patches/*.patch
57 test -d $DIR || {
58 test -f $FILE ||
59 curl -O $URL ||
60 die "Could not download OpenSSL"
62 mkdir $DIR && (
63 cd $DIR &&
64 git init &&
65 /git/contrib/fast-import/import-tars.perl ../$FILE
67 } || die "Could not check out openssl"
69 test $(cat $DIR/apps/md4.c 2> /dev/null | wc -l) -gt 2 || (
70 cd $DIR &&
71 replace_symlinks_with_copies import-tars &&
72 git checkout import-tars &&
73 test $(wc -l < apps/md4.c) -gt 2
74 ) || die "Could not replace symlinks with copies"
76 test grep INSTALLTOP=/mingw $DIR/Makefile > /dev/null 2>&1 || (
77 cd $DIR &&
78 apply_patches
79 ) || die "Could not apply the patches"
81 test -f $DIR/openssl.dll || (
82 cd $DIR &&
83 cmd /c ms\\mingw32.bat &&
84 cd out &&
85 list=$(echo *.dll openssl.exe) &&
86 cp $list /mingw/bin && (
87 cd /mingw/bin &&
88 git add $list &&
89 git commit -s -m "Install OpenSSL $VERSION"
90 ) &&
91 cd ../outinc &&
92 cp -r openssl /mingw/include &&
94 cd /mingw/include &&
95 git add openssl &&
96 git commit -s -m "Install OpenSSL $VERSION header files"
98 ) || die "Could not install $FILE"