Set lock_path correctly.
[openstack-build/neutron-build.git] / tools / misc-sanity-checks.sh
1 #! /bin/sh
2
3 # Copyright (C) 2014 VA Linux Systems Japan K.K.
4 # Copyright (C) 2014 YAMAMOTO Takashi <yamamoto at valinux co jp>
5 # All Rights Reserved.
6 #
7 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
8 #    not use this file except in compliance with the License. You may obtain
9 #    a copy of the License at
10 #
11 #         http://www.apache.org/licenses/LICENSE-2.0
12 #
13 #    Unless required by applicable law or agreed to in writing, software
14 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16 #    License for the specific language governing permissions and limitations
17 #    under the License.
18
19 TMPDIR=`mktemp -d /tmp/${0##*/}.XXXXXX` || exit 1
20 export TMPDIR
21 trap "rm -rf $TMPDIR" EXIT
22
23 FAILURES=$TMPDIR/failures
24
25
26 check_no_symlinks_allowed () {
27     # Symlinks break the package build process, so ensure that they
28     # do not slip in, except hidden symlinks.
29     if [ $(find . -type l ! -path '*/.*' | wc -l) -ge 1 ]; then
30         echo "Symlinks are not allowed!" >>$FAILURES
31     fi
32 }
33
34
35 check_pot_files_errors () {
36     # The job neutron-propose-translation-update does not update from
37     # transifex since our po files contain duplicate entries where
38     # obsolete entries duplicate normal entries. Prevent obsolete
39     # entries to slip in
40     find neutron -type f -regex '.*\.pot?' \
41                  -print0|xargs -0 -n 1 msgfmt --check-format \
42                  -o /dev/null
43     if [ "$?" -ne 0 ]; then
44         echo "PO files syntax is not correct!" >>$FAILURES
45     fi
46 }
47
48
49 check_identical_policy_files () {
50     # For unit tests, we maintain their own policy.json file to make test suite
51     # independent of whether it's executed from the neutron source tree or from
52     # site-packages installation path. We don't want two copies of the same
53     # file to diverge, so checking that they are identical
54     diff etc/policy.json neutron/tests/etc/policy.json 2>&1 > /dev/null
55     if [ "$?" -ne 0 ]; then
56         echo "policy.json files must be identical!" >>$FAILURES
57     fi
58 }
59
60 # Add your checks here...
61 check_no_symlinks_allowed
62 check_pot_files_errors
63 check_identical_policy_files
64
65 # Fail, if there are emitted failures
66 if [ -f $FAILURES ]; then
67     cat $FAILURES
68     exit 1
69 fi