-
Notifications
You must be signed in to change notification settings - Fork 15
/
resetdeb
executable file
·92 lines (75 loc) · 2.46 KB
/
resetdeb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
function err_mess ()
{
echo "$(basename $0): error: $1" > /dev/stderr;
}
[ -f "Makefile" ] || { err_mess "makefile not found"; exit 1; }
[ -f "configure.ac" ] || { err_mess "configure.ac not found"; exit 1; }
DISTRO="hardy"
if [ -n "$1" ]
then
DISTRO="$1";
shift;
fi
case $DISTRO in
gutsy|hardy);;
default) err_mess "unknown distro: $DISTRO";
exit 1;
;;
esac
BASE_NAME=$(head -n 50 configure.ac | grep "m4_define(\[library_base_name\], \[.*\])" | sed "s/m4_define(\[library_base_name\], \[\(.*\)\])/\1/")
API_VERSION=$(head -n 50 configure.ac | grep "m4_define(\[api_version\], \[.*\])" | sed "s/m4_define(\[api_version\], \[\(.*\)\])/\1/")
MAJOR_VER=$(head -n 50 configure.ac | grep "m4_define(\[package_major_version\], \[.*\])" | sed "s/m4_define(\[package_major_version\], \[\(.*\)\])/\1/")
MINOR_VER=$(head -n 50 configure.ac | grep "m4_define(\[package_minor_version\], \[.*\])" | sed "s/m4_define(\[package_minor_version\], \[\(.*\)\])/\1/")
MICRO_VER=$(head -n 50 configure.ac | grep "m4_define(\[package_micro_version\], \[.*\])" | sed "s/m4_define(\[package_micro_version\], \[\(.*\)\])/\1/")
NAME="lib${BASE_NAME}"
NAME1="lib${BASE_NAME}-${API_VERSION}-${MAJOR_VER}"
NAMEDEV1="${NAME1}-dev"
NAMEDBG1="${NAME1}-dbg"
VER="${MAJOR_VER}.${MINOR_VER}.${MICRO_VER}"
DEBIAN_IN_DIR="debian.in"
REL_SUB_VER_FILE="${DEBIAN_IN_DIR}/${DISTRO}/release_subv"
[ -f "$REL_SUB_VER_FILE" ] || { err_mess "release_subv not found"; exit 1; }
REL_SUB_VER="$(cat "${REL_SUB_VER_FILE}")";
echo "$REL_SUB_VER" | grep -q "[[:digit:]]\+" || { err_mess "invalid release subversion: $REL_SUB_VER"; exit 1;}
NAME_HYPHEN="${NAME}-${API_VERSION}-${VER}"
RESULTS_DIR="/var/cache/pbuilder_${DISTRO}/result"
BUILD_DIR="${HOME}/deb_builds/${DISTRO}/${NAME_HYPHEN}"
DEB_DIR_TEMPL="${DEBIAN_IN_DIR}/${DISTRO}/debian.template"
if [ -f "$DEB_DIR_TEMPL/changelog" ]
then
echo "Changelog found:"
cat "$DEB_DIR_TEMPL/changelog" | sed "s/.*/ > &/"
echo
ANSW="maybe"
while [[ $ANSW != yes && $ANSW != no ]]
do
echo -n "Delete it? (yes/no) "
read ANSW
done
if [[ $ANSW == no ]]
then
exit 0;
fi
rm -f "$DEB_DIR_TEMPL/changelog" || exit 1;
fi
echo "0" > "${REL_SUB_VER_FILE}" || exit 0
if [ -d "${BUILD_DIR}" ]
then
echo "Build directory found:"
echo
ls -1 ${BUILD_DIR} | sed "s/.*/ > &/"
echo
ANSW="maybe"
while [[ $ANSW != yes && $ANSW != no ]]
do
echo -n "Delete it? (yes/no) "
read ANSW
done
if [[ $ANSW == no ]]
then
exit 0;
fi
rm -fr "${BUILD_DIR}" || exit 1;
fi
echo "Done"