]>
git.ipfire.org Git - people/stevee/ipfire-3.x.git/blob - tools/make-git
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2008 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 # A small helper to make the git functions comfortable #
22 ###############################################################################
23 ###############################################################################
27 ###############################################################################
29 if [ -z "$EDITOR" ]; then
30 for i
in nano emacs vi
; do
31 EDITOR
=$
(which $i 2>/dev
/null
)
32 if ! [ -z "$EDITOR" ]; then
37 [ -z "$EDITOR" ] && exiterror
"You should have installed an editor."
40 CURRENT_BRANCH
=$
(git branch |
grep ^
* | cut
-c 3-)
43 if [ -d "$BASEDIR/.git" ]; then
44 ln -sf $BASEDIR/tools
/make-git
$BASEDIR/.git
/hooks
/pre-commit
47 ###############################################################################
49 # A small helper to make the git functions comfortable
51 ###############################################################################
54 if [ "$1" = "--batch" ]; then
56 git pull $
* |
grep -q "Already up-to-date." ||
rm -f $FAILED
57 [ -e $FAILED ] || distccd_restart
58 [ "$(expr $RANDOM % 25)" -eq "0" ] && git_gc
60 if [ "$CURRENT_BRANCH" == "master" ]; then
61 if ! (git status |
grep -q "working directory clean"); then
62 echo "Your \"master\" branch is not clean. This may cause a merge commit."
63 echo -n "Do you want this? [y/N]"
65 [ -z $REPLY ] && return 0
67 if [ "$i" == "$REPLY" ]; then
77 echo -n "You are not on branch \"master\". Do you want to rebase from \"master\"? [y/N]"
79 [ -z $REPLY ] && return 0
81 if [ "$i" == "$REPLY" ]; then
82 git rebase
-v refs
/heads
/master
86 exiterror
"\"$REPLY\" is not a valid answer."
94 [ "$CURRENT_BRANCH" == "master" ] || \
95 exiterror
"You have to be in branch \"master\", if you want to push."
96 git push
ssh://${IPFIRE_USER}@git.ipfire.org
/pub
/git
/ipfire-3.x master
104 [ "$?" -eq "0" ] || exiterror
"git commit $* failed."
108 DIFF_NAME
="${BASEDIR}/ipfire-diff-$(date '+%Y%m%d-%0k%0M').diff"
112 echo -ne "Make a local diff to last revision"
113 git
diff HEAD
> $DIFF_NAME
115 if [ -s $DIFF_NAME ]; then # if diff file is empty
116 echo "Diff was successfully saved to $DIFF_NAME"
125 echo -n "Generating changelog from repository"
127 [ -z $GIT_TAG ] || LAST_TAG
=$GIT_TAG
128 [ -z $LAST_TAG ] || EXT
="$LAST_TAG..HEAD"
130 git log
-n 500 --no-merges --pretty=medium
--shortstat $EXT > $BASEDIR/doc
/ChangeLog
139 git archive HEAD |
gzip -9 > ${SNAME}-${VERSION}.
source.
tar.gz
143 test $# -gt 0 || exiterror
"You need to pass the hostname of the remote host."
145 SSH_KEYGEN
=`which ssh-keygen`
146 if test $?
-ne 0; then
147 # Error message is printed by 'which'
152 if ! test -d $SSH_DIR; then
157 if [ ! -f $SSH_DIR/identity
] ||
[ ! -f $SSH_DIR/identity.pub
]; then
158 echo "Generating ssh1 RSA keys - please wait..."
159 rm -f $SSH_DIR/identity
$SSH_DIR/identity.pub
160 $SSH_KEYGEN -t rsa1
-f $SSH_DIR/identity
-P ''
161 if [ $?
-ne 0 ]; then
162 echo "Command \"$SSH_KEYGEN -t rsa1 -f $SSH_DIR/identity" \
163 "-P ''\" failed" 1>&2
167 echo "ssh1 RSA key is present"
170 if [ ! -f $SSH_DIR/id_dsa
] ||
[ ! -f $SSH_DIR/id_dsa.pub
]; then
171 echo "Generating ssh2 DSA keys - please wait..."
172 rm -f $SSH_DIR/id_dsa
$SSH_DIR/id_dsa.pub
173 $SSH_KEYGEN -t dsa
-f $SSH_DIR/id_dsa
-P ''
174 if test $?
-ne 0; then
175 echo "Command \"$SSH_KEYGEN -t dsa -f $SSH_DIR/id_dsa" \
176 "-P ''\" failed" 1>&2
180 echo "ssh2 DSA key is present"
183 SSH1_RSA_KEY
=`cat $SSH_DIR/identity.pub`
184 SSH2_DSA_KEY
=`cat $SSH_DIR/id_dsa.pub`
187 echo "You will now be asked for password for $IP"
188 ssh -oStrictHostKeyChecking=no
$IP "mkdir -p ~/.ssh; chmod 700 ~/.ssh; \
189 echo \"$SSH1_RSA_KEY\" >> ~/.ssh/authorized_keys; \
190 echo \"$SSH2_DSA_KEY\" >> ~/.ssh/authorized_keys2; \
191 chmod 600 ~/.ssh/authorized_keys ~/.ssh/authorized_keys2"
192 if test $?
-eq 0; then
193 echo "Keys were put successfully"
195 echo "Error putting keys to $IP" 1>&2
201 echo -n "Checking $IP connectivity by ssh$ver... "
202 ssh -q -oProtocol=${ver} -oBatchMode=yes \
203 -oStrictHostKeyChecking=no
$IP /bin
/true
209 git_hook_pre_commit
() {
210 local USERNAME USERMAIL
211 USERNAME
=$
(git config
--list |
grep ^user.name
)
212 USERNAME
=${USERNAME#user.name=}
214 USERMAIL
=$
(git config
--list |
grep ^user.email
)
215 USERMAIL
=${USERMAIL#user.email=}
217 if [[ ! "$USERMAIL" =~
"@ipfire\.org$" ]]; then
218 echo "User email is not from ipfire.org. Can't commit."
223 for i
in $USERNAME; do
224 COUNTER
=$
[ $COUNTER + 1 ]
227 if [ ! "$COUNTER" -ge 2 ]; then
228 echo "Setup user name as your real name. Can't commit."
234 if [ "$(basename $0)" = "pre-commit" ]; then