-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmkpkg
executable file
·195 lines (168 loc) · 6.07 KB
/
mkpkg
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
PKG="mirrorcommand"
SRC_NAME="MirrorCommand"
PKG_NAME="MirrorCommand"
TOP="usr"
DESTDIR="${TOP}/local"
MM="${DESTDIR}/${PKG_NAME}"
SRC=${HOME}/src
SUDO=sudo
GCI=
dpkg=`type -p dpkg-deb`
[ "${dpkg}" ] || {
echo "Debian packaging tools do not appear to be installed on this system"
echo "Are you on the appropriate Linux system with packaging requirements ?"
echo "Exiting"
exit 1
}
[ -f "${SRC}/${SRC_NAME}/VERSION" ] || {
[ -f "/builds/doctorfree/${SRC_NAME}/VERSION" ] || {
echo "$SRC/$SRC_NAME/VERSION does not exist. Exiting."
exit 1
}
SRC="/builds/doctorfree"
SUDO=
GCI=1
}
. "${SRC}/${SRC_NAME}/VERSION"
PKG_VER=${VERSION}
PKG_REL=${RELEASE}
# umask 0022
# Subdirectory in which to create the distribution files
OUT_DIR="dist/${PKG_NAME}_${PKG_VER}"
[ -d "${SRC}/${SRC_NAME}" ] || {
echo "$SRC/$SRC_NAME does not exist or is not a directory. Exiting."
exit 1
}
cd "${SRC}/${SRC_NAME}"
${SUDO} rm -rf dist
mkdir dist
[ -d ${OUT_DIR} ] && rm -rf ${OUT_DIR}
mkdir ${OUT_DIR}
cp -a pkg/debian ${OUT_DIR}/DEBIAN
chmod 755 ${OUT_DIR} ${OUT_DIR}/DEBIAN ${OUT_DIR}/DEBIAN/*
echo "Package: ${PKG}
Version: ${PKG_VER}-${PKG_REL}
Section: misc
Priority: optional
Architecture: all
Depends: git (>= 2.20.1), arp-scan (>= 1.9.5), wmctrl (>= 1.07-7), libmagic-dev, libatlas-base-dev, sox, libsox-fmt-all, build-essential, scrot, wget, unclutter, vlc, cec-utils, libudev-dev, jq (>= 1.4), fswebcam (>= 20140113)
Suggests: qterminal (>= 0.14.1)
Maintainer: ${DEBFULLNAME} <${DEBEMAIL}>
Installed-Size: 14000
Build-Depends: debhelper (>= 11)
Standards-Version: 4.1.3
Homepage: https://github.com/doctorfree/MirrorCommand
Description: MagicMirror Command Line Tools
Manage your MagicMirror from the command line" > ${OUT_DIR}/DEBIAN/control
chmod 644 ${OUT_DIR}/DEBIAN/control
for dir in "${TOP}" "${DESTDIR}" "${MM}" "${DESTDIR}/share" \
"${DESTDIR}/share/applications" "${DESTDIR}/share/doc" \
"${DESTDIR}/share/doc/${PKG}"
do
[ -d ${OUT_DIR}/${dir} ] || ${SUDO} mkdir ${OUT_DIR}/${dir}
${SUDO} chown root:root ${OUT_DIR}/${dir}
done
for dir in bin etc css config config-landscape config-notelegram config-landscape-notelegram modules pics
do
[ -d ${OUT_DIR}/${MM}/${dir} ] && ${SUDO} rm -rf ${OUT_DIR}/${MM}/${dir}
done
${SUDO} cp -a bin ${OUT_DIR}/${MM}/bin
for script in *.sh
do
grep ${script} .gitignore > /dev/null || {
dest=`echo ${script} | sed -e "s/\.sh//"`
${SUDO} cp ${script} ${OUT_DIR}/${MM}/bin/${dest}
}
done
for script in scripts/*.sh
do
grep ${script} .gitignore > /dev/null || {
dest=`echo ${script} | sed -e "s/scripts\///" -e "s/\.sh//"`
${SUDO} cp ${script} ${OUT_DIR}/${MM}/bin/${dest}
}
done
for script in remote/*
do
grep ${script} .gitignore > /dev/null || {
dest=`echo ${script} | sed -e "s/remote\///" -e "s/\.sh//"`
${SUDO} cp ${script} ${OUT_DIR}/${MM}/bin/${dest}
}
done
${SUDO} cp *.desktop "${OUT_DIR}/${DESTDIR}/share/applications"
${SUDO} cp AUTHORS ${OUT_DIR}/${DESTDIR}/share/doc/${PKG}/AUTHORS
${SUDO} cp LICENSE ${OUT_DIR}/${DESTDIR}/share/doc/${PKG}/copyright
${SUDO} cp CHANGELOG.md ${OUT_DIR}/${DESTDIR}/share/doc/${PKG}/changelog
${SUDO} cp README.md ${OUT_DIR}/${DESTDIR}/share/doc/${PKG}/README
${SUDO} gzip -9 ${OUT_DIR}/${DESTDIR}/share/doc/${PKG}/changelog
${SUDO} cp -a markdown "${OUT_DIR}/${DESTDIR}/share/doc/${PKG}/markdown"
${SUDO} cp -a man "${OUT_DIR}/${DESTDIR}/share/doc/${PKG}/man"
${SUDO} cp -a man "${OUT_DIR}/${DESTDIR}/share/man"
${SUDO} cp -a config ${OUT_DIR}/${MM}/config
${SUDO} cp -a config-notelegram ${OUT_DIR}/${MM}/config-notelegram
${SUDO} cp -a config-landscape ${OUT_DIR}/${MM}/config-landscape
${SUDO} cp -a config-landscape-notelegram ${OUT_DIR}/${MM}/config-landscape-notelegram
${SUDO} cp -a css ${OUT_DIR}/${MM}/css
${SUDO} cp -a etc ${OUT_DIR}/${MM}/etc
${SUDO} cp -a modules ${OUT_DIR}/${MM}/modules
[ -f .gitignore ] && {
while read ignore
do
${SUDO} rm -f ${OUT_DIR}/${MM}/${ignore}
done < .gitignore
}
${SUDO} chmod 755 ${OUT_DIR}/${MM}/bin/*
cd dist
echo "Building ${PKG_NAME}_${PKG_VER}-${PKG_REL} package"
${SUDO} dpkg --build ${PKG_NAME}_${PKG_VER} ${PKG_NAME}_${PKG_VER}-${PKG_REL}.deb
cd ${PKG_NAME}_${PKG_VER}
echo "Creating compressed tar archive of ${PKG_NAME} ${PKG_VER}-${PKG_REL} distribution"
tar cf - usr | gzip -9 > ../${PKG_NAME}_${PKG_VER}-${PKG_REL}.tgz
have_zip=`type -p zip`
[ "${have_zip}" ] || {
${SUDO} apt-get update
${SUDO} apt-get install zip -y
}
echo "Creating zip archive of ${PKG_NAME} ${PKG_VER}-${PKG_REL} distribution"
zip -q -r ../${PKG_NAME}_${PKG_VER}-${PKG_REL}.zip usr
cd ..
[ "${GCI}" ] || {
[ -d ../releases ] || mkdir ../releases
[ -d ../releases/${PKG_VER} ] || mkdir ../releases/${PKG_VER}
${SUDO} cp *.deb *.tgz *.zip ../releases/${PKG_VER}
}
# RPM distribution build
cd "${SRC}/${SRC_NAME}"
[ -d pkg/rpm ] && cp -a pkg/rpm ${OUT_DIR}/rpm
[ -d ${OUT_DIR}/rpm ] || mkdir ${OUT_DIR}/rpm
have_rpm=`type -p rpmbuild`
[ "${have_rpm}" ] || {
${SUDO} apt-get update
export DEBIAN_FRONTEND=noninteractive
${SUDO} ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
${SUDO} apt-get install rpm -y
${SUDO} dpkg-reconfigure --frontend noninteractive tzdata
}
rpmbuild -ba --build-in-place \
--define "_topdir ${OUT_DIR}" \
--define "_sourcedir ${OUT_DIR}" \
--define "_version ${PKG_VER}" \
--define "_release ${PKG_REL}" \
--buildroot ${SRC}/${SRC_NAME}/${OUT_DIR}/BUILDROOT \
${OUT_DIR}/rpm/${PKG_NAME}.spec
# Rename RPMs if necessary
for rpmfile in ${OUT_DIR}/RPMS/*/*.rpm
do
[ "${rpmfile}" == "${OUT_DIR}/RPMS/*/*.rpm" ] && continue
rpmbas=`basename ${rpmfile}`
rpmdir=`dirname ${rpmfile}`
newnam=`echo ${rpmbas} | sed -e "s/${PKG_NAME}-${PKG_VER}-${PKG_REL}/${PKG_NAME}_${PKG_VER}-${PKG_REL}/" -e "s/noarch.rpm/rpm/"`
[ "${rpmbas}" == "${newnam}" ] && continue
mv ${rpmdir}/${rpmbas} ${rpmdir}/${newnam}
done
${SUDO} cp ${OUT_DIR}/RPMS/*/*.rpm dist
[ "${GCI}" ] || {
[ -d releases ] || mkdir releases
[ -d releases/${PKG_VER} ] || mkdir releases/${PKG_VER}
${SUDO} cp ${OUT_DIR}/RPMS/*/*.rpm releases/${PKG_VER}
}