-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-mod.sh
107 lines (93 loc) · 2.91 KB
/
generate-mod.sh
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
#
# Copyright (c) 2020 DefKorns (https://defkorns.github.io/LICENSE)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# shellcheck disable=SC2001
PKG_PRETTY_NAME="Emulationstation: PSX Playlist"
PKG_NAME="es-psx-playlist"
PKG_CREATOR="DefKorns"
MAINTAINER="DefKorns <[email protected]>"
PLATFORM="SONYPSC"
ARCHITECTURE="armhf"
PKG_TARGET="${PKG_NAME}_${PLATFORM}"
PREINST="${PKG_TARGET}/DEBIAN/preinst"
POSTINST="${PKG_TARGET}/DEBIAN/postinst"
POSTRM="${PKG_TARGET}/DEBIAN/postrm"
CONTROL="${PKG_TARGET}/DEBIAN/control"
VERSION="$([ -f VERSION ] && head VERSION || echo "0.0.1")"
LAST_TAG_COMMIT=$(git rev-list --tags --max-count=1)
LAST_TAG=$(git describe --tags "${LAST_TAG_COMMIT}")
MAJOR=$(echo "${VERSION}" | sed "s/^\([0-9]*\).*/\1/")
MINOR=$(echo "${VERSION}" | sed "s/[0-9]*\.\([0-9]*\).*/\1/")
PATCH=$(echo "${VERSION}" | sed "s/[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/")
NEXT_MAJOR_VERSION="$((MAJOR + 1)).0.0"
NEXT_MINOR_VERSION="${MAJOR}.$((MINOR + 1))"
NEXT_PATCH_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
modCreation() {
mkdir -p "${PKG_TARGET}/DEBIAN"
cp -rf mod/* ${PKG_TARGET}/
{
printf "%s\n" \
"Package: ${PKG_NAME}" \
"Author: ${PKG_CREATOR}" \
"Version: ${VERSION}" \
"Built: $(date)" \
"Section: mods" \
"Priority: optional" \
"Architecture: ${ARCHITECTURE}" \
"Platform: ${PLATFORM} ${ARCHITECTURE}" \
"Maintainer: ${MAINTAINER}" \
"Description: ${PKG_PRETTY_NAME}"
cat mod_description.txt
} >>${CONTROL}
[ -f "preinst" ] && cp -rf preinst ${PREINST} && chmod 755 ${PREINST}
[ -f "postinst" ] && cp -rf postinst ${POSTINST} && chmod 755 ${POSTINST}
[ -f "postrm" ] && cp -rf postrm ${POSTRM} && chmod 755 ${POSTRM}
dpkg-deb -b ${PKG_TARGET}
mv ${PKG_TARGET}.deb ${PKG_TARGET}.mod
rm -r ${PKG_TARGET:?}/
touch ${PKG_TARGET}.mod
}
checkVersion() {
echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
}
clean() {
rm -rf ${PKG_TARGET:?}/ ${PKG_TARGET}.mod
}
case "$1" in
clean)
clean
;;
minor)
clean
modCreation
echo "${NEXT_MINOR_VERSION}" >VERSION
;;
major)
clean
modCreation
echo "${NEXT_MAJOR_VERSION}" >VERSION
;;
*)
clean
modCreation
echo "${NEXT_PATCH_VERSION}" >VERSION
if [ "$(checkVersion "${VERSION}")" -gt "$(checkVersion "${LAST_TAG}")" ]; then
git tag "$VERSION"
fi
;;
esac
#EOF