Skip to content

Commit

Permalink
Added Linux installer
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Serrano Polo committed Jul 23, 2016
1 parent 3a90c73 commit 21ed554
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmake/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,18 @@ INSTALL(FILES lmms.png DESTINATION "${DATA_DIR}/pixmaps")
INSTALL(FILES lmms DESTINATION "${DATA_DIR}/menu")
INSTALL(FILES lmms.desktop DESTINATION "${DATA_DIR}/applications")
INSTALL(FILES lmms.xml DESTINATION "${DATA_DIR}/mime/packages")

CONFIGURE_FILE("build-installer.in" "${CMAKE_BINARY_DIR}/build-installer" @ONLY)

IF(LMMS_HOST_X86)
SET(HOST_ARCH i386-linux-gnu)
ELSEIF(LMMS_HOST_X86_64)
SET(HOST_ARCH x86_64-linux-gnu)
ELSE()
SET(HOST_ARCH unknown-linux-gnu)
ENDIF()
SET(RUN_FILE "${CMAKE_PROJECT_NAME}-${VERSION}-${HOST_ARCH}.run")
ADD_CUSTOM_TARGET(makeself
COMMAND "${CMAKE_BINARY_DIR}/build-installer" "\"${CMAKE_BINARY_DIR}\""
"\"${RUN_FILE}\""
COMMENT "Generating installer")
83 changes: 83 additions & 0 deletions cmake/linux/build-installer.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash
set -e
BINDIR="$1"
RUNFILE="$2"
[ "$BINDIR" -a "$RUNFILE" ]

VERSION=@VERSION@

cd "$BINDIR"
[ -e CMakeCache.txt ]

rm -fr lmms.root
mkdir lmms.root
make install DESTDIR=lmms.root

cd lmms.root
mv usr/local/* usr
rm -r usr/include usr/local

strip usr/bin/lmms usr/lib/lmms/RemoteZynAddSubFx usr/lib/lmms/*.so \
usr/lib/lmms/ladspa/*

# Find required libraries and download the deb files that contain them;
# RemoteVstPlugin.exe.so is not considered
ldd usr/bin/lmms usr/lib/lmms/RemoteZynAddSubFx usr/lib/lmms/lib*.so \
usr/lib/lmms/ladspa/* |
grep = |
cut -d " " -f 3 |
grep -v usr/lib/lmms |
sort -u |
xargs dpkg -S |
cut -d : -f 1 |
sort -u |
xargs aptitude download

# Unpack the downloaded deb files
ls *.deb |
while read DEB
do
dpkg-deb -x $DEB .
done
rm *.deb

mv usr/share/applications/lmms.desktop lmms-$VERSION.desktop
sed -e "
/^Name=/ s/LMMS/LMMS $VERSION/
/^Icon=/ s/lmms/lmms-$VERSION/
" -i lmms-$VERSION.desktop

mv usr/share/pixmaps/lmms.png lmms-$VERSION.png
rmdir --ignore-fail-on-non-empty usr/share/pixmaps

mv usr/share/mime/packages/lmms.xml .

rm -fr lib64 usr/share/applications usr/share/doc usr/share/doc-base \
usr/share/lintian usr/share/man usr/share/menu usr/share/mime

# libc6 is included, so its loader should be used instead of the system one;
# move the loader to usr/bin because of Qt applicationDirPath() usage
MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH)
mv lib/$MULTIARCH/ld-*.so usr/bin/ld.so

cat > launcher << EOF
#!/bin/sh
DIR=\$(dirname \$(readlink -f "\$0"))
export LD_LIBRARY_PATH="\$DIR"/lib/$MULTIARCH:"\$DIR"/usr/lib/$MULTIARCH\
:"\$DIR"/usr/lib/$MULTIARCH/pulseaudio
"\$DIR"/usr/bin/ld.so "\$DIR"/usr/bin/lmms "\$@"
EOF

chmod a+x launcher

cp -a ../../cmake/linux/installer .

cd ..
fakeroot makeself --xz --complevel 6 lmms.root "$RUNFILE" LMMS ./installer \
$VERSION

# Work around feature in makeself to allow system installation
if [ "$(makeself -v)" = "Makeself version 2.2.0" ]
then
sed -e "4 s/umask 077//" -i "$RUNFILE"
fi
41 changes: 41 additions & 0 deletions cmake/linux/installer
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh
set -e
[ "$1" ]

VERSION="$1"

if [ $(id -u) -eq 0 ]
then
DIR=/opt/lmms-$VERSION
PREFIX=/usr
else
DIR="$HOME"/.lmms-$VERSION
PREFIX="$HOME"/.local
fi
echo Installing to $DIR
mkdir -p "$DIR"

rm -fr "$DIR"/etc "$DIR"/lib "$DIR"/usr
mv etc launcher lib usr "$DIR"

sed -e "/^Exec=/ s#lmms#\"$DIR\"/launcher#" -i lmms-$VERSION.desktop

ICONDIR="$PREFIX"/share/icons
mkdir -p "$ICONDIR"
mv lmms-$VERSION.png "$ICONDIR"

MENUDIR="$PREFIX"/share/applications
mkdir -p "$MENUDIR"
mv lmms-$VERSION.desktop "$MENUDIR"

MIMEDIR="$PREFIX"/share/mime/packages
if [ ! \( -e "$MIMEDIR"/lmms.xml -o -e /usr/share/mime/packages/lmms.xml -o \
-e /usr/local/share/mime/packages/lmms.xml \) ]
then
mkdir -p "$MIMEDIR"
mv lmms.xml "$MIMEDIR"
if [ "$(which update-mime-database)" ]
then
update-mime-database "$PREFIX"/share/mime
fi
fi

0 comments on commit 21ed554

Please sign in to comment.