Skip to content

Commit

Permalink
Fix #95541: Portable build for Linux (AppImage)
Browse files Browse the repository at this point in the history
- Set share path relative to executable on Linux too
- Linux dependencies for portable AppImage
- Helper scripts for desktop integration
- Update man pages
  • Loading branch information
shoogle committed Feb 17, 2016
1 parent 2c7e5f2 commit 767a95a
Show file tree
Hide file tree
Showing 14 changed files with 1,072 additions and 162 deletions.
34 changes: 29 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -441,16 +441,40 @@ if (NOT MINGW AND NOT APPLE)
# qt libraries as we used at compile time
#
SET(CMAKE_INSTALL_RPATH "${_qt5Core_install_prefix}/lib") # ignored if CMAKE_SKIP_RPATH="TRUE"
string(TOUPPER "mscore${MSCORE_INSTALL_SUFFIX}" MAN_MSCORE_UPPER) # Command name shown in uppercase in man pages by convention
if (${MSCORE_INSTALL_SUFFIX} MATCHES "portable") # Note: "-portable-anything" would match
# Build portable AppImage as per https://github.com/probonopd/AppImageKit
execute_process(COMMAND arch OUTPUT_VARIABLE ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)# get architecture (strip trailing newline)
get_filename_component(PORTABLE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} PATH)# get path (dirname)
get_filename_component(PORTABLE_INSTALL_NAME ${CMAKE_INSTALL_PREFIX} NAME)# strip path (basename)
if (NOT MSCORE_UNSTABLE)
set(PORTABLE_INSTALL_NAME "${PORTABLE_INSTALL_NAME}-${MUSESCORE_VERSION_FULL}") # append version info.
endif (NOT MSCORE_UNSTABLE)
set(PORTABLE_INSTALL_NAME "${PORTABLE_INSTALL_NAME}-${ARCH}") # append system architecture.
set(CMAKE_INSTALL_PREFIX ${PORTABLE_INSTALL_PATH}/${PORTABLE_INSTALL_NAME}.AppDir) # e.g. "MuseScore-X.Y.Z-x86_64.AppDir"
execute_process(COMMAND echo ${CMAKE_INSTALL_PREFIX} OUTPUT_FILE PREFIX.txt)
# Prepare portable scripts:
configure_file(build/Linux+BSD/portable/AppRun.in AppRun @ONLY)
configure_file(build/Linux+BSD/portable/portable-utils.in portable-utils @ONLY)
set(SCRIPT_PERMS PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ WORLD_READ)
install(PROGRAMS ${PROJECT_BINARY_DIR}/AppRun DESTINATION . COMPONENT portable ${SCRIPT_PERMS})
install(PROGRAMS ${PROJECT_BINARY_DIR}/portable-utils
build/Linux+BSD/portable/ldd-recursive
build/rm-empty-dirs DESTINATION bin COMPONENT portable ${SCRIPT_PERMS})
install(FILES build/Linux+BSD/portable/qt.conf DESTINATION bin COMPONENT portable)
else (${MSCORE_INSTALL_SUFFIX} MATCHES "portable")
set(MAN_PORTABLE '.\"') # comment out lines in man page that are only relevent to the portable version
endif (${MSCORE_INSTALL_SUFFIX} MATCHES "portable")
# install desktop file (perform variable substitution first)
configure_file(build/mscore.desktop.in mscore${MSCORE_INSTALL_SUFFIX}.desktop)
configure_file(build/Linux+BSD/mscore.desktop.in mscore${MSCORE_INSTALL_SUFFIX}.desktop)
install( FILES ${PROJECT_BINARY_DIR}/mscore${MSCORE_INSTALL_SUFFIX}.desktop DESTINATION share/applications)
# substitute variables within man pages
set(MAN_NAME mscore)
set(MAN_ALIAS musescore)
set(MAN_EXTENSION .1)
set(MAN_FULL_NAME ${MAN_NAME}${MSCORE_INSTALL_SUFFIX}${MAN_EXTENSION})
set(MAN_FULL_ALIAS ${MAN_ALIAS}${MSCORE_INSTALL_SUFFIX}${MAN_EXTENSION})
set(MAN_TARGET ${PROJECT_SOURCE_DIR}/build/${MAN_NAME}${MAN_EXTENSION}.in)
set(MAN_TARGET ${PROJECT_SOURCE_DIR}/build/Linux+BSD/${MAN_NAME}${MAN_EXTENSION}.in)
set(MAN_BUILD ${PROJECT_BINARY_DIR}/${MAN_FULL_NAME})
configure_file(${MAN_TARGET} ${MAN_BUILD})
# compress man pages if gzip is installed (don't on OpenBSD)
Expand All @@ -468,7 +492,7 @@ if (NOT MINGW AND NOT APPLE)
DEPENDS ${MAN_TARGET}
COMMAND ${GZIP_EXECUTABLE} -9 < ${MAN_TARGET} > ${MAN_BUILD}
)
add_custom_target(manpages
add_custom_target(manpages ALL
DEPENDS ${MAN_BUILD}
COMMAND echo "Man pages have been compressed ready for installation."
VERBATIM
Expand All @@ -479,7 +503,7 @@ if (NOT MINGW AND NOT APPLE)
else (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
message(STATUS "gzip not found (it is optional). Man pages will not be compressed.")
endif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
add_custom_target(manpages
add_custom_target(manpages ALL
COMMAND echo "Man pages will be installed uncompressed."
VERBATIM
)
Expand All @@ -501,7 +525,7 @@ if (NOT MINGW AND NOT APPLE)
message(STATUS "ln not found (it is optional). No symlink aliases will be created.")
endif (LN_EXECUTABLE)
# add .MSCZ and .MSCX to MIME database (informs system that filetypes .MSCZ & .MSCX are MuseScore files)
configure_file(build/musescore.xml.in musescore${MSCORE_INSTALL_SUFFIX}.xml)
configure_file(build/Linux+BSD/musescore.xml.in musescore${MSCORE_INSTALL_SUFFIX}.xml)
install( FILES ${PROJECT_BINARY_DIR}/musescore${MSCORE_INSTALL_SUFFIX}.xml DESTINATION share/mime/packages COMPONENT doc)
# Note: must now run "update-mime-database" to apply changes. This is done in the Makefile.
endif (NOT MINGW AND NOT APPLE)
Expand Down
31 changes: 26 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ release:
-DBUILD_LAME="${BUILD_LAME}" \
-DCMAKE_SKIP_RPATH="${NO_RPATH}" ..; \
make lrelease; \
make manpages; \
make mscore_alias; \
make -j ${CPUS}; \


Expand All @@ -76,11 +74,8 @@ debug:
-DBUILD_LAME="${BUILD_LAME}" \
-DCMAKE_SKIP_RPATH="${NO_RPATH}" ..; \
make lrelease; \
make manpages; \
make mscore_alias; \
make -j ${CPUS}; \


#
# win32
# cross compile windows package
Expand Down Expand Up @@ -127,6 +122,32 @@ install: release
gtk-update-icon-cache -f -t "${PREFIX}/share/icons/hicolor"; \
fi

# Portable target: build AppDir ready to be turned into a portable AppImage.
# Creating the AppImage requires https://github.com/probonopd/AppImageKit
# Portable target requires both build and runtime dependencies,
# if Qt is in a non-standard location then be sure to add its
# "bin" folder to PATH and "lib" folder to LD_LIBRARY_PATH. i.e.:
# $ export $PATH="/path/to/Qt/bin:${PATH}"
# $ export $LD_LIBRARY_PATH="/path/to/Qt/lib:${LD_LIBRARY_PATH}"
# $ make portable
# PREFIX sets install location *and* the name of the resulting AppDir.
# Version is appended to PREFIX in CMakeLists.txt if MSCORE_UNSTABLE=FALSE.
portable: PREFIX=MuseScore
portable: SUFFIX=-portable
portable: LABEL=Portable AppImage
portable: NO_RPATH=TRUE
portable: UPDATE_CACHE=FALSE
portable: install
build_dir="$$(pwd)/build.release" && cd "$$(cat $${build_dir}/PREFIX.txt)" \
&& [ -L usr ] || ln -s . usr && mscore="mscore${SUFFIX}" \
&& dsktp="$${mscore}.desktop" icon="$${mscore}.svg" mani="install_manifest.txt" \
&& cp "share/applications/$${dsktp}" "$${dsktp}" \
&& cp "share/icons/hicolor/scalable/apps/$${icon}" "$${icon}" \
&& <"$${build_dir}/$${mani}" >"$${mani}" \
sed -rn 's/.*(share\/)(man|mime|icons|applications)(.*)/\1\2\3/p' \
&& "$${build_dir}/../build/Linux+BSD/portable/copy-libs" . \
; ./AppRun check-depends | tee "$${build_dir}/dependencies.txt"

installdebug: debug
cd build.debug \
&& make install \
Expand Down
243 changes: 243 additions & 0 deletions build/Linux+BSD/mscore.1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
.\" Hey, EMACS: -*- nroff -*-
.\" To preview the page formatting without installing use "man -l mscore.1"
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH @MAN_MSCORE_UPPER@ 1 "14th January 2016" https://musescore.org/ "MuseScore User Commands"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh disable hyphenation
.\" .hy enable hyphenation
.\" .ad l left justify
.\" .ad b justify to both left and right margins
.\" .nf disable filling
.\" .fi enable filling
.\" .br insert line break
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
.\" respectively.
.SH NAME@Variables_substituted_by_CMAKE_on_installation@
mscore@MSCORE_INSTALL_SUFFIX@, musescore@MSCORE_INSTALL_SUFFIX@ \- @MUSESCORE_NAME_VERSION@ sheet music editor.

.SH SYNOPSIS
@BEGIN_section_to_only_appear_in_portable_builds@
@MAN_PORTABLE@.SS Before installation:
@MAN_PORTABLE@.B @PORTABLE_INSTALL_NAME@.AppImage
@MAN_PORTABLE@.RI [ OPTIONS ]
@MAN_PORTABLE@.RI [ FILE .\|.\|.]

@MAN_PORTABLE@.SS After installation:
@END_section_to_only_appear_in_portable_builds@
.B mscore@MSCORE_INSTALL_SUFFIX@
.RI [ OPTIONS ]
.RI [ FILE .\|.\|.]
.br
.B musescore@MSCORE_INSTALL_SUFFIX@
.RI [ OPTIONS ]
.RI [ FILE .\|.\|.]

.SH DESCRIPTION
MuseScore is a free and open source WYSIWYG program for typesetting
musical scores, released under the GNU General Public Licence (GPLv2).

@BEGIN_section_to_only_appear_in_portable_builds@
@MAN_PORTABLE@.SS Portable version
@MAN_PORTABLE@This portable version of MuseScore has all of MuseScore's usual features,
@MAN_PORTABLE@but it runs on a wider range of distributions and does not need to be
@MAN_PORTABLE@installed. There is an option to install it if full integration with other
@MAN_PORTABLE@applications and the desktop environment is desired.
@END_section_to_only_appear_in_portable_builds@

.SS Getting help
This manual documents command line useage of
.BR mscore .
For help with the full MuseScore program see:
.RS
.TP
.B Online Handbook
<https://musescore.org/handbook>
.TP
.B Support Forum
<https://musescore.org/forum>
.RE

.SS Further information
.TP
These pages cover the topics in this manual may be more up-to-date:

<https://musescore.org/handbook/command-line-options-0>
<https://musescore.org/handbook/revert-factory-settings-0>

.SH OPTIONS
A summary of options is included below. Running
.B mscore
without options launches the full MuseScore
program and opens any specified files.

@BEGIN_section_to_only_appear_in_portable_builds@
@MAN_PORTABLE@.SS Special options for the portable version
@MAN_PORTABLE@.TP
@MAN_PORTABLE@.B \-h, --help
@MAN_PORTABLE@Lists the various command line options and their usage.
@MAN_PORTABLE@.TP
@MAN_PORTABLE@.B man, manual, manpage
@MAN_PORTABLE@Displays this manual.
@MAN_PORTABLE@If MuseScore is installed the manual can be viewed using the traditional `man
@MAN_PORTABLE@.BR mscore `.
@MAN_PORTABLE@.TP
@MAN_PORTABLE@.B install [-i] [PREFIX]
@MAN_PORTABLE@.RS
@MAN_PORTABLE@Run this without '-i' or 'PREFIX' specified to fully integrate MuseScore
@MAN_PORTABLE@with the desktop environment (GNOME, KDE, etc) just as if it had been
@MAN_PORTABLE@installed using a package manager. This should:
@MAN_PORTABLE@.RS 2
@MAN_PORTABLE@.IP \[bu] 2
@MAN_PORTABLE@Add MuseScore to your Applications Menu or Launcher,
@MAN_PORTABLE@and add it to the "Open with..." list of programs.
@MAN_PORTABLE@.IP \[bu]
@MAN_PORTABLE@Move the executable to put it with your other programs.
@MAN_PORTABLE@(Usually a location within your PATH environment variable.)
@MAN_PORTABLE@.IP \[bu]
@MAN_PORTABLE@Create symlinks to make it easier to launch MuseScore from the
@MAN_PORTABLE@command line when needed.
@MAN_PORTABLE@.IP \[bu]
@MAN_PORTABLE@Make sure MSCZ, MSCX and MusicXML files are recognised
@MAN_PORTABLE@by the system and the correct icons are displayed.
@MAN_PORTABLE@.RE
@MAN_PORTABLE@
@MAN_PORTABLE@Run as root (sudo) to install for all users.
@MAN_PORTABLE@Advanced users can use '-i' to enter interactive mode
@MAN_PORTABLE@and 'PREFIX' to install to a custom location.
@MAN_PORTABLE@Installation not required to run the program.
@MAN_PORTABLE@.RE
@MAN_PORTABLE@
@MAN_PORTABLE@.TP
@MAN_PORTABLE@.B remove, uninstall [PREFIX]
@MAN_PORTABLE@Removes icons and resources,
@MAN_PORTABLE@and asks whether you would like to remove the program too.
@MAN_PORTABLE@(You can delete it yourself later if you wish.)
@MAN_PORTABLE@Scores and personal files are not removed.
@MAN_PORTABLE@If you installed for all users then it will be removed for all users.
@MAN_PORTABLE@
@MAN_PORTABLE@.TP
@MAN_PORTABLE@.B check-depends [exes-only]
@MAN_PORTABLE@System information for developers.
@MAN_PORTABLE@This detects which software libraries needed
@MAN_PORTABLE@by MuseScore are not available from the system
@MAN_PORTABLE@and so must be packaged with MuseScore.
@MAN_PORTABLE@
@MAN_PORTABLE@.SS Normal MuseScore options
@END_section_to_only_appear_in_portable_builds@
.TP
.B \-h, --help
Displays help.
.TP
.B \-v, --version
Displays MuseScore's current version in the command line without starting the graphical interface.
.TP
.B \--long-version
Displays MuseScore's current version and revision in the command line without starting the graphical interface.
.TP
.B \-d, --debug
Starts MuseScore in debug mode.
.TP
.B \-L, --layout-debug
Starts MuseScore in layout debug mode
.TP
.B \-s, --no-synthesizer
Disables the integrated software synthesizer
.TP
.B \-m, --no-midi
Disables MIDI input
.TP
.B \-a, --use-audio <driver>
Use audio driver: jack, alsa, pulse, portaudio
.TP
.B \-n, --new-score
Starts with the new score wizard regardless of preference setting for start mode
.TP
.B \-I, --dump-midi-in
Displays all MIDI input on the console
.TP
.B \-O, --dump-midi-out
Displays all MIDI output on the console
.TP
.B \-o, --export-to <filename>
Exports the currently opened file to the specified <filename>. The file type depends on the filename extension. This option switches to the "converter" mode and avoids any graphical interface. You can also add a filename before the -o if you want to import and export files from the command line. For example mscore -o "My Score.pdf" "My Score.mscz"
.TP
.B \-r, --image-resolution <dpi>
Determines the output resolution for the output to "*.png" files in the converter mode. The default resolution is 300 dpi.
.TP
.B \-T, --trim-margin <margin>
Trims exported PNG and SVG images to remove surrounding whitespace around the score. The specified number of pixels of whitespace will be added as a margin; use 0 for a tightly cropped image. For SVG, this option works only with single-page scores.
.TP
.B \-x, --gui-scaling <factor>
Scales the score display and other GUI elements by the specified factor, for use with high resolution displays.
.TP
.B \-S, --style <style>
Loads a style file; useful when you convert with the \-o option
.TP
.B \-p, --plugin <name>
Execute the named plugin
.TP
.B \--template-mode
Save template mode, no page size
.TP
.B \-F, --factory-settings
Use only the standard built-in presets or "factory-settings" and delete preferences
.TP
.B \-R, --revert-settings
Use only the standard built-in presets or "factory-settings", but do not delete preferences
.TP
.B \-i, --load-icons
Load icons from the file system. Useful if you want to edit the MuseScore icons and preview the changes
.TP
.B \-e, --experimental
Enable experimental features. (E.g. layers).
.TP
.B \-c, --config-folder <pathname>
Set config path
.TP
.B \-t, --test-mode
Enable Test Mode
.TP
.B \-M, --midi-operations <file>
Specify MIDI import operations file
.TP
.B \-w, --no-webview
No web view in Start Center
.TP
.B \-P, --export-score-parts
Used with -o .pdf, export score and parts

.SH FILES
Advanced users can find MuseScore's configuration files at:
.RS
.TP
.I ~/.config/MuseScore/MuseScore2.ini
Main MuseScore preference file.

.TP
.I ~/.local/share/data/MuseScore/MuseScore2/
Directory for all other preferences and session data.
(Autosaves, palettes, locale, plugin data, etc.)
.RE

The information in these files may allow partial recovery of lost work in
some situations, but full recovery is extremely unlikely.
No method of data rescue can match regular, automated backups.

.SH BUGS
.TP
Issue Tracker:

<https://musescore.org/project/issues>

.TP
Please check if the bug has already been reported.

.SH AUTHOR
The MuseScore Team.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions build/Linux+BSD/portable/AppRun.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# TODO: rewrite this file in a faster, more portable language (e.g. C)

# APPDIR and APPIMAGE are environment variables which are set when the user
# runs the AppImage. They won't be set if you try to run this outside of an
# AppImage, so here we set them to something sensible instead for testing.
[ "${APPDIR}" ] || export APPDIR="$(dirname "$(readlink -f "${0}")")"
[ "${APPIMAGE}" ] || export APPIMAGE="${APPDIR}/AppRun"

libs="${APPDIR}/lib"
export LD_LIBRARY_PATH="${libs}:${libs}/qt5/lib:${LD_LIBRARY_PATH}"

case "$1" in
-h|--help|install|uninstall|remove|man|manual|manpage|check-depends )
"${APPDIR}/bin/portable-utils" "$@"
;;
* )
"${APPDIR}/bin/mscore@MSCORE_INSTALL_SUFFIX@" "$@"
;;
esac

exit $?
Loading

0 comments on commit 767a95a

Please sign in to comment.