2017-04-12 01:16:46 +00:00
|
|
|
#!/bin/bash
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
echo "Usage: mkpkg directory_name"
|
|
|
|
else
|
|
|
|
DIR="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")/${@}"
|
|
|
|
TMPDIR=/tmp/tmp.$(( $RANDOM * 19318203981230 + 40 ))
|
|
|
|
PLUGIN=$(basename ${DIR})
|
|
|
|
ARCHIVE="$(dirname $(dirname ${DIR}))/archive"
|
|
|
|
DESTDIR="$TMPDIR/usr/local/emhttp/plugins/${PLUGIN}"
|
2017-06-16 20:38:57 +00:00
|
|
|
PLG_FILE="$(dirname $(dirname ${DIR}))/plugin/${PLUGIN}.plg"
|
2017-04-12 01:16:46 +00:00
|
|
|
VERSION=$(date +"%Y.%m.%d")
|
|
|
|
ARCH="-x86_64-1"
|
|
|
|
PACKAGE="${ARCHIVE}/${PLUGIN}-${VERSION}${ARCH}.txz"
|
|
|
|
MD5="${ARCHIVE}/${PLUGIN}-${VERSION}${ARCH}.md5"
|
|
|
|
|
|
|
|
|
|
|
|
for x in '' a b c d e d f g h ; do
|
|
|
|
PKG="${ARCHIVE}/${PLUGIN}-${VERSION}${x}${ARCH}.txz"
|
|
|
|
if [[ ! -f $PKG ]]; then
|
|
|
|
PACKAGE=$PKG
|
|
|
|
VERSION="${VERSION}${x}"
|
|
|
|
MD5="${ARCHIVE}/${PLUGIN}-${VERSION}${ARCH}.md5"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
sed -i -e "s#\(ENTITY\s*version[^\"]*\).*#\1\"${VERSION}\">#" "$PLG_FILE"
|
2018-01-13 07:43:39 +00:00
|
|
|
sed -i "/##&name/a\###${VERSION}" "$PLG_FILE"
|
2017-04-12 01:16:46 +00:00
|
|
|
|
|
|
|
mkdir -p "${TMPDIR}/"
|
|
|
|
cd "$DIR"
|
|
|
|
cp --parents -f $(find . -type f ! \( -iname "pkg_build.sh" -o -iname "sftp-config.json" -o -iname ".DS_Store" \) ) "${TMPDIR}/"
|
|
|
|
cd "$TMPDIR/"
|
|
|
|
makepkg -l y -c y "${PACKAGE}"
|
|
|
|
cd "$ARCHIVE/"
|
|
|
|
md5sum $(basename "$PACKAGE") > "$MD5"
|
|
|
|
rm -rf "$TMPDIR"
|
|
|
|
|
|
|
|
# Verify and install plugin package
|
|
|
|
sum1=$(md5sum "${PACKAGE}")
|
|
|
|
sum2=$(cat "$MD5")
|
|
|
|
if [ "${sum1:0:32}" != "${sum2:0:32}" ]; then
|
|
|
|
echo "Checksum mismatched.";
|
|
|
|
rm "$MD5" "${PACKAGE}"
|
|
|
|
else
|
|
|
|
echo "Checksum matched."
|
|
|
|
fi
|
|
|
|
fi
|