Add /src/rebase
[msysgit.git] / src / common / update-lib.sh
blob126e6d1788c1e1f6a6aaf08032fca7fa4bb80c4e
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 --ignore-unmatch rm) ||
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 setup () {
76 test -z "$d" &&
77 die "Script did not specify a directory"
78 test -f "$d/Makefile" ||
79 (cd "$d" && ./configure $configure_options) || exit
82 compile () {
83 test -z "$d" &&
84 die "Script did not specify a directory"
85 (cd "$d" && make) || exit
88 download_extract_setup_and_compile () {
89 download &&
90 extract &&
91 setup &&
92 compile || exit