sudo aptitude install build-essential dh-make mingw32 alien wine qt4-dev-tools I could forget to add some packages here, but you will learn about their shortage when executing the script. You can do without qt4-dev-tools by specifying the path to your qmake and qt libraries from Qt-Sdk downloaded from the site in PATH and LD_LIBRARY_PATH Nokia.We also need to download and install the Nullsoft Scriptable Install System under wine, we will need it to create installation packages for Windows. After installing NSIS, we will need a little tune-up.export PATH = ~ / qtsdk-2010.01 / qt / bin /: $ PATHexport LD_LIBRARY_PATH = ~ / qtsdk-2010.01 / qt / lib /: $ LD_LIBRARY_PATH
Add the Environment key to the HKEY_CURRENT_USER key, in which we will create two string values:wine regedit
$ QT_SDK_INSTALL_DIR / qt / mkspecs.Copy win32-g ++ to the directory with our project, renaming it to win32-x-g ++. Next, we will edit qmake.conf, replacing the mingw32 calls, the Windows commands with the Linux commands. In essence, we should have a file with the following contents:
<pre>
#
# qmake configuration for win32-g ++
#
# Written for MinGW
#
MAKEFILE_GENERATOR = MINGW
TEMPLATE = app
CONFIG + = qt warn_on release link_prl copy_dir_files debug_and_release debug_and_release_target precompile_header
QT + = core gui
DEFINES + = UNICODE QT_LARGEFILE_SUPPORT
QMAKE_COMPILER_DEFINES + = __GNUC__ WIN32
QMAKE_EXT_OBJ = .o
QMAKE_EXT_RES = _res.o
QMAKE_CC = gcc
QMAKE_LEX = flex
QMAKE_LEXFLAGS =
QMAKE_YACC = byacc
QMAKE_YACCFLAGS = -d
QMAKE_CFLAGS =
QMAKE_CFLAGS_DEPS = -M
QMAKE_CFLAGS_WARN_ON = -Wall
QMAKE_CFLAGS_WARN_OFF = -w
QMAKE_CFLAGS_RELEASE = -O2
QMAKE_CFLAGS_DEBUG = -g
QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses
QMAKE_CXX = i586-mingw32msvc-g ++
QMAKE_CXXFLAGS = $$ QMAKE_CFLAGS
QMAKE_CXXFLAGS_DEPS = $$ QMAKE_CFLAGS_DEPS
QMAKE_CXXFLAGS_WARN_ON = $$ QMAKE_CFLAGS_WARN_ON
QMAKE_CXXFLAGS_WARN_OFF = $$ QMAKE_CFLAGS_WARN_OFF
QMAKE_CXXFLAGS_RELEASE = $$ QMAKE_CFLAGS_RELEASE
QMAKE_CXXFLAGS_DEBUG = $$ QMAKE_CFLAGS_DEBUG
QMAKE_CXXFLAGS_YACC = $$ QMAKE_CFLAGS_YACC
QMAKE_CXXFLAGS_THREAD = $$ QMAKE_CFLAGS_THREAD
QMAKE_CXXFLAGS_RTTI_ON = -frtti
QMAKE_CXXFLAGS_RTTI_OFF = -fno-rtti
QMAKE_CXXFLAGS_EXCEPTIONS_ON = -fexceptions -mthreads
QMAKE_CXXFLAGS_EXCEPTIONS_OFF = -fno-exceptions
QMAKE_INCDIR =
QMAKE_INCDIR_QT = $$ [QT_WIN_INCLUDE_PATH]
QMAKE_LIBDIR_QT = $$ [QT_WIN_LIB_PATH]
QMAKE_RUN_CC = $ (CC) -c $ (CFLAGS) $ (INCPATH) -o $ obj $ src
QMAKE_RUN_CC_IMP = $ (CC) -c $ (CFLAGS) $ (INCPATH) -o $ @ $ <
QMAKE_RUN_CXX = $ (CXX) -c $ (CXXFLAGS) $ (INCPATH) -o $ obj $ src
QMAKE_RUN_CXX_IMP = $ (CXX) -c $ (CXXFLAGS) $ (INCPATH) -o $ @ $ <
QMAKE_LINK = i586-mingw32msvc-g ++
QMAKE_LINK_C = gcc
QMAKE_LFLAGS = -mthreads -Wl, -enable-stdcall-fixup -Wl, -enable-auto-import \
-Wl, -enable-runtime-pseudo-reloc -mwindows
QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads -Wl
QMAKE_LFLAGS_EXCEPTIONS_OFF =
QMAKE_LFLAGS_RELEASE = -Wl, -s
QMAKE_LFLAGS_DEBUG =
QMAKE_LFLAGS_CONSOLE = -Wl, -subsystem, console
QMAKE_LFLAGS_WINDOWS = -Wl, -subsystem, windows
QMAKE_LFLAGS_DLL = -shared
QMAKE_LINK_OBJECT_MAX = 10
QMAKE_LINK_OBJECT_SCRIPT = object_script
QMAKE_LIBS =
QMAKE_LIBS_CORE = -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lws2_32
QMAKE_LIBS_GUI = -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lws2_32 -lole32 -luuid -luser32 -ladvapi32
QMAKE_LIBS_NETWORK = -lws2_32
QMAKE_LIBS_OPENGL = -lopengl32 -lglu32 -lgdi32 -luser32
QMAKE_LIBS_COMPAT = -ladvapi32 -lshell32 -lcomdlg32 -luser32 -lgdi32 -lws2_32
QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqtmain
! isEmpty (QMAKE_SH) {
MINGW_IN_SHELL = 1
QMAKE_DIR_SEP = /
QMAKE_COPY = cp
QMAKE_COPY_DIR = xcopy / s / q / y / i
QMAKE_MOVE = mv
QMAKE_DEL_FILE = rm
QMAKE_MKDIR = mkdir
QMAKE_DEL_DIR = rmdir
QMAKE_CHK_DIR_EXISTS = test -d
} else {
QMAKE_COPY = copy / y
QMAKE_COPY_DIR = xcopy / s / q / y / i
QMAKE_MOVE = move
QMAKE_DEL_FILE = del
QMAKE_MKDIR = mkdir
QMAKE_DEL_DIR = rmdir
QMAKE_CHK_DIR_EXISTS = if not exist
}
QMAKE_MOC = $$ [QT_INSTALL_BINS] $$ {DIR_SEPARATOR} moc
QMAKE_UIC = $$ [QT_INSTALL_BINS] $$ {DIR_SEPARATOR} uic
QMAKE_IDC = $$ [QT_INSTALL_BINS] $$ {DIR_SEPARATOR} idc
QMAKE_IDL = midl
QMAKE_LIB = ar -ru
QMAKE_RC = i586-mingw32msvc-windres
QMAKE_ZIP = zip -r -9
QMAKE_STRIP = i586-mingw32msvc-strip
QMAKE_STRIPFLAGS_LIB + = --strip-unneeded
load (qt_config) More information about cross compilation can be found here . Edit the project file (.pro). These additions in the file are needed for the install option to appear in the Makefile generated by qmake. <pre>
unix {
# VARIABLES
isEmpty (PREFIX): PREFIX = / usr / local #PREFIX is the installation path
BINDIR = $$ PREFIX / bin # path to binaries
DATADIR = $$ PREFIX / share # path to the various components of the application that you can refuse
DEFINES + = DATADIR = \ "$$ DATADIR \" \
PKGDATADIR = \ "$$ PKGDATADIR \"
# MAKE INSTALL
INSTALLS + = target \
desktop \
pixmaps \
icon22 \
templates1 \
templates2 \
pagetemplates # leaving only target in INSTALLS, you can also add the installation of libraries in the necessary directories by analogy
target.path = $$ BINDIR
desktop.path = $$ DATADIR / applications /
desktop.files + = $$ {TARGET} .desktop
pixmaps.path = $$ DATADIR / pixmaps /
pixmaps.files + = images / $$ {TARGET} .png
icon22.path = $$ DATADIR / icons / hicolor / 22x22 / apps /
icon22.files + = images / $$ {TARGET} .png
templates1.path = $$ DATADIR / yourownnewsmaker / templates / default /
templates1.files = templates / default /*.*
templates2.path = $$ DATADIR / yourownnewsmaker / templates / eeex-sony-pdf /
templates2.files = templates / eeex-sony-pdf /*.*
pagetemplates.path = $$ DATADIR / yourownnewsmaker / page-templates /
pagetemplates.files = page-templates /*.*
}
If we want our application in Windows to have its own icon, then we need to add the following lines to the project file:And create a file icons.rc with the following contentwin32: RC_FILE = icons.rc
Build deb packages. The control and changelog files are very standard and I think they don’t need to be described again. You can see examples of my files by downloading an archive with scripts. I draw your attention to the fact that tabulation is not used in all scripts. This is very important for NSIS and for dh_make.Rules we had to be completely replaced, but as a result we get a very universal file, in which we need to specify only APPNAME.IDI_ICON1 ICON DISCARDABLE "path / to / your / your icon.ico"
Changelog - below is an example, note that the file does not use tabulation.<pre> #! / usr / bin / make -f APPNAME: = yourownnewsmaker builddir: mkdir -p builddir builddir / Makefile: builddir cd builddir && qmake-qt4 PREFIX = / usr ../$(APPNAME).pro -spec linux-g ++ -r build: build-stamp build-stamp: builddir / Makefile dh_testdir # Add commands to compile the package. cd builddir && $ (MAKE) touch $ @ clean: dh_testdir dh_testroot rm -f build-stamp # Add here commands to clean up after the build process. rm -rf builddir dh_clean install: build dh_testdir dh_testroot dh_clean -k dh_installdirs # Add here commands to install the package into debian / your_appname #cd builddir && $ (MAKE) install cd builddir && $ (MAKE) INSTALL_ROOT = $ (CURDIR) / debian / $ (APPNAME) install #cd builddir && $ (MAKE) install binary-indep: build install binary-arch: build install dh_testdir dh_testroot dh_installdocs dh_installexamples dh_installman dh_link dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install configurege
Here you can read a little more about creating deb packages from qt projects. NSIS script for Windows. I wrote this script based on examples and it does not contain anything superfluous, just showing the license, choosing the path for the installation and installing the application itself. You only need to change the paths in the script for your own. Script content:<pre> yourownnewsmaker (1.3) karmic; urgency = low * Added new template for sony e-readers; * Added new file pdf-print.properties in templates; * Fixed installer for windows; - Valery Konchin <eeexception@gmail.com> Mon, 1 Mar 2010 00:00:00 +0300
<pre>
; Turn off old selected section
; 12 06 2005: Luis Wong
; Template voor het genereren van een installer.
; speciaal voor het genereren van EasyPlayer installers.
; Trimedia Interactive Projects
; -------------------------------
; Start
! define MUI_PRODUCT "yourownnewsmaker"
! define MUI_FILE "yourownnewsmaker"
! define MUI_VERSION "1.3"
! define MUI_BRANDINGTEXT "Your Own New Maker Ver. $ {MUI_VERSION}"
CRCCheck On
; Bij deze moeten we waarschijnlijk een absoluut pad gaan gebruiken
; dit moet effe uitgetest worden.
! include "$ {NSISDIR} \ Contrib \ Modern UI \ System.nsh"
; --------------------------------
; General
Name "$ {MUI_BRANDINGTEXT}"
OutFile "../yourownnewsmaker-install-v.${MUI_VERSION}.exe"
ShowInstDetails "nevershow"
ShowUninstDetails "nevershow"
; SetCompressor "bzip2"
! define MUI_ICON "images / yourownnewsmaker.ico"
! define MUI_UNICON "images / yourownnewsmaker.ico"
;! define MUI_SPECIALBITMAP "Bitmap.bmp"
; Request application privileges for Windows Vista
RequestExecutionLevel user
; --------------------------------
; Folder selection page
InstallDir "$ PROGRAMFILES \ $ {MUI_PRODUCT}"
; --------------------------------
; Modern UI Configuration
! define MUI_WELCOMEPAGE
! define MUI_LICENSEPAGE
! define MUI_DIRECTORYPAGE
! define MUI_ABORTWARNING
! define MUI_UNINSTALLER
! define MUI_UNCONFIRMPAGE
! define MUI_FINISHPAGE
; --------------------------------
; Pages
! insertmacro MUI_PAGE_WELCOME
! insertmacro MUI_PAGE_LICENSE "license"
! insertmacro MUI_PAGE_COMPONENTS
! insertmacro MUI_PAGE_DIRECTORY
! insertmacro MUI_PAGE_INSTFILES
! insertmacro MUI_PAGE_FINISH
! insertmacro MUI_UNPAGE_WELCOME
! insertmacro MUI_UNPAGE_CONFIRM
! insertmacro MUI_UNPAGE_INSTFILES
! insertmacro MUI_UNPAGE_FINISH
; --------------------------------
; Language
! insertmacro MUI_LANGUAGE "English"
; --------------------------------
; Modern UI System
;! insertmacro MUI_SYSTEM
! include "MUI2.nsh"
; --------------------------------
; Data
LicenseData "license"
; --------------------------------
; Installer Sections
Section "Your Own News Maker (required)"
; Add files
SetOutPath "$ INSTDIR"
File "$ {MUI_FILE} .exe"
File "* .dll"
File "license"
File "changes"
SetOutPath "$ INSTDIR \ page-templates"
file "page-templates \ *. properties"
SetOutPath "$ INSTDIR \ templates \ eeex-sony-pdf"
file "templates \ eeex-sony-pdf \ *. *"
SetOutPath "$ INSTDIR \ templates \ default"
file "templates \ default \ *. *"
; file "templates \ *. html"
; file "page-templates \ *. properties"
; SetOutPath "$ INSTDIR \ data"
; file "data \ *. cst"
; file "data \ errorlog.txt"
; hier komen dan nog de bestanden die in de playlist staan
; SetOutPath "$ INSTDIR"
; file / r mpg
; SetOutPath "$ INSTDIR"
; file / r xtras
; create desktop shortcut
CreateShortCut "$ DESKTOP \ $ {MUI_PRODUCT} .lnk" "$ INSTDIR \ $ {MUI_FILE}. Exe" ""
; create start-menu items
CreateDirectory "$ SMPROGRAMS \ $ {MUI_PRODUCT}"
CreateShortCut "$ SMPROGRAMS \ $ {MUI_PRODUCT} \ Uninstall.lnk" "$ INSTDIR \ Uninstall.exe" "" "$ INSTDIR \ Uninstall.exe" 0
CreateShortCut "$ SMPROGRAMS \ $ {MUI_PRODUCT} \ $ {MUI_PRODUCT} .lnk" "$ INSTDIR \ $ {MUI_FILE} .exe" "" "" $ INSTDIR \ $ {MUI_FILE} .exe "0
; write uninstall information to the registry
WriteRegStr HKLM "Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ $ {MUI_PRODUCT}" "DisplayName" "$ {MUI_PRODUCT} (remove only)"
WriteRegStr HKLM "Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ $ {MUI_PRODUCT}" "UninstallString" "$ INSTDIR \ Uninstall.exe"
WriteUninstaller "$ INSTDIR \ Uninstall.exe"
SectionEnd
; --------------------------------
; Uninstaller Section
Section "Uninstall"
; Delete Files
RMDir / r "$ INSTDIR \ *. *"
; Remove the installation directory
RMDir "$ INSTDIR"
; Delete Start Menu Shortcuts
Delete "$ DESKTOP \ $ {MUI_PRODUCT} .lnk"
Delete "$ SMPROGRAMS \ $ {MUI_PRODUCT} \ *. *"
RmDir "$ SMPROGRAMS \ $ {MUI_PRODUCT}"
; Delete Uninstaller And Unistall Registry Entries
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE \ $ {MUI_PRODUCT}"
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ $ {MUI_PRODUCT}"
SectionEnd
; --------------------------------
; MessageBox Section
; Function that calls a messagebox when installed finished
Function .onInstSuccess
MessageBox MB_OK "You have successfully installed $ {MUI_PRODUCT}. Use the desktop icon to start the program."
FunctionEnd
Function un.onUninstSuccess
MessageBox MB_OK "You have successfully uninstalled $ {MUI_PRODUCT}."
FunctionEnd
; eof
Scripts for automatic assembly. Linux packages: <pre>
#! / bin / sh
#
#
BUILDDATE = $ (date +% F)
MAJORVERSION = `sed '/ ^ \ # / d' version.properties | grep 'major' | tail -n 1 | sed 's /^.*=//; s / ^ [[: space:]] * //; s / [[: space:]] * $ //' `
MINORVERSION = `sed '/ ^ \ # / d' version.properties | grep 'minor' | tail -n 1 | sed 's /^.*=//; s / ^ [[: space:]] * //; s / [[: space:]] * $ //' `
echo "Version: $ MAJORVERSION. $ MINORVERSION"
echo "Build date: $ BUILDDATE"
BASEDIR = "./"
DEPLOYDIR = "deploy / yourownnewsmaker- $ MAJORVERSION. $ MINORVERSION"
PLATFORMDIR = "linux"
BUILDNAME = "yourownnewsmaker- $ MAJORVERSION. $ MINORVERSION"
RELEASEDIR = "$ DEPLOYDIR / $ PLATFORMDIR / $ BUILDNAME"
echo "Build dir: $ RELEASEDIR"
rm -rf $ DEPLOYDIR / $ PLATFORMDIR /
mkdir -p "$ DEPLOYDIR / $ PLATFORMDIR"
svn export ./ $ RELEASEDIR
cd $ RELEASEDIR
sed -i "s /% test-major-version% / $ MAJORVERSION / g" version.cpp
sed -i "s /% test-minor-version% / $ MINORVERSION / g" version.cpp
sed -i "s /% test-date% / $ BUILDDATE / g" version.cpp
rm -rf * .rc
rm -rf build-libs
rm -rf win32-x-g ++
rm -rf linux-g ++ - qt4.5
rm -rf * .user
rm -rf * .sh
rm -rf makefile
rm -rf * .properties
rm -rf * .nsi
rm -rf help
mkdir src
mv * .cpp src
mv * .h src
mv * .ui src
mv yourownnewsmaker.pro src / src.pro
mv * .qrc src
mv images src
mv page-templates src
mv templates src
mv yourownnewsmaker.desktop src
mv changes src
mv license src
touch yourownnewsmaker.pro
echo "QMAKEVERSION = $$ [QMAKE_VERSION]" >> yourownnewsmaker.pro
echo "ISQT4 = $$ find (QMAKEVERSION, ^ [2-9])" >> yourownnewsmaker.pro
echo "isEmpty (ISQT4) {" >> yourownnewsmaker.pro
echo "error (\" Use the qmake include with Qt4.4 or greater, on Debian that is qmake-qt4 \ ");" >> yourownnewsmaker.pro
echo "}" >> yourownnewsmaker.pro
echo "" >> yourownnewsmaker.pro
echo "TEMPLATE = subdirs" >> yourownnewsmaker.pro
echo "SUBDIRS = src" >> yourownnewsmaker.pro
export DEBFULLNAME = "Valery Konchin"
dh_make -e eeexception@gmail.com --createorig --single -c gpl
mkdir debian
mv rules debian / rules
mv control debian / control
mv changelog debian / changelog
sed -i "s / <url: \ / \ / example.com> / http: \ / \ / eeexception.org/g" debian / copyright
sed -i "s / <put> here> / Valery Konchin <eeexception@gmail.com> / g" debian / copyright
sed -i "s / <likewise for another author> // g" debian / copyright
sed -i "s / Copyright (C) YYYY Firstname Lastname / Copyright (C) 2010 Valery Konchin / g" debian / copyright
dpkg-buildpackage
rm -rf debian
rm -rf builddir
cd ../
tar -pczf $ BUILDNAME.tar.gz $ BUILDNAME
rm -rf $ BUILDNAME
Windows packages:Part 3. Check the results. As a result of the execution of the scripts, we will receive in the deploy / deb, rpm directory, an archive with source codes, as well as an archive with binaries and an installation package for Windows, which in my opinion is quite enough for most users. Packages generated in this way by deb and rpm may not be ideal for inclusion in the repository, but they successfully install and update the application in the system. Ideally, the scripts do not have enough validation of the installation, as well as the performance of the applications themselves. But for this you need to use some system for GUI testing, in search of which I am now. PS In connection with the article size limit, I completely lay out the scripts Also, I recommend to download them, as the site's parser could swallow some characters. http://dl.dropbox.com/u/930431/project-build-scripts.tar.gz .<pre> #! / bin / sh # # BUILDDATE = $ (date +% F) MAJORVERSION = `sed '/ ^ \ # / d' version.properties | grep 'major' | tail -n 1 | sed 's /^.*=//; s / ^ [[: space:]] * //; s / [[: space:]] * $ //' ` MINORVERSION = `sed '/ ^ \ # / d' version.properties | grep 'minor' | tail -n 1 | sed 's /^.*=//; s / ^ [[: space:]] * //; s / [[: space:]] * $ //' ` echo "Version: $ MAJORVERSION. $ MINORVERSION" echo "Build date: $ BUILDDATE" BASEDIR = "./" DEPLOYDIR = "deploy / yourownnewsmaker- $ MAJORVERSION. $ MINORVERSION" PLATFORMDIR = "windows" BUILDNAME = "yourownnewsmaker- $ MAJORVERSION. $ MINORVERSION" RELEASEDIR = "$ DEPLOYDIR / $ PLATFORMDIR / $ BUILDNAME" echo "Build dir: $ RELEASEDIR" rm -rf $ DEPLOYDIR / $ PLATFORMDIR / mkdir -p "$ DEPLOYDIR / $ PLATFORMDIR" svn export ./ $ RELEASEDIR cd $ RELEASEDIR sed -i "s /% test-major-version% / $ MAJORVERSION / g" version.cpp sed -i "s /% test-minor-version% / $ MINORVERSION / g" version.cpp sed -i "s /% test-date% / $ BUILDDATE / g" version.cpp # set the necessary paths QT_WIN_INSTALL_DIR = / home / exception / Development / qt-4.6.1-win QT_LIN_INSTALL_DIR = / home / exception / Development / qtsdk-2010.01 / qt export LD_LIBRARY_PATH = $ QT_LIN_INSTALL_DIR / lib: $ LD_LIBRARY_PATH export PATH = $ QT_LIN_INSTALL_DIR / bin: $ PATH export QT_LINUX_BIN_PATH = $ QT_LIN_INSTALL_DIR / bin export QT_WIN_INCLUDE_PATH = $ QT_WIN_INSTALL_DIR / include export QT_WIN_LIB_PATH = $ QT_WIN_INSTALL_DIR / lib qmake -set QT_WIN_INCLUDE_PATH $ QT_WIN_INCLUDE_PATH qmake -set QT_WIN_LIB_PATH $ QT_WIN_LIB_PATH # This is what qmake starts with cross-compiling qmake yourownnewsmaker.pro -spec win32-x-g ++ -r make cp -rf build-libs / win / *. dll ./ cp -rf release / *. exe ./ rm -rf images / *. png rm -rf * .rc rm -rf * .res rm -rf build-libs rm -rf win32-x-g ++ rm -rf linux-g ++ - qt4.5 rm -rf * .user rm -rf * .sh rm -rf makefile rm -rf * .properties rm -rf release rm -rf debug rm -rf * .desktop rm -rf makefile. * rm -rf * .Debug rm -rf * .Release rm -rf control rm -rf changelog rm -rf rules rm -rf help rm -rf * .qrc rm -rf * .cpp rm -rf * .h rm -rf * .ui rm -rf * .pro # With these commands, we replace line breaks with Windows sed -i s / $ / '\ r' / templates / default /*.* sed -i s / $ / '\ r' / templates / eeex-sony-pdf /*.* sed -i s / $ / '\ r' / page-templates / *. properties sed -i s / $ / '\ r' / license sed -i s / $ / '\ r' / changes wine makensis.exe win.nsi rm -rf * .nsi cd ../ zip -r $ BUILDNAME.zip $ BUILDNAME
Source: https://habr.com/ru/post/86432/
All Articles