/src/rt: ignore the build/ directory
[msysgit.git] / src / common / update-lib.sh
blob832f50c3a90836ceb66108f5f38584bebe96cc0f
1 #!/bin/sh
3 # Make sure that the working directory is clean and does not have untracked
4 # files; otherwise our semi-automatic finding the new files will not work!
6 die () {
7 echo "$*" >&2
8 exit 1
11 check_pristine () {
12 (cd / &&
13 git diff-files --quiet &&
14 git diff-index --cached --quiet HEAD &&
15 others="$(git ls-files --exclude-from=.gitignore \
16 --exclude-per-directory=.gitignore --others)" &&
17 test -z "$others") ||
18 die "State not pristine enough for successful package update"
21 # Remove old files stored in fileList.txt
22 pre_install () {
23 test -z "$FILELIST" && {
24 echo "No file list specified for pre_install"
25 exit 1
27 ! test -s "$FILELIST" ||
28 cat "$FILELIST" | (cd / && xargs git rm --ignore-unmatch) ||
29 exit
32 # update the index
33 post_install () {
34 (cd / && git add .) || exit
36 git diff --cached --diff-filter=AM --name-only |
37 sed -e "s/^/\//" > "$FILELIST" ||
38 exit
40 git add "$FILELIST" || exit
42 echo "Successfully built and installed $package $version"
43 echo "After checking the result, please commit (possibly with --amend)"
44 echo
47 download () {
48 test -z "$tar" &&
49 die "Script did not specify an archive"
50 test -f "$tar" || {
51 echo "Downloading $tar ..."
52 curl $url/$tar -o $tar || exit
56 extract () {
57 test -z "$d" &&
58 die "Script did not specify a directory"
59 test -d "$d" || {
60 echo "Unpacking $tar ..."
61 case "$tar" in
62 *.tar.gz|*.tgz)
63 tar -xzf "$tar"
65 *.tar.bz2|*.tbz)
66 tar -xjf "$tar"
68 *.zip)
69 unzip "$tar"
71 esac || exit
75 apply_patches () {
76 test -d "$d"/.git && return
77 patchdir="$(pwd)"/patches
78 (cd "$d" &&
79 git init &&
80 git add . &&
81 git commit -m initial &&
82 for p in "$patchdir"/*.patch
84 git am "$p" || exit
85 done) ||
86 exit
89 setup () {
90 test -z "$d" &&
91 die "Script did not specify a directory"
92 test -f "$d/Makefile" ||
93 (cd "$d" && ./configure $configure_options) || exit
96 compile () {
97 test -z "$d" &&
98 die "Script did not specify a directory"
99 (cd "$d" && make) || exit
102 download_extract_setup_and_compile () {
103 download &&
104 extract &&
105 setup &&
106 compile || exit