added paper

This commit is contained in:
arcan1s 2014-01-21 00:29:20 +04:00
parent b88b8a9ec1
commit 44c4c5e66e
7 changed files with 538 additions and 18 deletions

View File

@ -8,14 +8,14 @@ short: about-zshrc
description: It is first paper in my blog (I think I need something here for tests =)). There are many similar articles, and I'll not be an exception. I just want to show my <code>.zshrc</code> and explain what it does and why it is needed. Also any comments or additions are welcome. It is a translated paper from Russian (<a href="http://archlinux.org.ru/forum/topic/12752/">original</a>).
commentIssueId: 5
---
<h3><a name="prepare" class="anchor" href="#prepare"><span class="octicon octicon-link"></span></a>Prepare</h2>
<h2><a name="prepare" class="anchor" href="#prepare"><span class="octicon octicon-link"></span></a>Prepare</h2>
<p align="justify">First install recommended minima:</p>
{% highlight bash %}
pacman -Sy pkgfile zsh zsh-completions zsh-syntax-highlighting
{% endhighlight %}
<p align="justify"><a href="https://www.archlinux.org/packages/pkgfile/">pkgfile</a> is a very useful utility. Also this command will install shell, additional completion and syntax highlighting.</p>
<h3><a name="configuration" class="anchor" href="#configuration"><span class="octicon octicon-link"></span></a>Shell configuration</h2>
<h2><a name="configuration" class="anchor" href="#configuration"><span class="octicon octicon-link"></span></a>Shell configuration</h2>
<p align="justify">All options are avaible <a href="http://zsh.sourceforge.net/Doc/Release/Options.html">here</a>.</p>
<p align="justify">Set history file and number of commands in cache of the current session and in the history file:</p>
@ -112,7 +112,7 @@ setopt HIST_REDUCE_BLANKS
source /usr/share/doc/pkgfile/command-not-found.zsh
{% endhighlight %}
<h3><a name="highlighting" class="anchor" href="#highlighting"><span class="octicon octicon-link"></span></a>Syntax highlighting</h2>
<h2><a name="highlighting" class="anchor" href="#highlighting"><span class="octicon octicon-link"></span></a>Syntax highlighting</h2>
{% highlight bash %}
# highlighting
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
@ -161,7 +161,7 @@ ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=yellow'
{% endhighlight %}
<p align="justify">In first line highlighting is turned on. Next main, brackets and pattern highlighting are turned on. Patterns are set below (<code>rm -rf *</code> in the example). Also <code>root</code> and <code>cursor</code> highlighting may be turned on. Colors syntax is understandable, <code>fg</code> is font color, <code>bg</code> is background color.</p>
<h3><a name="prompt" class="anchor" href="#prompt"><span class="octicon octicon-link"></span></a>$PROMPT and $RPROMPT</h2>
<h2><a name="prompt" class="anchor" href="#prompt"><span class="octicon octicon-link"></span></a>$PROMPT and $RPROMPT</h2>
<p align="justify">The general idea is the use single <code>.zshrc</code> for root and normal user:</p>
{% highlight bash %}
# PROMPT && RPROMPT
@ -239,7 +239,7 @@ $returncode\
{% endhighlight %}
<p align="justify">My RPROMPT shows current time, battery change and last returned code. <code>precmd()</code> is necessary for automatic updating. The construct <code>$(if.true.false)</code> is conditional statement in <code>zsh</code>.</p>
<h3><a name="aliases" class="anchor" href="#aliases"><span class="octicon octicon-link"></span></a>Aliases</h2>
<h2><a name="aliases" class="anchor" href="#aliases"><span class="octicon octicon-link"></span></a>Aliases</h2>
<p align="justify"><b>Copy only those aliases that you need.</b> If any alias uses application that is not installed it will leads to fail of loading of configuration file.</p>
<p align="justify">Small useful (or maybe not) function:</p>
@ -327,7 +327,7 @@ alias -g h="| head"
alias -g dn="&> /dev/null &"
{% endhighlight %}
<h3><a name="functions" class="anchor" href="#functions"><span class="octicon octicon-link"></span></a>Functions</h2>
<h2><a name="functions" class="anchor" href="#functions"><span class="octicon octicon-link"></span></a>Functions</h2>
<p align="justify">Here is a special function for <code>xrandr</code>:</p>
{% highlight bash %}
@ -439,7 +439,7 @@ yatest () {
{% endhighlight %}
<p align="justify">But autocomplete for <code>yaourt -Ss</code> <a href="https://github.com/zsh-users/zsh-completions/pull/205">will require</a> root privileges.</p>
<h3><a name="variables" class="anchor" href="#variables"><span class="octicon octicon-link"></span></a>Variables</h2>
<h2><a name="variables" class="anchor" href="#variables"><span class="octicon octicon-link"></span></a>Variables</h2>
<p align="justify">It is recommended to set own variables in <code>~/.zshenv</code>. But I have everything stored in the single file.</p>
<p align="justify">Here are path, mask of new files, editor and pager:</p>
@ -463,8 +463,8 @@ hash -d u1=/mnt/usbdev1
hash -d u2=/mnt/usbdev
{% endhighlight %}
<h3><a name="screenshot" class="anchor" href="#screenshot"><span class="octicon octicon-link"></span></a>Screenshot</h2>
<h2><a name="screenshot" class="anchor" href="#screenshot"><span class="octicon octicon-link"></span></a>Screenshot</h2>
<p align="justify"><a href="/resources/screenshots/zshrc_demo.png"><img src="/resources/preview/zshrc_demo_prev.jpg"></a></p>
<h3><a name="file" class="anchor" href="#file"><span class="octicon octicon-link"></span></a>File</h2>
<h2><a name="file" class="anchor" href="#file"><span class="octicon octicon-link"></span></a>File</h2>
<p align="justify"><a href="https://raw.github.com/arcan1s/dotfiles/master/zshrc">Here is</a> my <code>.zshrc</code>.</p>

View File

@ -0,0 +1,200 @@
---
category: en
type: paper
layout: paper
tags: archlinux, linux, building, qutim
title: Building Qutim using Qt5
short: building-qutim-using-qt5
description: <a href="http://qutim.org">Qutim</a> is a multiprotocol and cross platform messenger. It is written on <code>CPP</code> using Qt library. The project is actively developed. In this paper I will say about building this package in Archlinux using Qt5 library (instead of Qt4 which is used in current AUR packages).
commentIssueId: 6
---
<h2><a name="problems" class="anchor" href="#problems"><span class="octicon octicon-link"></span></a>What's wrong?</h2>
<p align="justify">This package uses <a href="http://qt-project.org/wiki/qbs">qbs</a> for building, which is a bit strange IMHO. A package, which is necessary for building, is <a href="https://aur.archlinux.org/packages/qbs-git/">in AUR </a>. I recommend to use git version of the package. When I asked Andrea Scarpino (who maintains KDE and Qt packages into the official repos) about qbs, he told me "we will support it in time". And I agree with him, the project seems to be a little unstable.</p>
<h2><a name="prepare" class="anchor" href="#prepare"><span class="octicon octicon-link"></span></a>Prepare</h2>
<p align="justify">Install dependences. I had used <code>namcap</code>, so maybe I missed something:</p>
{% highlight bash %}
pacman -Sy --asdeps clang git libc++abi qt5-quick1 qt5-x11extras
yaourt -S --asdeps jreen-git qbs-git
{% endhighlight %}
<h3><a name="qbs" class="anchor" href="#qbs"><span class="octicon octicon-link"></span></a>qbs settings</h3>
<p align="justify">You may read about qbs <a href="http://qt-project.org/wiki/qbs">on the link</a> or see examples which are provides by the package. qbs uses configuration file that firstly you must create and secondly it is stored in your home directory. In theory a configuration file creating ((<code>~/.config/QtProject/qbs.conf</code>)) looks like this:</p>
{% highlight bash %}
qbs-setup-qt --detect
qbs-detect-toolchains
{% endhighlight %}
<p align="justify">Firstly we find Qt libraries. Then we find toolchains (such as compilers). And next we must insert a toolchain into Qt profile (for example, we need <code>clang</code> toolchain):</p>
{% highlight bash %}
sed 's/clang\\/qt-5-2-0\\/g' -i ~/.config/QtProject/qbs.conf
{% endhighlight %}
<p align="justify">And there are other ways. You may edit the file manually or use <code>qbs-config-ui</code> or <code>qbs-config</code>.</p>
<p align="justify">So, we have created the configuration file and put it into build directory:</p>
{% highlight ini %}
[General]
[Qt]
filedialog=
[profiles]
clang\cpp\compilerName=clang++
clang\cpp\toolchainInstallPath=/usr/bin
clang\qbs\architecture=x86_64
clang\qbs\endianness=little
clang\qbs\toolchain=clang, llvm, gcc
gcc\cpp\compilerName=g++
gcc\cpp\toolchainInstallPath=/usr/bin
gcc\qbs\architecture=x86_64
gcc\qbs\endianness=little
gcc\qbs\toolchain=gcc
qutim\Qt\core\binPath=/usr/lib/qt/bin
qutim\Qt\core\buildVariant=release
qutim\Qt\core\config=shared, qpa, no_mocdepend, release, qt_no_framework
qutim\Qt\core\docPath=/usr/share/doc/qt
qutim\Qt\core\incPath=/usr/include/qt
qutim\Qt\core\libInfix=
qutim\Qt\core\libPath=/usr/lib
qutim\Qt\core\mkspecPath=/usr/lib/qt/mkspecs/linux-g++
qutim\Qt\core\namespace=
qutim\Qt\core\pluginPath=/usr/lib/qt/plugins
qutim\Qt\core\qtConfig=minimal-config, small-config, medium-config, large-config, full-config, gtk2, gtkstyle, fontconfig, libudev, evdev, xlib, xcb-glx, xcb-xlib, xcb-sm, xrender, accessibility-atspi-bridge, linuxfb, c++11, accessibility, opengl, shared, qpa, reduce_exports, reduce_relocations, clock-gettime, clock-monotonic, mremap, getaddrinfo, ipv6ifname, getifaddrs, inotify, eventfd, system-jpeg, system-png, png, system-freetype, no-harfbuzz, system-zlib, nis, cups, iconv, glib, dbus, dbus-linked, openssl-linked, xcb, xinput2, alsa, pulseaudio, icu, concurrent, audio-backend, release
qutim\Qt\core\version=5.2.0
qutim\cpp\compilerName=clang++
qutim\cpp\toolchainInstallPath=/usr/bin
qutim\qbs\architecture=x86_64
qutim\qbs\endianness=little
qutim\qbs\toolchain=clang, llvm, gcc
{% endhighlight %}
<p align="justify"><a href="/resources/docs/qutim-qt5-git/qbs-qutim.conf">qbs-qutim.conf</a></p>
<h3><a name="patch" class="anchor" href="#patch"><span class="octicon octicon-link"></span></a>Patch for sources</h3>
<p align="justify">The first problem is <code>clang</code> (at least in Archlinux):</p>
{% highlight diff %}
diff -ruN qutim.orig/core/libqutim.qbs qutim/core/libqutim.qbs
--- qutim.orig/core/libqutim.qbs 2014-01-06 15:39:56.000000000 +0400
+++ qutim/core/libqutim.qbs 2014-01-06 15:44:54.502175067 +0400
@@ -75,7 +75,7 @@
cpp.linkerFlags: {
var flags = base;
if (qbs.toolchain.contains("clang") && qbs.targetOS.contains("linux"))
- flags = flags.concat("-stdlib=libc++ -lcxxrt");
+ flags = flags.concat("-lc++abi");
return flags;
}
{% endhighlight %}
<p align="justify">The second one is qbs:</p>
{% highlight diff %}
diff -ruN qutim.orig/protocols/jabber/jreen/jreen.qbs qutim/protocols/jabber/jreen/jreen.qbs
--- qutim.orig/protocols/jabber/jreen/jreen.qbs 2014-01-06 15:41:33.000000000 +0400
+++ qutim/protocols/jabber/jreen/jreen.qbs 2014-01-06 15:44:54.502175067 +0400
@@ -2,7 +2,7 @@
Project {
- moduleSearchPaths: "qbs/modules"
+ qbsSearchPaths: "qbs/modules"
references: "src/src.qbs"
}
{% endhighlight %}
<p align="justify">And the last one is Vk plugin:</p>
{% highlight diff %}
diff -ruN qutim.orig/protocols/vkontakte/vreen/vreen.qbs qutim/protocols/vkontakte/vreen/vreen.qbs
--- qutim.orig/protocols/vkontakte/vreen/vreen.qbs 2014-01-06 15:41:42.000000000 +0400
+++ qutim/protocols/vkontakte/vreen/vreen.qbs 2014-01-06 15:46:47.142178486 +0400
@@ -5,6 +5,7 @@
property string vreen_qml_path: "bin"
property string vreen_lib_path: "lib"
property string vreen_libexec_path: "lib"
+ property string lib_path: "lib"
property string vreen_version_major: 1
property string vreen_version_minor: 9
{% endhighlight %}
<p align="justify"><a href="/resources/docs/qutim-qt5-git/qutim-qbs-1.1.patch">qutim-qbs-1.1.patch</a></p>
<h3><a name="sources" class="anchor" href="#sources"><span class="octicon octicon-link"></span></a>Get sources</h3>
{% highlight bash %}
# clone repo
git clone https://github.com/euroelessar/qutim
# save qbs.conf
mkdir -p .config/QtProject
cp qbs-qutim.conf .config/QtProject/qbs.conf
# create build directory
mkdir build
# update submodules
cd qutim
git submodule update --init --recursive
# patch
cd ..
patch -p0 -i qutim-qbs-1.1.patch
{% endhighlight %}
<h2><a name="build" class="anchor" href="#build"><span class="octicon octicon-link"></span></a>Building</h2>
{% highlight bash %}
cd qutim
HOME=$(pwd) qbs -j $(nproc) -d ../build release profile:qutim
{% endhighlight %}
<p align="justify">I want to create a universal recipe for the building, thus we must set <code>$HOME</code> directory. Flag <code>-j</code> means number of jobs, <code>-d</code> means build directory, <code>release</code> means building type (debug, release), <code>profile</code> is used profile, which is described in the configuration file.</p>
<h2><a name="install" class="anchor" href="#install"><span class="octicon octicon-link"></span></a>Installation</h2>
{% highlight bash %}
HOME=$(pwd) sudo qbs install -d ../build --install-root "/usr" profile:qutim
{% endhighlight %}
<p align="justify">We must set root directory (<code>--install-root</code>), because without this option the package will be installed into <code>/</code> (<code>/bin</code> and <code>/lib</code>).</p>
<h2><a name="pkgbuild" class="anchor" href="#pkgbuild"><span class="octicon octicon-link"></span></a>PKGBUILD</h2>
{% highlight bash %}
pkgname=qutim-qt5-git
_gitname=qutim
pkgver=v0.3.1.967.gc56d61e
pkgrel=1
pkgdesc="Multiplatform instant messenger (qt5 build). Git version"
arch=('i686' 'x86_64')
url="http://qutim.org"
license=('LGPL' 'GPL3')
depends=('jreen-git' 'libc++abi' 'qt5-quick1' 'qt5-x11extras')
makedepends=('clang' 'qbs')
conflicts=(qutim-0.2_ru-git, qutim-0.3-git, qutim-stable, qutim-git)
source=("${_gitname}::git+https://github.com/euroelessar/qutim.git"
"qutim-qbs-1.1.patch"
"qbs-qutim.conf")
md5sums=('SKIP'
'c0f151c43c055f76d3fa3efa3b8005e0'
'40f096b269eb00b040035591fce8e259')
pkgver() {
cd "${_gitname}"
git describe --always | sed 's|-|.|g'
}
prepare() {
# FIXME: dirty hack
mkdir -p "${srcdir}/.config/QtProject"
cp "${srcdir}/qbs-qutim.conf" "${srcdir}/.config/QtProject/qbs.conf"
# create build directory
if [[ -d ${srcdir}/build ]]; then
rm -rf "${srcdir}/build"
fi
mkdir "${srcdir}/build"
cd "${_gitname}"
# update modules
git submodule update --init --recursive
# fix qbs build
cd ..
patch -p0 -i "${srcdir}/qutim-qbs-1.1.patch"
}
build() {
cd "${_gitname}"
HOME="${srcdir}" qbs -j $(nproc) -d ../build release profile:qutim
}
package() {
cd "${srcdir}/${_gitname}"
HOME="${srcdir}" qbs install -d ../build --install-root "${pkgdir}/usr" profile:qutim
}
{% endhighlight %}
<p align="justify"><a href="/resources/docs/qutim-qt5-git/PKGBUILD">PKGBUILD</a></p>

View File

@ -0,0 +1,52 @@
# Maintainer: Evgeniy Alekseev <arcanis.arch at gmail dot com>
pkgname=qutim-qt5-git
_gitname=qutim
pkgver=v0.3.1.967.gc56d61e
pkgrel=1
pkgdesc="Multiplatform instant messenger (qt5 build). Git version"
arch=('i686' 'x86_64')
url="http://qutim.org"
license=('LGPL' 'GPL3')
depends=('jreen-git' 'libc++abi' 'qt5-quick1' 'qt5-x11extras')
makedepends=('clang' 'qbs')
conflicts=(qutim-0.2_ru-git, qutim-0.3-git, qutim-stable, qutim-git)
source=("${_gitname}::git+https://github.com/euroelessar/qutim.git"
"qutim-qbs-1.1.patch"
"qbs-qutim.conf")
md5sums=('SKIP'
'c0f151c43c055f76d3fa3efa3b8005e0'
'40f096b269eb00b040035591fce8e259')
pkgver() {
cd "${_gitname}"
git describe --always | sed 's|-|.|g'
}
prepare() {
# FIXME: dirty hack
mkdir -p "${srcdir}/.config/QtProject"
cp "${srcdir}/qbs-qutim.conf" "${srcdir}/.config/QtProject/qbs.conf"
# create build directory
if [[ -d ${srcdir}/build ]]; then
rm -rf "${srcdir}/build"
fi
mkdir "${srcdir}/build"
cd "${_gitname}"
# update modules
git submodule update --init --recursive
# fix qbs build
cd ..
patch -p0 -i "${srcdir}/qutim-qbs-1.1.patch"
}
build() {
cd "${_gitname}"
HOME="${srcdir}" qbs -j $(nproc) -d ../build release profile:qutim
}
package() {
cd "${srcdir}/${_gitname}"
HOME="${srcdir}" qbs install -d ../build --install-root "${pkgdir}/usr" profile:qutim
}

View File

@ -0,0 +1,33 @@
[General]
[Qt]
filedialog=
[profiles]
clang\cpp\compilerName=clang++
clang\cpp\toolchainInstallPath=/usr/bin
clang\qbs\architecture=x86_64
clang\qbs\endianness=little
clang\qbs\toolchain=clang, llvm, gcc
gcc\cpp\compilerName=g++
gcc\cpp\toolchainInstallPath=/usr/bin
gcc\qbs\architecture=x86_64
gcc\qbs\endianness=little
gcc\qbs\toolchain=gcc
qutim\Qt\core\binPath=/usr/lib/qt/bin
qutim\Qt\core\buildVariant=release
qutim\Qt\core\config=shared, qpa, no_mocdepend, release, qt_no_framework
qutim\Qt\core\docPath=/usr/share/doc/qt
qutim\Qt\core\incPath=/usr/include/qt
qutim\Qt\core\libInfix=
qutim\Qt\core\libPath=/usr/lib
qutim\Qt\core\mkspecPath=/usr/lib/qt/mkspecs/linux-g++
qutim\Qt\core\namespace=
qutim\Qt\core\pluginPath=/usr/lib/qt/plugins
qutim\Qt\core\qtConfig=minimal-config, small-config, medium-config, large-config, full-config, gtk2, gtkstyle, fontconfig, libudev, evdev, xlib, xcb-glx, xcb-xlib, xcb-sm, xrender, accessibility-atspi-bridge, linuxfb, c++11, accessibility, opengl, shared, qpa, reduce_exports, reduce_relocations, clock-gettime, clock-monotonic, mremap, getaddrinfo, ipv6ifname, getifaddrs, inotify, eventfd, system-jpeg, system-png, png, system-freetype, no-harfbuzz, system-zlib, nis, cups, iconv, glib, dbus, dbus-linked, openssl-linked, xcb, xinput2, alsa, pulseaudio, icu, concurrent, audio-backend, release
qutim\Qt\core\version=5.2.0
qutim\cpp\compilerName=clang++
qutim\cpp\toolchainInstallPath=/usr/bin
qutim\qbs\architecture=x86_64
qutim\qbs\endianness=little
qutim\qbs\toolchain=clang, llvm, gcc

View File

@ -0,0 +1,35 @@
diff -ruN qutim.orig/core/libqutim.qbs qutim/core/libqutim.qbs
--- qutim.orig/core/libqutim.qbs 2014-01-06 15:39:56.000000000 +0400
+++ qutim/core/libqutim.qbs 2014-01-06 15:44:54.502175067 +0400
@@ -75,7 +75,7 @@
cpp.linkerFlags: {
var flags = base;
if (qbs.toolchain.contains("clang") && qbs.targetOS.contains("linux"))
- flags = flags.concat("-stdlib=libc++ -lcxxrt");
+ flags = flags.concat("-lc++abi");
return flags;
}
diff -ruN qutim.orig/protocols/jabber/jreen/jreen.qbs qutim/protocols/jabber/jreen/jreen.qbs
--- qutim.orig/protocols/jabber/jreen/jreen.qbs 2014-01-06 15:41:33.000000000 +0400
+++ qutim/protocols/jabber/jreen/jreen.qbs 2014-01-06 15:44:54.502175067 +0400
@@ -2,7 +2,7 @@
Project {
- moduleSearchPaths: "qbs/modules"
+ qbsSearchPaths: "qbs/modules"
references: "src/src.qbs"
}
diff -ruN qutim.orig/protocols/vkontakte/vreen/vreen.qbs qutim/protocols/vkontakte/vreen/vreen.qbs
--- qutim.orig/protocols/vkontakte/vreen/vreen.qbs 2014-01-06 15:41:42.000000000 +0400
+++ qutim/protocols/vkontakte/vreen/vreen.qbs 2014-01-06 15:46:47.142178486 +0400
@@ -5,6 +5,7 @@
property string vreen_qml_path: "bin"
property string vreen_lib_path: "lib"
property string vreen_libexec_path: "lib"
+ property string lib_path: "lib"
property string vreen_version_major: 1
property string vreen_version_minor: 9

View File

@ -8,14 +8,14 @@ short: about-zshrc
description: Это моя статья в моем блоге (я думаю, мне нужно что-нибудь для тестов =)). Существует множество похожих статей и, я думаю, не буду отличаться от большинства. Я просто хочу показать мой <code>.zshrc</code> и объяснить, что в нем есть и зачем оно нужно. Также, любые комментарии или дополнения приветствуются. <a href="http://archlinux.org.ru/forum/topic/12752/">Оригинал</a> статьи.
commentIssueId: 5
---
<h3><a name="prepare" class="anchor" href="#prepare"><span class="octicon octicon-link"></span></a>Подготовка</h2>
<h2><a name="prepare" class="anchor" href="#prepare"><span class="octicon octicon-link"></span></a>Подготовка</h2>
<p align="justify">Сначала установите необходимый минимум:</p>
{% highlight bash %}
pacman -Sy pkgfile zsh zsh-completions zsh-syntax-highlighting
{% endhighlight %}
<p align="justify"><a href="https://www.archlinux.org/packages/pkgfile/">pkgfile</a> очень полезная утилита. Данная команда также установит шелл, дополнения к нему и подсветку синтаксиса.</p>
<h3><a name="configuration" class="anchor" href="#configuration"><span class="octicon octicon-link"></span></a>Настройка шелла</h2>
<h2><a name="configuration" class="anchor" href="#configuration"><span class="octicon octicon-link"></span></a>Настройка шелла</h2>
<p align="justify">Все доступные опции приведены <a href="http://zsh.sourceforge.net/Doc/Release/Options.html">здесь</a>.</p>
<p align="justify">Указываем файл с историей, число команд хранящихся в кэше текущего сеанса и число команд, хранящихся в файле:</p>
@ -112,7 +112,7 @@ setopt HIST_REDUCE_BLANKS
source /usr/share/doc/pkgfile/command-not-found.zsh
{% endhighlight %}
<h3><a name="highlighting" class="anchor" href="#highlighting"><span class="octicon octicon-link"></span></a>Подсветка синтаксиса</h2>
<h2><a name="highlighting" class="anchor" href="#highlighting"><span class="octicon octicon-link"></span></a>Подсветка синтаксиса</h2>
{% highlight bash %}
# highlighting
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
@ -161,7 +161,7 @@ ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=yellow' # конс
{% endhighlight %}
<p align="justify">В первой строке включаем подсветку. Затем включаем основную подсветку, а также подсветку скобок и шаблонов. Шаблоны указываются ниже (<code>rm -rf *</code> в примере). Также может быть включена подсветка команд от <code>root</code> и курсора <code>cursor</code>. Синтаксис настроек понятен, <code>fg</code> цвет шрифта, <code>bg</code> цвет фона.</p>
<h3><a name="prompt" class="anchor" href="#prompt"><span class="octicon octicon-link"></span></a>$PROMPT и $RPROMPT</h2>
<h2><a name="prompt" class="anchor" href="#prompt"><span class="octicon octicon-link"></span></a>$PROMPT и $RPROMPT</h2>
<p align="justify">Я хочу использовать один файл <code>.zshrc</code> для рута и обычного пользователя:</p>
{% highlight bash %}
# PROMPT && RPROMPT
@ -239,7 +239,7 @@ $returncode\
{% endhighlight %}
<p align="justify">Мой RPROMPT показывает текущее время, заряд батареи и код возврата последнего приложения. <code>precmd()</code> необходимо для автоматического обновления. Конструкция <code>$(if.true.false)</code> является условным оператором в <code>zsh</code>.</p>
<h3><a name="aliases" class="anchor" href="#aliases"><span class="octicon octicon-link"></span></a>Аллиасы</h2>
<h2><a name="aliases" class="anchor" href="#aliases"><span class="octicon octicon-link"></span></a>Аллиасы</h2>
<p align="justify"><b>Копируйте только те аллиасы, которые Вам необходимы.</b> Если какой-либо аллиас использует приложение, которое не установлено, это приведет к сбою загрузки конфигурационного файла.</p>
<p align="justify">Полезная (или не очень) функция:</p>
@ -327,7 +327,7 @@ alias -g h="| head"
alias -g dn="&> /dev/null &"
{% endhighlight %}
<h3><a name="functions" class="anchor" href="#functions"><span class="octicon octicon-link"></span></a>Функции</h2>
<h2><a name="functions" class="anchor" href="#functions"><span class="octicon octicon-link"></span></a>Функции</h2>
<p align="justify">Специальная функция для <code>xrandr</code>:</p>
{% highlight bash %}
@ -439,7 +439,7 @@ yatest () {
{% endhighlight %}
<p align="justify">Но автодополнение для <code>yaourt -Ss</code> <a href="https://github.com/zsh-users/zsh-completions/pull/205">будет требовать</a> привилегий рута.</p>
<h3><a name="variables" class="anchor" href="#variables"><span class="octicon octicon-link"></span></a>Переменные</h2>
<h2><a name="variables" class="anchor" href="#variables"><span class="octicon octicon-link"></span></a>Переменные</h2>
<p align="justify">Рекомендуется хранить свои переменные в <code>~/.zshenv</code>. Но я все храню в одном файле.</p>
<p align="justify">Пути, маска создаваемых файлов, редактор и пейджер:</p>
@ -463,8 +463,8 @@ hash -d u1=/mnt/usbdev1
hash -d u2=/mnt/usbdev2
{% endhighlight %}
<h3><a name="screenshot" class="anchor" href="#screenshot"><span class="octicon octicon-link"></span></a>Скриншот</h2>
<h2><a name="screenshot" class="anchor" href="#screenshot"><span class="octicon octicon-link"></span></a>Скриншот</h2>
<p align="justify"><a href="/resources/screenshots/zshrc_demo.png"><img src="/resources/preview/zshrc_demo_prev.jpg"></a></p>
<h3><a name="file" class="anchor" href="#file"><span class="octicon octicon-link"></span></a>Файл</h2>
<h2><a name="file" class="anchor" href="#file"><span class="octicon octicon-link"></span></a>Файл</h2>
<p align="justify"><a href="https://raw.github.com/arcan1s/dotfiles/master/zshrc">Мой</a> <code>.zshrc</code>.</p>

View File

@ -0,0 +1,200 @@
---
category: ru
type: paper
layout: paper
tags: archlinux, linux, сборка, qutim
title: Сборка Qutim с Qt5
short: building-qutim-using-qt5
description: Если кто-то не знает, <a href="http://qutim.org">Qutim</a> - мультипротокольный кросс-платформенный месседжер. Написан он на <code>CPP</code> с использованием библиотек Qt. Проект активно развивается. В этой статье речь пойдет о реализации сборки данного пакета в Archlinux с использованием библиотек Qt5 (а не Qt4, как это делают текущие пакеты в AUR).
commentIssueId: 6
---
<h2><a name="problems" class="anchor" href="#problems"><span class="octicon octicon-link"></span></a>Что не так?</h2>
<p align="justify">Да все так. Просто пакет использует для сборки систему <a href="http://qt-project.org/wiki/qbs">qbs</a>, которая, на мой взгляд, немного странная. Пакет, необходимый для сборки, <a href="https://aur.archlinux.org/packages/qbs-git/">находится в AUR</a> (рекомендую git-версию). Когда я спросил у Andrea Scarpino (который сопровождает все KDE и Qt пакеты в официальные репозитории) по поводу переноса этого пакета в репозитории, он ответил, что всему свое время. В принципе, я с ним согласен, так как проект, судя по всему, еще немного сыроват.</p>
<h2><a name="prepare" class="anchor" href="#prepare"><span class="octicon octicon-link"></span></a>Подготовка</h2>
<p align="justify">Установим зависимости. Что-то может быть пропустил, зависимости сканировал с использованием <code>namcap</code>:</p>
{% highlight bash %}
pacman -Sy --asdeps clang git libc++abi qt5-quick1 qt5-x11extras
yaourt -S --asdeps jreen-git qbs-git
{% endhighlight %}
<h3><a name="qbs" class="anchor" href="#qbs"><span class="octicon octicon-link"></span></a>Настройка qbs</h3>
<p align="justify">Желающие могут почитать документацию <a href="http://qt-project.org/wiki/qbs">по ссылке</a> или посмотреть примеры (включены в пакет). Загвоздка в том, что эта штука использует файл настроек, который, во-первых, нужно сначала сгенерировать, во-вторых, хранится в домашней директории (и только там). В теории, генерация файла настроек (<code>~/.config/QtProject/qbs.conf</code>) происходит следующим образом:</p>
{% highlight bash %}
qbs-setup-qt --detect
qbs-detect-toolchains
{% endhighlight %}
<p align="justify">Сначала находим Qt для сборки, потом находим инструментарий (компиляторы, например). Дальше вставляем инструментарий (например, нам для Qutim нужен <code>clang</code>) в Qt, например, так:</p>
{% highlight bash %}
sed 's/clang\\/qt-5-2-0\\/g' -i ~/.config/QtProject/qbs.conf
{% endhighlight %}
<p align="justify">Альтернативные варианты - править файл вручную или воспользоваться <code>qbs-config-ui</code> или <code>qbs-config</code> на Ваш выбор.</p>
<p align="justify">Так или иначе, нужный файл мы сгенерировали, сохраним его в будущей директории сборки:</p>
{% highlight ini %}
[General]
[Qt]
filedialog=
[profiles]
clang\cpp\compilerName=clang++
clang\cpp\toolchainInstallPath=/usr/bin
clang\qbs\architecture=x86_64
clang\qbs\endianness=little
clang\qbs\toolchain=clang, llvm, gcc
gcc\cpp\compilerName=g++
gcc\cpp\toolchainInstallPath=/usr/bin
gcc\qbs\architecture=x86_64
gcc\qbs\endianness=little
gcc\qbs\toolchain=gcc
qutim\Qt\core\binPath=/usr/lib/qt/bin
qutim\Qt\core\buildVariant=release
qutim\Qt\core\config=shared, qpa, no_mocdepend, release, qt_no_framework
qutim\Qt\core\docPath=/usr/share/doc/qt
qutim\Qt\core\incPath=/usr/include/qt
qutim\Qt\core\libInfix=
qutim\Qt\core\libPath=/usr/lib
qutim\Qt\core\mkspecPath=/usr/lib/qt/mkspecs/linux-g++
qutim\Qt\core\namespace=
qutim\Qt\core\pluginPath=/usr/lib/qt/plugins
qutim\Qt\core\qtConfig=minimal-config, small-config, medium-config, large-config, full-config, gtk2, gtkstyle, fontconfig, libudev, evdev, xlib, xcb-glx, xcb-xlib, xcb-sm, xrender, accessibility-atspi-bridge, linuxfb, c++11, accessibility, opengl, shared, qpa, reduce_exports, reduce_relocations, clock-gettime, clock-monotonic, mremap, getaddrinfo, ipv6ifname, getifaddrs, inotify, eventfd, system-jpeg, system-png, png, system-freetype, no-harfbuzz, system-zlib, nis, cups, iconv, glib, dbus, dbus-linked, openssl-linked, xcb, xinput2, alsa, pulseaudio, icu, concurrent, audio-backend, release
qutim\Qt\core\version=5.2.0
qutim\cpp\compilerName=clang++
qutim\cpp\toolchainInstallPath=/usr/bin
qutim\qbs\architecture=x86_64
qutim\qbs\endianness=little
qutim\qbs\toolchain=clang, llvm, gcc
{% endhighlight %}
<p align="justify"><a href="/resources/docs/qutim-qt5-git/qbs-qutim.conf">qbs-qutim.conf</a></p>
<h3><a name="patch" class="anchor" href="#patch"><span class="octicon octicon-link"></span></a>Готовим патч для исходников</h3>
<p align="justify">Первая проблема - <code>clang</code> (по крайней мере, в Archlinux):</p>
{% highlight diff %}
diff -ruN qutim.orig/core/libqutim.qbs qutim/core/libqutim.qbs
--- qutim.orig/core/libqutim.qbs 2014-01-06 15:39:56.000000000 +0400
+++ qutim/core/libqutim.qbs 2014-01-06 15:44:54.502175067 +0400
@@ -75,7 +75,7 @@
cpp.linkerFlags: {
var flags = base;
if (qbs.toolchain.contains("clang") && qbs.targetOS.contains("linux"))
- flags = flags.concat("-stdlib=libc++ -lcxxrt");
+ flags = flags.concat("-lc++abi");
return flags;
}
{% endhighlight %}
<p align="justify">Далее пофиксить устаревший стандарт qbs:</p>
{% highlight diff %}
diff -ruN qutim.orig/protocols/jabber/jreen/jreen.qbs qutim/protocols/jabber/jreen/jreen.qbs
--- qutim.orig/protocols/jabber/jreen/jreen.qbs 2014-01-06 15:41:33.000000000 +0400
+++ qutim/protocols/jabber/jreen/jreen.qbs 2014-01-06 15:44:54.502175067 +0400
@@ -2,7 +2,7 @@
Project {
- moduleSearchPaths: "qbs/modules"
+ qbsSearchPaths: "qbs/modules"
references: "src/src.qbs"
}
{% endhighlight %}
<p align="justify">И пофиксить сборку библиотеки для Vk:</p>
{% highlight diff %}
diff -ruN qutim.orig/protocols/vkontakte/vreen/vreen.qbs qutim/protocols/vkontakte/vreen/vreen.qbs
--- qutim.orig/protocols/vkontakte/vreen/vreen.qbs 2014-01-06 15:41:42.000000000 +0400
+++ qutim/protocols/vkontakte/vreen/vreen.qbs 2014-01-06 15:46:47.142178486 +0400
@@ -5,6 +5,7 @@
property string vreen_qml_path: "bin"
property string vreen_lib_path: "lib"
property string vreen_libexec_path: "lib"
+ property string lib_path: "lib"
property string vreen_version_major: 1
property string vreen_version_minor: 9
{% endhighlight %}
<p align="justify"><a href="/resources/docs/qutim-qt5-git/qutim-qbs-1.1.patch">qutim-qbs-1.1.patch</a></p>
<h3><a name="sources" class="anchor" href="#sources"><span class="octicon octicon-link"></span></a>Получаем исходники</h3>
{% highlight bash %}
# клонируем репозиторий
git clone https://github.com/euroelessar/qutim
# кладем файл настроек qbs
mkdir -p .config/QtProject
cp qbs-qutim.conf .config/QtProject/qbs.conf
# создаем директорию сборки
mkdir build
# обновляем подмодули
cd qutim
git submodule update --init --recursive
# патчим
cd ..
patch -p0 -i qutim-qbs-1.1.patch
{% endhighlight %}
<h2><a name="build" class="anchor" href="#build"><span class="octicon octicon-link"></span></a>Сборка</h2>
{% highlight bash %}
cd qutim
HOME=$(pwd) qbs -j $(nproc) -d ../build release profile:qutim
{% endhighlight %}
<p align="justify">Я пытался сделать универсальный способ сборки пакета, поэтому такое странное переназначение домашней директории. Флаг <code>-j</code> указывает число потоков сборки, флаг <code>-d</code> директорию сборки, <code>release</code> тип сборки (debug, release), <code>profile</code> используемый профиль, описанный в файле настроек.</p>
<h2><a name="install" class="anchor" href="#install"><span class="octicon octicon-link"></span></a>Установка</h2>
{% highlight bash %}
HOME=$(pwd) sudo qbs install -d ../build --install-root "/usr" profile:qutim
{% endhighlight %}
<p align="justify">Из нового - указание корневого каталога (<code>--install-root</code>). Без этого пакет будет установлен в <code>/</code> (<code>/bin</code> и <code>/lib</code>).</p>
<h2><a name="pkgbuild" class="anchor" href="#pkgbuild"><span class="octicon octicon-link"></span></a>PKGBUILD</h2>
{% highlight bash %}
pkgname=qutim-qt5-git
_gitname=qutim
pkgver=v0.3.1.967.gc56d61e
pkgrel=1
pkgdesc="Multiplatform instant messenger (qt5 build). Git version"
arch=('i686' 'x86_64')
url="http://qutim.org"
license=('LGPL' 'GPL3')
depends=('jreen-git' 'libc++abi' 'qt5-quick1' 'qt5-x11extras')
makedepends=('clang' 'qbs')
conflicts=(qutim-0.2_ru-git, qutim-0.3-git, qutim-stable, qutim-git)
source=("${_gitname}::git+https://github.com/euroelessar/qutim.git"
"qutim-qbs-1.1.patch"
"qbs-qutim.conf")
md5sums=('SKIP'
'c0f151c43c055f76d3fa3efa3b8005e0'
'40f096b269eb00b040035591fce8e259')
pkgver() {
cd "${_gitname}"
git describe --always | sed 's|-|.|g'
}
prepare() {
# FIXME: dirty hack
mkdir -p "${srcdir}/.config/QtProject"
cp "${srcdir}/qbs-qutim.conf" "${srcdir}/.config/QtProject/qbs.conf"
# create build directory
if [[ -d ${srcdir}/build ]]; then
rm -rf "${srcdir}/build"
fi
mkdir "${srcdir}/build"
cd "${_gitname}"
# update modules
git submodule update --init --recursive
# fix qbs build
cd ..
patch -p0 -i "${srcdir}/qutim-qbs-1.1.patch"
}
build() {
cd "${_gitname}"
HOME="${srcdir}" qbs -j $(nproc) -d ../build release profile:qutim
}
package() {
cd "${srcdir}/${_gitname}"
HOME="${srcdir}" qbs install -d ../build --install-root "${pkgdir}/usr" profile:qutim
}
{% endhighlight %}
<p align="justify"><a href="/resources/docs/qutim-qt5-git/PKGBUILD">PKGBUILD</a></p>