-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mkpkg
executable file
·245 lines (207 loc) · 8.66 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#!/bin/bash
PKG="musicplayerplus"
SRC_NAME="MusicPlayerPlus"
PKG_NAME="MusicPlayerPlus"
DEBFULLNAME="Ronald Record"
DEBEMAIL="[email protected]"
DESTDIR="usr"
SRC=${HOME}/src
SUDO=sudo
GCI=
arch=
centos=
debian=
fedora=
export __MPP_SRC__=`pwd`
[ -f /etc/os-release ] && . /etc/os-release
[ "${ID_LIKE}" == "debian" ] && debian=1
[ "${ID}" == "arch" ] || [ "${ID_LIKE}" == "arch" ] && arch=1
[ "${ID}" == "centos" ] && centos=1
[ "${ID}" == "fedora" ] && fedora=1
[ "${debian}" ] || [ -f /etc/debian_version ] && debian=1
[ "${arch}" ] || [ "${debian}" ] || [ "${fedora}" ] || [ "${centos}" ] || {
echo "${ID_LIKE}" | grep debian > /dev/null && debian=1
}
if [ "${arch}" ]
then
sudo pacman -Syy
scripts/mkaur.sh
exit 0
fi
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"
GCI=1
# SUDO=
}
. "${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: sound
Priority: optional
Architecture: all
Depends: alsa-utils, bc, coreutils, curl, dialog, flac, jq, libboost-all-dev (>= 1.71.0), libcurl4 (>= 7.68.0), libmpdclient2 (>= 2.9), libncursesw6 (>= 6), libreadline8 (>= 6.0), libtag1v5 (>= 1.11), libtinfo6 (>= 6), mediainfo, mpd (>= 0.21.20), tmux, ffmpeg, inotify-tools, mpc, python3-dev, python3-pip, mplayer, libchromaprint-dev, dconf-cli, uuid-runtime, libeigen3-dev, libfftw3-dev, libsamplerate0, libiniparser-dev, libyaml-dev, libsdl2-dev, libasound2, libpulse-dev, libcurl4-openssl-dev, libsqlite3-0 (>= 3.6.0), libavformat-dev, libavfilter-dev, libswresample-dev, libavcodec-dev, libswscale-dev, libavdevice-dev, libavutil-dev, wget, wmctrl, x11-utils, x11-xserver-utils, imagemagick
Maintainer: ${DEBFULLNAME} <${DEBEMAIL}>
Installed-Size: 34728
Build-Depends: debhelper (>= 11)
Provides: mpd-client
Suggests: desktop-file-utils
Homepage: https://github.com/doctorfree/MusicPlayerPlus
Description: Music Player Plus
Music server, player, and services management system" > ${OUT_DIR}/DEBIAN/control
chmod 644 ${OUT_DIR}/DEBIAN/control
for dir in "${DESTDIR}" "${DESTDIR}/share" "${DESTDIR}/share/man" \
"${DESTDIR}/share/applications" "${DESTDIR}/share/doc" \
"${DESTDIR}/share/doc/${PKG}" "${DESTDIR}/share/${PKG}" \
"${DESTDIR}/share/${PKG}/mpcplus"
do
[ -d ${OUT_DIR}/${dir} ] || ${SUDO} mkdir ${OUT_DIR}/${dir}
${SUDO} chown root:root ${OUT_DIR}/${dir}
done
for dir in bin
do
[ -d ${OUT_DIR}/${DESTDIR}/${dir} ] && ${SUDO} rm -rf ${OUT_DIR}/${DESTDIR}/${dir}
done
${SUDO} cp -a bin ${OUT_DIR}/${DESTDIR}/bin
${SUDO} cp *.desktop "${OUT_DIR}/${DESTDIR}/share/applications"
${SUDO} cp copyright ${OUT_DIR}/${DESTDIR}/share/doc/${PKG}
${SUDO} cp LICENSE ${OUT_DIR}/${DESTDIR}/share/doc/${PKG}
${SUDO} cp AUTHORS ${OUT_DIR}/${DESTDIR}/share/doc/${PKG}
${SUDO} cp CHANGELOG.md ${OUT_DIR}/${DESTDIR}/share/doc/${PKG}
${SUDO} cp README.md ${OUT_DIR}/${DESTDIR}/share/doc/${PKG}
pandoc -f gfm README.md | ${SUDO} tee ${OUT_DIR}/${DESTDIR}/share/doc/${PKG}/README.html > /dev/null
${SUDO} gzip -9 ${OUT_DIR}/${DESTDIR}/share/doc/${PKG}/CHANGELOG.md
${SUDO} cp -a share/alsa-capabilities ${OUT_DIR}/${DESTDIR}/share/doc/${PKG}/alsa-capabilities
${SUDO} cp VERSION ${OUT_DIR}/${DESTDIR}/share/${PKG}
${SUDO} cp asound.conf.tmpl ${OUT_DIR}/${DESTDIR}/share/${PKG}
${SUDO} cp config/default_cover.png ${OUT_DIR}/${DESTDIR}/share/${PKG}/mpcplus
${SUDO} cp config/fzmp.conf ${OUT_DIR}/${DESTDIR}/share/${PKG}/mpcplus
${SUDO} cp -a share/scripts ${OUT_DIR}/${DESTDIR}/share/${PKG}/scripts
${SUDO} cp -a share/calliope ${OUT_DIR}/${DESTDIR}/share/${PKG}/calliope
${SUDO} cp -a share/figlet-fonts ${OUT_DIR}/${DESTDIR}/share/${PKG}/figlet-fonts
${SUDO} cp config/xterm-24bit.src ${OUT_DIR}/${DESTDIR}/share/${PKG}
${SUDO} cp config/tmux.conf ${OUT_DIR}/${DESTDIR}/share/${PKG}
${SUDO} cp config/mpprc ${OUT_DIR}/${DESTDIR}/share/${PKG}
${SUDO} cp -a config/beets "${OUT_DIR}/${DESTDIR}/share/${PKG}/beets"
${SUDO} cp -a beets "${OUT_DIR}/${DESTDIR}/share/${PKG}/beets/plugins"
${SUDO} cp config/calliope/* "${OUT_DIR}/${DESTDIR}/share/${PKG}/calliope"
${SUDO} cp -a config/kitty "${OUT_DIR}/${DESTDIR}/share/${PKG}/kitty"
${SUDO} cp -a config/mopidy "${OUT_DIR}/${DESTDIR}/share/${PKG}/mopidy"
${SUDO} cp -a config/mpd "${OUT_DIR}/${DESTDIR}/share/${PKG}/mpd"
${SUDO} cp -a config/mppcava "${OUT_DIR}/${DESTDIR}/share/${PKG}/mppcava"
${SUDO} cp -a config/navidrome "${OUT_DIR}/${DESTDIR}/share/${PKG}/navidrome"
${SUDO} cp -a config/ncmpcpp "${OUT_DIR}/${DESTDIR}/share/${PKG}/ncmpcpp"
${SUDO} cp -a config/pipewire "${OUT_DIR}/${DESTDIR}/share/${PKG}/pipewire"
${SUDO} cp -a config/tmuxp ${OUT_DIR}/${DESTDIR}/share/${PKG}/tmuxp
${SUDO} cp -a config/ueberzug ${OUT_DIR}/${DESTDIR}/share/${PKG}/mpcplus/ueberzug
${SUDO} cp -a config/yt-dlp "${OUT_DIR}/${DESTDIR}/share/${PKG}/yt-dlp"
${SUDO} cp -a music "${OUT_DIR}/${DESTDIR}/share/${PKG}/music"
${SUDO} cp -a man/man1 ${OUT_DIR}/${DESTDIR}/share/man/man1
${SUDO} cp -a man/man5 ${OUT_DIR}/${DESTDIR}/share/man/man5
${SUDO} cp -a share/menu "${OUT_DIR}/${DESTDIR}/share/menu"
[ -f .gitignore ] && {
while read ignore
do
${SUDO} rm -f ${OUT_DIR}/${DESTDIR}/${ignore}
done < .gitignore
}
${SUDO} chmod 644 ${OUT_DIR}/${DESTDIR}/share/man/*/*
${SUDO} chmod 644 ${OUT_DIR}/${DESTDIR}/share/menu/*
${SUDO} chmod 755 ${OUT_DIR}/${DESTDIR}/bin/* \
${OUT_DIR}/${DESTDIR}/bin \
${OUT_DIR}/${DESTDIR}/share/man \
${OUT_DIR}/${DESTDIR}/share/man/* \
${OUT_DIR}/${DESTDIR}/share/${PKG}/scripts/*
${SUDO} chown -R root:root ${OUT_DIR}/${DESTDIR}
cd dist
echo "Building ${PKG_NAME}_${PKG_VER} Debian 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} 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} 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}
}
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}
}
if [ "${arch}" ]; then
echo "Invoking scripts/mkaur.sh to create Arch Linux installation package"
sudo pacman -Syy
scripts/mkaur.sh sync
exit 0
else
# Build Arch package if makepkg is installed even if not on Arch
have_arch=$(type -p makepkg)
[ "${have_arch}" ] && {
echo "Invoking scripts/mkaur.sh to create Arch Linux installation package"
scripts/mkaur.sh
}
fi