Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Monday, October 5, 2020

Linux Mint: Install the proper firmware and set-up the USB-BT400 for linux

Objective


I wanted to set up my new USB-BT400 adapter working with Linux Mint.

Motivation


As a consequence of the actual corona-situation I had to use my headset in order to work from home. Since now, I only had a cheap wired one that I rarely used. Recently, my old headset somehow disassembled itself. Therefore, I thought, maybe it's better to buy a good one instead of a crappy cheap one, because I have to use it at a daily bases from now on. The headset should be of good quality and also fit well regarding UX, which means "no cables" anymore. My decision felt on the Sony XB900N. I also wanted to be able to use it not only with my laptop, but also with my desktop computer. Unfortunately, I have no bluetooth adapter assembled on it's mainboard. Therefore I decided to buy a bluetooth adapter, as well. My decision here, felt on the USB-BT400. The adapter and the headset worked well on Windows. I even could use the headset with my laptop out-of-the-box. Unfortunatelly, I recognized, when I wanted to use the bluetooth adapter in combination with the bluetooth headset on my desktop computer running my favorite OS Linux Mint Ulyana, the speakers of the headset work well, but the microphone was not recognized at all. Time to fix this!

Prerequisites


  • Linux Mint 20.0 Ulyana - Cinnamon (64 Bit)
  • USB-BT400
  • Any bluetooth headset with microphone (e.g. Sony XB900N)

Solution


Test if all works


First plug-in the bluetooth adapter into a free USB slot. Turn bluetooth on. Open the bluetooth device manager (e.g. default or blueman) and try find your bluetooth headset. Set it up, try to pair it and connect. If everything works fine, Good! Otherwise...

Check what the problem is


Open a terminal and type the following command:

$> sudo dmesg | egrep -i 'blue|firm'

you'll see some output similar to this:

[ 0.196061] Spectre V2 : Enabling Restricted Speculation for firmware calls
[ 1.011797] usb 3-6: Product: BCM920702 Bluetooth 4.0
[ 4.962537] Bluetooth: Core ver 2.22
[ 4.962552] Bluetooth: HCI device and connection manager initialized
...
[ 5.169217] Bluetooth: hci0: BCM20702A1 (001.002.014) build 1346
[ 5.172387] bluetooth hci0: Direct firmware load for brcm/BCM20702A1-0b05-17cb.hcd failed with error -2
[ 5.172390] Bluetooth: hci0: BCM: Patch brcm/BCM20702A1-0b05-17cb.hcd not found


Get the missing firmware and install it.


Navigate to USB-BT400 firmware and download the correct firmware for your device mentioned from the error message above, mine is BCM20702A1-0b05-17cb.hcd
$> cd /lib/firmware/brcm/
$> wget https://github.com/winterheart/broadcom-bt-firmware/
   blob/master/brcm/BCM20702A1-0b05-17cb.hcd
   && sudo mv BCM20702A1-0b05-17cb.hcd /lib/firmware/brcm/

you'll see some output similar to this:

Resolving github.com (github.com)... 140.82.121.3
Connecting to github.com (github.com)|140.82.121.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘BCM20702A1-0b05-17cb.hcd’
BCM20702A1-0b05-17cb.hcd [ <=> ] 80,47K --.-KB/s in 0,03s
2020-10-05 19:23:04 (2,26 MB/s) - ‘BCM20702A1-0b05-17cb.hcd’ saved [82403]


Verify that all is fine now


Reboot, and check again.
$> sudo dmesg | egrep -i 'blue|firm'

you'll see some output similar to this:

[ 0.196061] Spectre V2 : Enabling Restricted Speculation for firmware calls
[ 1.011797] usb 3-6: Product: BCM920702 Bluetooth 4.0
[ 4.962537] Bluetooth: Core ver 2.22
[ 4.962552] Bluetooth: HCI device and connection manager initialized
...
[ 5.979445] Bluetooth: hci0: BCM20702A1 (001.002.014) build 1467
[ 5.995451] Bluetooth: hci0: Broadcom Bluetooth Device


Open the bluetooth device manager (e.g. default or blueman) and try find your bluetooth headset. Set it up, try to pair it and connect. Navigate with your browser to a page to test your microphone online. Done!

References:

  1. Ubuntu forum discussing the issue
  2. Broadcom Bluetooth firmware for Linux kernel
  3. USB-BT400 firmware
  4. Online webcam, speaker and microphone test page

Friday, June 21, 2019

Linux Mint: Compile the Lua interpreter from source and build your own Debian package to install it

Objective


Compile the latest version of the Lua language interpreter from source. First build a locally installed Lua interpreter for the current user only. Finally, build a Debian package to install it and have the possibility to safely remove it when necessary.

Motivation


Recently, I thought it was a good idea to learn a new programming language that can be easily integrated and combined with C++. After a quick research I figured that Lua would be very handy for such a job. Unfortunately, my current Mint version does not quite support the latest Lua version in it's repository. Additionally, I plan to use Lua from Windows 10, too. So, I wanted to have the installation build from the same sources for both Operating Systems as well. This article describes the process to get a local portable installation of Lua on per user basis and a description on how to build a Debian installer package for Linux that can be easily uninstalled again. An upcoming article will describe how to compile your own Lua interpreter on Windows 10 using the (command line interface) CLI compiler from Microsoft e.g. Visual Studio Professional.

Prerequisites



Solution


I decided to do the whole build and temporary stuff within a "tmp" folder in my home account.
The boostrap toolchain will reside in the sub-directory "lua" within the "tmp" folder.

Get the latest source of the Lua interpreter from their homepage


Open a terminal and change the current directory to "~/tmp". Type the following commands to dowload the latest version of the source code of the Lua interpreter, in my case version 5.3.5.

$> mkdir -p ~/tmp/lua
$> cd ~/tmp/lua
$> wget https://www.lua.org/ftp/lua-5.3.5.tar.gz

you'll see some output similar to this:

--2019-06-19 21:34:32-- https://www.lua.org/ftp/lua-5.3.5.tar.gz
Resolving www.lua.org (www.lua.org)... 88.99.213.221, 2a01:4f8:10a:3edc::2
Connecting to www.lua.org (www.lua.org)|88.99.213.221|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 303543 (296K) [application/gzip]
Saving to: ‘lua-5.3.5.tar.gz’

lua-5.3.5.tar.gz 100%[===============================================================>] 296,43K --.-KB/s in 0,1s

2019-06-19 21:34:32 (2,56 MB/s) - ‘lua-5.3.5.tar.gz’ saved [303543/303543]

Now you have to unpack the downloaded package:

$> tar -xzvf lua-5.3.5.tar.gz

Everything will be unpacked into the sub-directory "lua-5.3.5"

lua-5.3.5/
lua-5.3.5/Makefile
lua-5.3.5/doc/
lua-5.3.5/doc/luac.1
lua-5.3.5/doc/manual.html
lua-5.3.5/doc/manual.css
lua-5.3.5/doc/contents.html
[...]
lua-5.3.5/doc/readme.html
lua-5.3.5/src/
lua-5.3.5/src/ldblib.c
lua-5.3.5/src/lmathlib.c
lua-5.3.5/src/loslib.c
lua-5.3.5/src/lvm.c
lua-5.3.5/src/ldo.h
lua-5.3.5/src/lua.h
[...]
lua-5.3.5/src/lua.hpp
[...]
lua-5.3.5/README
[...]

Change into the directory "~/tmp/lua/lua-5.3.5" in order to build the interpreter.

$> cd ~/tmp/lua/lua-5.3.5

Compile the Lua interpreter from the sources


In order to check how the interpreter can be build and to get more information, we type "make"

$> make

Please do 'make PLATFORM' where PLATFORM is one of these:
aix bsd c89 freebsd generic linux macosx mingw posix solaris
See doc/readme.html for complete instructions.

For further explanations, we can check the included documentation in "doc/readme.html".

Let's compile the sources for the Linux target system.

$> make linux

cd src && make linux
make[1]: Entering directory '/home/cschmidt/tmp/lua/lua-5.3.5/src'
make all SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline"
make[2]: Entering directory '/home/cschmidt/tmp/lua/lua-5.3.5/src'
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_2 -DLUA_USE_LINUX -c -o lapi.o lapi.c
[...]
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_2 -DLUA_USE_LINUX -c -o linit.o linit.c
ar rcu liblua.a lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o lmathlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o loadlib.o linit.o
ar: `u' modifier ignored since `D' is the default (see `U')
ranlib liblua.a
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_2 -DLUA_USE_LINUX -c -o lua.o lua.c
lua.c:82:10: fatal error: readline/readline.h: No such file or directory
#include
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
: recipe for target 'lua.o' failed
make[2]: *** [lua.o] Error 1
make[2]: Leaving directory '/home/cschmidt/tmp/lua/lua-5.3.5/src'
Makefile:110: recipe for target 'linux' failed
make[1]: *** [linux] Error 2
make[1]: Leaving directory '/home/cschmidt/tmp/lua/lua-5.3.5/src'
Makefile:55: recipe for target 'linux' failed
make: *** [linux] Error 2

Ooops, that was unexpected!

However, a quick online research shows that in order to compile Lua the dependency to the "readline" library has to be met.
Let's quickly resolve that.

$> sudo apt-get install libreadline-dev

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libtinfo-dev
Suggested packages:
readline-doc
The following NEW packages will be installed:
libreadline-dev libtinfo-dev
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 214 kB of archives.
After this operation, 1.134 kB of additional disk space will be used.
Do you want to continue? [J/n] J
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libtinfo-dev amd64 6.1-1ubuntu1.18.04 [81,3 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 libreadline-dev amd64 7.0-3 [133 kB]
Fetched 214 kB in 0s (557 kB/s)
Selecting previously unselected package libtinfo-dev:amd64.
(Reading database ... 354931 files and directories currently installed.)
Preparing to unpack .../libtinfo-dev_6.1-1ubuntu1.18.04_amd64.deb ...
Unpacking libtinfo-dev:amd64 (6.1-1ubuntu1.18.04) ...
Selecting previously unselected package libreadline-dev:amd64.
Preparing to unpack .../libreadline-dev_7.0-3_amd64.deb ...
Unpacking libreadline-dev:amd64 (7.0-3) ...
Processing triggers for install-info (6.5.0.dfsg.1-2) ...
Setting up libtinfo-dev:amd64 (6.1-1ubuntu1.18.04) ...
Setting up libreadline-dev:amd64 (7.0-3) ...

And try again ...

$> make linux

cd src && make linux
make[1]: Entering directory '/home/cschmidt/tmp/lua/lua-5.3.5/src'
make all SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline"
make[2]: Entering directory '/home/cschmidt/tmp/lua/lua-5.3.5/src'
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_2 -DLUA_USE_LINUX -c -o lua.o lua.c
gcc -std=gnu99 -o lua lua.o liblua.a -lm -Wl,-E -ldl -lreadline
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_2 -DLUA_USE_LINUX -c -o luac.o luac.c
gcc -std=gnu99 -o luac luac.o liblua.a -lm -Wl,-E -ldl -lreadline
make[2]: Leaving directory '/home/cschmidt/tmp/lua/lua-5.3.5/src'
make[1]: Leaving directory '/home/cschmidt/tmp/lua/lua-5.3.5/src'

Done.

In order to install everything system-wide, you can now type

$> sudo make linux install

But hold on!
Do we really want to pollute our system and install things system-wide without having the possibility to uninstall safely everything later?

What about just create a local install for the current user ...

$> make local

make install INSTALL_TOP=../install
make[1]: Entering directory '/home/cschmidt/tmp/lua/lua-5.3.5'
cd src && mkdir -p ../install/bin ../install/include ../install/lib ../install/man/man1 ../install/share/lua/5.3 ../install/lib/lua/5.3
cd src && install -p -m 0755 lua luac ../install/bin
cd src && install -p -m 0644 lua.h luaconf.h lualib.h lauxlib.h lua.hpp ../install/include
cd src && install -p -m 0644 liblua.a ../install/lib
cd doc && install -p -m 0644 lua.1 luac.1 ../install/man/man1

Let's see, what this did:

$> ls -la

drwxr-xr-x 5 cschmidt cschmidt 4096 Jun 19 21:43 .
drwxrwxr-x 3 cschmidt cschmidt 4096 Jun 19 21:35 ..
drwxr-xr-x 2 cschmidt cschmidt 4096 Jun 26 2018 doc
drwxrwxr-x 7 cschmidt cschmidt 4096 Jun 19 21:43install
-rw-r--r-- 1 cschmidt cschmidt 3273 Dez 20 2016 Makefile
-rw-r--r-- 1 cschmidt cschmidt 151 Jun 26 2018 README
drwxr-xr-x 2 cschmidt cschmidt 4096 Jun 19 21:40 src

$> ls -la install

drwxrwxr-x 7 cschmidt cschmidt 4096 Jun 19 21:43 .
drwxr-xr-x 57 cschmidt users 4096 Jun 20 20:59 ..
drwxrwxr-x 2 cschmidt cschmidt 4096 Jun 19 21:43 bin
drwxrwxr-x 2 cschmidt cschmidt 4096 Jun 19 21:43 include
drwxrwxr-x 3 cschmidt cschmidt 4096 Jun 19 21:43 lib
drwxrwxr-x 3 cschmidt cschmidt 4096 Jun 19 21:43 man
drwxrwxr-x 3 cschmidt cschmidt 4096 Jun 19 21:43 share

Fine, everything is build locally into a sub-folder "install". If we want to use this version, we can just move it to our home-account and expand the "PATH" environment variable by the location to the Lua interpreter binary:

$> mv install ~/lua
$> set PATH=$PATH:~/lua/bin

In order to add the binary path permanently after a new login, we need to edit the "PATH" variable in our ".bashrc" file as we already did in some of the other articles e.g. Linux Mint: Compile and install the Go compiler from source.

Anyway, this time we want to build a Debian installer package instead.

Build a Debian package to install


As we already know from the article about Linux Mint: Linux Mint: Build your own debian package of cmake, we can use "checkinstall":

$> sudo checkinstall --install=no

checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
This software is released under the GNU GPL.



*****************************************
**** Debian package creation selected ***
*****************************************

The configuration will look like something similar to

This package will be built according to these values:

0 - Maintainer: [ cschmidt@gimli ]
1 - Summary: [ Lua 5.3.0 private build ]
2 - Name: [ lua ]
3 - Version: [ 5.3.5 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ checkinstall ]
7 - Architecture: [ amd64 ]
8 - Source location: [ lua-5.3.5 ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ lua ]
12 - Conflicts: [ ]
13 - Replaces: [ ]

Enter a number to change any of them or press ENTER to continue:

so we adjust everything in order to our needs (for details see also the article Linux Mint: Linux Mint: Build your own debian package of cmake):

This package will be built according to these values:

0 - Maintainer: [ christianschmidt@hotmail.com ]
1 - Summary: [ Lua 5.3.0 private build ]
2 - Name: [ lua ]
3 - Version: [ 5.3.5 ]
4 - Release: [ 1 ]
5 - License: [ MIT ]
6 - Group: [ checkinstall ]
7 - Architecture: [ amd64 ]
8 - Source location: [ lua-5.3.5 ]
9 - Alternate source location: [ https://www.lua.org/ftp/lua-5.3.5.tar.gz ]
10 - Requires: [ ]
11 - Provides: [ lua ]
12 - Conflicts: [ ]
13 - Replaces: [ ]

Enter a number to change any of them or press ENTER to continue:

Now, we can hit "ENTER" to start the build process.

Installing with make install...

========================= Installation results ===========================
cd src && mkdir -p /usr/local/bin /usr/local/include /usr/local/lib /usr/local/man/man1 /usr/local/share/lua/5.3 /usr/local/lib/lua/5.3
cd src && install -p -m 0755 lua luac /usr/local/bin
cd src && install -p -m 0644 lua.h luaconf.h lualib.h lauxlib.h lua.hpp /usr/local/include
cd src && install -p -m 0644 liblua.a /usr/local/lib
cd doc && install -p -m 0644 lua.1 luac.1 /usr/local/man/man1

======================== Installation successful ==========================

Copying documentation directory...
./
./doc/
./doc/lua.css
./doc/contents.html
./doc/manual.css
./doc/luac.1
./doc/index.css
./doc/osi-certified-72x60.png
./doc/readme.html
./doc/lua.1
./doc/logo.gif
./doc/manual.html
./README

Copying files to the temporary directory...OK

Stripping ELF binaries and libraries...OK

Compressing man pages...OK

Building file list...OK

Building Debian package...OK

NOTE: The package will not be installed

Erasing temporary files...OK

Deleting temp dir...OK


**********************************************************************

Done. The new package has been saved to

/home/cschmidt/tmp/lua/lua-5.3.5/lua_5.3.5-1_amd64.deb
You can install it in your system anytime using:

dpkg -i lua_5.3.5-1_amd64.deb

**********************************************************************

Finished.

We now have a package "lua_5.3.5-1_amd64.deb" in the folder "~/tm/lua/lua-3.5.3" that we can e.g. double-click to install.

References:

  1. Lua homepage

Saturday, June 23, 2018

Linux Mint: Compile and install the Go compiler from source

Objective


Set up bootstrapping. Build the latest version of the Go compiler with C bridge mode support from it's sources.

Motivation


By coincidence, I stumbled over this interesting tutorial about the programming language Go.
Since i was always interested to play around with that language, I took the opportunity, to try it out. As I usually want to use the latest compiler-version, I thought, it would be a good idea, that I do not use the Go-Installer, but compile the sources by myself from scratch. Unfortunately, the latest Go compiler, cannot be compiled with C support, when there is not already a Go compiler installed in the system. Therefore I also had to install an older Go compiler for booststrapping first.

Prerequisites



Solution


I decided to do the whole build and temporary stuff within the "Downloads" folder in my home account.
The boostrap toolchain will reside in the sub-directory "gobootstrap" within the "Downloads" folder.

Setup the bootstrap toolchain


Open a terminal. Download and install the latest Go bootstrap toolchain.

$> mkdir -p Downloads/goboostrap
$> cd Downloads/gobootstrap
$> wget https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz

you'll see some output similar to this:

--2018-06-23 17:58:49-- https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz
Resolving dl.google.com (dl.google.com)... 216.58.207.46, 2a00:1450:4001:824::200e
Connecting to dl.google.com (dl.google.com)|216.58.207.46|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11009739 (10M) [application/octet-stream]
Saving to: ‘go1.4-bootstrap-20171003.tar.gz.1’

go1.4-bootstrap-20171003.tar.gz.1 100%[==========================================================================>] 10,50M 5,23MB/s in 2,0s

2018-06-23 17:58:51 (5,23 MB/s) - ‘go1.4-bootstrap-20171003.tar.gz.1’ saved [11009739/11009739]

Now you have to unpack the downloaded toolchain package:

$> tar -xvzf go1.4-bootstrap-20171003.tar.gz

The whole stuff is unpacked into a new sub-directory "go"

go/.gitattributes
go/.gitignore
[...]
go/src/cmd/5g/gg.h
go/src/cmd/5g/ggen.c
go/src/cmd/5g/gobj.c
go/src/cmd/5g/gsubr.c
[...]
go/test/varerr.go
go/test/varinit.go
go/test/zerodivide.go

Change directory into the "./go/src" and build the bootstrap toolchain.
Observe: This step requires you to have already a functional GCC compiler present on your system.
If not already done: To set-up the GCC 7.3.0 on your system see Install multiple versions of GCC on your system

$> CGO_ENABLED=0 ./make.bash

# Building C bootstrap tool.
cmd/dist

# Building compilers and Go bootstrap tool for host, linux/amd64.
lib9
[...]
# Building packages and commands for linux/amd64.
runtime
errors
sync/atomic
[...]
cmd/pprof
net/rpc
net/http/fcgi
net/rpc/jsonrpc

Finally, the toolchain build is finished.

Compile the Go compiler


Before you compile the compiler, step back to the "Downloads" folder and download the latest source of the go compiler.

$> cd ~/Downloads
$> wget https://dl.google.com/go/go1.10.3.src.tar.gz

--2018-06-23 18:29:13-- https://dl.google.com/go/go1.10.3.src.tar.gz
Resolving dl.google.com (dl.google.com)... 216.58.207.78, 2a00:1450:4001:825::200e
Connecting to dl.google.com (dl.google.com)|216.58.207.78|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18323736 (17M) [application/octet-stream]
Saving to: ‘go1.10.3.src.tar.gz’

go1.10.3.src.tar.gz 100%[==========================================================================>] 17,47M 5,94MB/s in 2,9s

2018-06-23 18:29:16 (5,94 MB/s) - ‘go1.10.3.src.tar.gz’ saved [18323736/18323736]

Now, unpack the sources, like it was already done, with the toolchain package.

$> tar -xvzf go1.10.3.src.tar.gz

go/
go/AUTHORS
go/CONTRIBUTING.md
[...]
go/src/runtime/closure_test.go
go/src/runtime/compiler.go
go/src/runtime/complex.go
[...]
go/test/varinit.go
go/test/writebarrier.go
go/test/zerodivide.go

Again, step into the "src" directory and build the compiler, using the bootstrap toolchain.
This step may take a while, depending on the performance of your computer.

$> cd go/src
$> GOROOT_BOOTSTRAP=~/Downloads/gobootstrap/go ./all.bash

Building Go cmd/dist using /home/cschmidt/Downloads/gobootstrap/go.
Building Go toolchain1 using /home/cschmidt/Downloads/gobootstrap/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for linux/amd64.

##### Testing packages.
ok archive/tar 0.051s
ok archive/zip 1.164s
ok bufio 0.186s
ok bytes 0.686s
ok compress/bzip2 0.132s
[...]
ok cmd/vendor/golang.org/x/arch/x86/x86asm 0.213s
ok cmd/vet 3.946s
ok cmd/vet/internal/cfg 0.033s

##### GOMAXPROCS=2 runtime -cpu=1,2,4 -quick
ok runtime 14.067s

##### cmd/go terminal test
PASS
ok _/home/cschmidt/Downloads/go/src/cmd/go/testdata/testterminal18153 0.001s

##### Testing without libgcc.
ok crypto/x509 1.016s
ok net 0.031s
ok os/user 0.038s

[...]

##### API check
Go version is "go1.10.3", ignoring -next /home/cschmidt/Downloads/go/api/next.txt

ALL TESTS PASSED
---
Installed Go for linux/amd64 in /home/cschmidt/Downloads/go
Installed commands in /home/cschmidt/Downloads/go/bin
*** You need to add /home/cschmidt/Downloads/go/bin to your PATH.

As I didn't want to have the Go compiler installed in my "Downloads" folder I simply move it directly into my home-account.

$> cd ~/Downloads
$> mv go ~/

Let's try to call the Go compiler

$> go

The program 'go' is currently not installed. You can install it by typing:
sudo apt install golang-go

Ouwww! What went wrong? -- Nothing!

I forgot to extend the PATH variable of my environment as mentioned by the hint, given after compilation.

To do so, I add the following line to my "~/.bashrc".

$> echo 'PATH=$PATH:$HOME/go/bin # Add go compiler' >> ~/.bashrc

Observe: Double-check, you use single quotes instead of double quotes here, otherwise, the bash will already expand the "$PATH" variable here and append it's content to your "~/.bashrc".

Once, again:
$> go

Go is a tool for managing Go source code.

Usage:

go command [arguments]
[...]

Yeah, finally done.
Just to clean up the mess within the "Downloads" directory by just deleting everything, I do not need anymore.

References:

  1. Go - Environment Setup
  2. Installing Go from source

Wednesday, June 20, 2018

Linux Mint: Build your own debian package of cmake

Objective


I wanted to use the newest available version of CMake (version 3.12.0-rc1) on Linux Mint 18.3 Sylvia.

Motivation


My company started using CMake as a Meta-Build-System in combination with Visual Studio 2017 in a brand new software project. Because of this fact, I had the opportunity, to attend a Modern CMake seminar at Eclipseina GmbH, covering most features of Modern CMake.
As Visual Studio 2017 comes with a CMake-component of version 3.10.0 already, I wanted at least to be able to use the same version of CMake on my Linux Mint 18.3 at home.
Modern CMake requires at least CMake version 3.x.

Unfortunately, the repository of Linux Mint 18.3 only supports a Debian package installer for CMake 3.5.1. The homepage of CMake at cmake.org only offers an install script, without uninstaller. I don't want to pollute my system with early access versions of software packages that I cannot clearly uninstall later.
In contrary, I wanted to be able to install and uninstall any version of CMake. Therefore I needed to build my own Debian install package (*.deb) for CMake.

Prerequisites



Solution


Install CMake locally


Open a terminal. Download and install the CMake installer script:

$> mkdir Downloads
$> cd Downloads
$> wget https://cmake.org/files/v3.12/cmake-3.12.0-rc1-Linux-x86_64.sh

you'll see some output like this:

--2018-06-19 22:58:04-- https://cmake.org/files/v3.12/cmake-3.12.0-rc1-Linux-x86_64.sh
Resolving cmake.org (cmake.org)... 66.194.253.19
Connecting to cmake.org (cmake.org)|66.194.253.19|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 30260259 (29M) [text/x-sh]
Saving to: ‘cmake-3.12.0-rc1-Linux-x86_64.sh.1’

cmake-3.12.0-rc1-Linux-x86_64.sh 100%[==========================================================>] 28,86M 6,02MB/s in 5,3s

2018-06-19 22:58:10 (5,41 MB/s) - ‘cmake-3.12.0-rc1-Linux-x86_64.sh.1’ saved [30260259/30260259]

Now, set the executable flag for the downloaded script and start the temporary local install as normal user

$> chmod u+x cmake-3.12.0-rc1-Linux-x86_64.sh
$> ./cmake-3.12.0-rc1-Linux-x86_64.sh

CMake Installer Version: 3.12.0-rc1, Copyright (c) Kitware
This is a self-extracting archive.
The archive will be extracted to: /home/cschmidt/Downloads

If you want to stop extracting, please press .
CMake - Cross Platform Makefile Generator
Copyright 2000-2018 Kitware, Inc. and Contributors
All rights reserved.

[...]
Do you accept the license? [yN]:

Accept the license, by typing 'y'.

By default the CMake will be installed in:
"/home/cschmidt/Downloads/cmake-3.12.0-rc1-Linux-x86_64"
Do you want to include the subdirectory cmake-3.12.0-rc1-Linux-x86_64?
Saying no will install in: "/home/cschmidt/Downloads" [Yn]:

Accept the default path, by typing 'Y'.

Using target directory: /home/cschmidt/Downloads/cmake-3.12.0-rc1-Linux-x86_64
Extracting, please wait...

Unpacking finished successfully

To be able to use the locally installed CMake, you must add it's binary directory to your environment path:
(Of course, you must use the path from above that reflects your install directory and add a "/bin" path-component here)

$> PATH=$PATH:/home/cschmidt/Downloads/cmake-3.12.0-rc1-Linux-x86_64/bin

Download and extract the CMake source package


$> wget https://cmake.org/files/v3.12/cmake-3.12.0-rc1.tar.gz

--2018-06-19 23:15:38-- https://cmake.org/files/v3.12/cmake-3.12.0-rc1.tar.gz
Resolving cmake.org (cmake.org)... 66.194.253.19
Connecting to cmake.org (cmake.org)|66.194.253.19|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8089283 (7,7M) [application/x-gzip]
Saving to: ‘cmake-3.12.0-rc1.tar.gz.1’

cmake-3.12.0-rc1.tar.gz.1 100%[==========================================================>] 7,71M 3,46MB/s in 2,2s

2018-06-19 23:15:42 (3,46 MB/s) - ‘cmake-3.12.0-rc1.tar.gz.1’ saved [8089283/8089283]

Extract the source tar-gz package:

$> tar -xvzf cmake-3.12.0-rc1.tar.gz
cmake-3.12.0-rc1/.clang-format
cmake-3.12.0-rc1/.clang-tidy
cmake-3.12.0-rc1/Auxiliary/
cmake-3.12.0-rc1/Auxiliary/bash-completion/
cmake-3.12.0-rc1/Auxiliary/bash-completion/cmake
cmake-3.12.0-rc1/Auxiliary/bash-completion/CMakeLists.txt
[...]
cmake-3.12.0-rc1/Utilities/Sphinx/static/cmake-favicon.ico
cmake-3.12.0-rc1/Utilities/Sphinx/static/cmake-logo-16.png
cmake-3.12.0-rc1/Utilities/Sphinx/static/cmake.css
cmake-3.12.0-rc1/Utilities/Sphinx/templates/
cmake-3.12.0-rc1/Utilities/Sphinx/templates/layout.html

Compile CMake from source using your temporary CMake installation


$> cd cmake-3.12.0-rc1
$> mkdir build
$> cd build/
$> cmake ..

CMake does some checks of your system and builds the binaries from source, which takes a while ...

-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
[...]
-- Performing Test run_inlines_hidden_test
-- Performing Test run_inlines_hidden_test - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cschmidt/Downloads/cmake-3.12.0-rc1/build
cschmidt@gimli:~/Downloads/cmake-3.12.0-rc1/build$ make
Scanning dependencies of target cmsys_c
[ 0%] Building C object Source/kwsys/CMakeFiles/cmsys_c.dir/ProcessUNIX.c.o
[ 0%] Building C object Source/kwsys/CMakeFiles/cmsys_c.dir/Base64.c.o
[...]
[ 1%] Building C object Source/kwsys/CMakeFiles/cmsys_c.dir/String.c.o
[ 1%] Linking C static library libcmsys_c.a
[...]
Scanning dependencies of target foo
[100%] Building CXX object Tests/FindPackageModeMakefileTest/CMakeFiles/foo.dir/foo.cpp.o
[100%] Linking CXX static library libfoo.a
[100%] Built target foo

Build the Debian package (*.deb)


If checkinstall is not installed on your machine, you can install it via:

$> sudo apt-get install checkinstall

On mine, it's already available, therefore...

Reading package lists... Done
Building dependency tree
Reading state information... Done
checkinstall is already the newest version (1.6.2-4ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Normally checkinstall needs to be run as root and does not only build the package, but also install the software.
To just build the package, without root privileges and without automatically installing it, we have to run checkinstall using fakeroot.

$> fakeroot checkinstall --install=no --fstrans=yes

checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
This software is released under the GNU GPL.


The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs? [y]: y

Confirm the question with 'y'.

Preparing package documentation...OK

*** No known documentation files were found. The new package
*** won't include a documentation directory.

*****************************************
**** Debian package creation selected ***
*****************************************

This package will be built according to these values:

0 - Maintainer: [ cschmidt@gimli ]
1 - Summary: [ CMake Release Candidate (3.12.0-rc1) ]
2 - Name: [ build ]
3 - Version: [ 20180618 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ checkinstall ]
7 - Architecture: [ amd64 ]
8 - Source location: [ build ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ build ]
12 - Conflicts: [ ]
13 - Replaces: [ ]

Now you have the opportunity to change some meta-data, e.g. name and URL:

Enter a number to change any of them or press ENTER to continue: 0
Enter the maintainer's name and e-mail address:
>> cwschmidt

Enter a number to change any of them or press ENTER to continue: 9
Enter the alternate source location:
>> https://cmake.org/files/v3.12/cmake-3.12.0-rc1.tar.gz

This package will be built according to these values:

0 - Maintainer: [ cwschmidt ]
1 - Summary: [ CMake Release Candidate (3.12.0-rc1) ]
2 - Name: [ build ]
3 - Version: [ 20180618 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ checkinstall ]
7 - Architecture: [ amd64 ]
8 - Source location: [ build ]
9 - Alternate source location: [ https://cmake.org/files/v3.12/cmake-3.12.0-rc1.tar.gz ]
10 - Requires: [ ]
11 - Provides: [ build ]
12 - Conflicts: [ ]
13 - Replaces: [ ]

Enter a number to change any of them or press ENTER to continue:

Finally, press Enter to continue

Installing with make install...

========================= Installation results ===========================
[ 1%] Built target cmsys_c
[ 2%] Built target cmsysTestsC
[ 4%] Built target cmsys
[...]
[100%] Built target pseudo_tidy
[100%] Built target pseudo_cppcheck
[100%] Built target foo
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/doc/cmake-3.12/Copyright.txt
-- Installing: /usr/local/share/cmake-3.12/Help
-- Installing: /usr/local/share/cmake-3.12/Help/prop_dir
-- Installing: /usr/local/share/cmake-3.12/Help/prop_dir/VS_GLOBAL_SECTION_PRE_section.rst
[...]
-- Installing: /usr/local/share/cmake-3.12/Modules
-- Installing: /usr/local/share/cmake-3.12/Modules/FindCurses.cmake
-- Installing: /usr/local/share/cmake-3.12/Modules/FindWget.cmake
-- Installing: /usr/local/share/cmake-3.12/Modules/FindAVIFile.cmake
[...]
-- Installing: /usr/local/bin/cmake
-- Installing: /usr/local/bin/ctest
-- Installing: /usr/local/bin/cpack
[...]
-- Installing: /usr/local/share/cmake-3.12/completions/cmake
-- Installing: /usr/local/share/cmake-3.12/completions/cpack
-- Installing: /usr/local/share/cmake-3.12/completions/ctest

======================== Installation successful ==========================

Some of the files created by the installation are inside the home directory: /home

You probably don't want them to be included in the package.
Do you want me to list them? [n]: y
Should I exclude them from the package? (Saying yes is a good idea) [n]: y

You were ask, to exclude the files that were placed in your home-directory.
To inspect the list, answer the first question with 'y'.
Answer the second question to exclude the files in the home-directory with 'y'.

Copying files to the temporary directory...OK

Stripping ELF binaries and libraries...OK

Compressing man pages...OK

Building file list...OK

Building Debian package...OK

NOTE: The package will not be installed

Erasing temporary files...OK

Writing backup package...OK
OK

Deleting temp dir...OK


**********************************************************************

Done. The new package has been saved to

/home/cschmidt/Downloads/cmake-3.12.0-rc1/build/build_20180618-1_amd64.deb
You can install it in your system anytime using:

dpkg -i build_20180618-1_amd64.deb

**********************************************************************

Finished. You can install the newly created package, by typing

$> sudo dpkg -i build_20180618-1_amd64.deb

or with your debian package manager with a double-click on the file "build_20180618-1_amd64.deb".

References:

  1. cmake.org
  2. How do I install the latest version of cmake from the command line?
  3. checkinstall source code inside home directory

Friday, July 28, 2017

Linux Mint: Mount your iPhone like an external drive to transfer photos and videos

Objective


I want to mount my "iPhone 5s" like any external disk-drive on my Linux Mint 18.2 "Sonya" to access my photos and videos. The "out-of-box" solution stopped working since my upgrade to iOS 10.3.

Motivation


Since iOS 8, I was used to install libimobiledevice with my package-manager (usually synaptic or "apt-get install libimobiledevice" from the Mint repository, to have access to my "iPhone 5s".
Until now, this was a very convenient way, to exchange photos and videos between my iPhone and a my Laptop with Linux Mint. Recently I updated my Linux installation to Linux Mint 18.2 "Sonya" and my iPhone to iOS 10.3.3. After that, I recognized that libimobiledevice didn't work reliable anymore.
First, I couldn't really find out, whether the newer version of Linux Mint or the newer version of iOS was in charge for the decline of service. After a while reading posts on the subject on the internet, I really suspect, that the main reason was the upgrade to iOS 10.2 and later 10.3. In iOS 10.2 I already, only sporadically, could connect my phone, but mostly just to see the "Documents" folder mounted, but not the "Photo" folder. Rarely the "Photo" folder appeared, too. If I was lucky and it was mounted, I wasn't asked whether I will trust the connection to the computer by my phone.
However, without the confirmation of this question (which didn't even appear) the "Photo" folder always was displayed as empty. Bummer!

Prerequisites


  • Linux Mint 18.2 Sonya
  • iPhone 5s with iOS 10.3.3

Solution: Compiling most of the sources yourself


On the internet, I found a manual, that promised to make the connection between an "iPhone" and Linux Mint work again [1]. This manual was written originally for users of Ubuntu in the first place. Still with Linux Mint, it did mostly work as described, but was kind of incomplete.

After you follow this description, the tools, to mount and unmount your phone, will be installed in the home account for the current user, just only one library usbmuxd must be installed as root in the system, otherwise mounting would not work.

Install necessary software for building the source packages


To check-out and compile the needed packages from source, you have to install some additional software first.

Therefore, open a bash-command-shell and install git to be able to check-out the source code repository to be compiled.

$> sudo apt-get install -y git

Then install the compiler suite via the meta-package build-essentials including gcc and such...

$> sudo apt-get install -y build-essential

In contrary to the original manual at [1], I had to install some additional build tools.

$> sudo apt-get install -y libtool m4 automake

I also needed the package libfuse-dev from the Mint repository, this seems maybe not to be necessary on Ubuntu.

$> sudo apt-get install -y libfuse-dev

Setup the shell environment to build the software


If you don't want to install the new commands directly into your system (which also would additionally need sudo for all "make install" commands, which is not recommended), you have to setup your shell environment.

As for this tutorial, all new commands to mount and unmount the file-system of your iPhone, will be installed in the sub-directory "${HOME}/usr/bin/".

Create the sub-directory to store the source files of the packages to be compiled:

$> mkdir -p "$HOME/usr/src"

Set all required environment variables to ensure to build the packages from source as desired:

$> export PKG_CONFIG_PATH="${HOME}/usr/lib/pkgconfig:${PKG_CONFIG_PATH}"
$> export CPATH="${HOME}/usr/include:${CPATH}"
$> export MANPATH="${HOME}/usr/share/man:${MANPATH}"
$> export PATH="${HOME}/usr/bin:${PATH}"
$> export LD_LIBRARY_PATH="${HOME}/usr/lib:${LD_LIBRARY_PATH}"

Make the path to your new tools permanent


It is recommended, to put the last two export statements into your .bashrc, to be loaded every time you open a new command shell, otherwise you must type

$> export PATH="${HOME}/usr/bin:${PATH}"
$> export LD_LIBRARY_PATH="${HOME}/usr/lib:${LD_LIBRARY_PATH}

in every newly opened command-shell to mount and unmount the file-system of your iPhone, because the first export is needed to find the new commands and the second is needed to load the correct run-time for the commands.

Clone all needed repositories from Github


$> cd ~/usr/src
$> for x in libplist libusbmuxd usbmuxd libimobiledevice ifuse; do git clone https://github.com/libimobiledevice/${x}.git;done

You should see something similar to the following output:

Cloning into 'libplist'...
remote: Counting objects: 3767, done.
remote: Total 3767 (delta 0), reused 0 (delta 0), pack-reused 3767
Receiving objects: 100% (3767/3767), 1.13 MiB | 727.00 KiB/s, done.
Resolving deltas: 100% (2304/2304), done.
Checking connectivity... done.
Cloning into 'libusbmuxd'...
remote: Counting objects: 382, done.
remote: Total 382 (delta 0), reused 0 (delta 0), pack-reused 382
Receiving objects: 100% (382/382), 123.94 KiB | 0 bytes/s, done.
Resolving deltas: 100% (209/209), done.
Checking connectivity... done.
Cloning into 'usbmuxd'...
remote: Counting objects: 1954, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 1954 (delta 0), reused 1 (delta 0), pack-reused 1949
Receiving objects: 100% (1954/1954), 604.44 KiB | 424.00 KiB/s, done.
Resolving deltas: 100% (1191/1191), done.
Checking connectivity... done.
Cloning into 'libimobiledevice'...
remote: Counting objects: 8095, done.
remote: Total 8095 (delta 0), reused 0 (delta 0), pack-reused 8095
Receiving objects: 100% (8095/8095), 2.47 MiB | 617.00 KiB/s, done.
Resolving deltas: 100% (5666/5666), done.
Checking connectivity... done.
Cloning into 'ifuse'...
remote: Counting objects: 499, done.
remote: Total 499 (delta 0), reused 0 (delta 0), pack-reused 499
Receiving objects: 100% (499/499), 92.37 KiB | 0 bytes/s, done.
Resolving deltas: 100% (242/242), done.
Checking connectivity... done.

Additionally to the original manual [1], I also had to compile libplist from source.

Build and install the packages in the following order


Build libplist


$> cd ~/usr/src/libplist
$> ./autogen.sh --prefix="$HOME/usr"
$> make && make install

Build libusbmuxd


$> cd ~/usr/src/libusbmuxd
$> ./autogen.sh --prefix="$HOME/usr"
$> make && make install

Build libimobiledevice


$> cd ~/usr/src/libimobiledevice
$> ./autogen.sh --prefix="$HOME/usr"
$> make && make install

Build usbmuxd


The package usbmuxd must be installed with administrative rights, because it needs write access to "/lib/udev/rules.d" and "/lib/systemd/system".

$> cd ~/usr/src/usbmuxd
$> ./autogen.sh --prefix="$HOME/usr"
$> make && sudo make install

Build ifuse


$> cd ~/usr/src/ifuse
$> ./autogen.sh --prefix="$HOME/usr"
$> make && make install

Test if everything works


It's assumed that you put the two exports into your ~/.bashrc as mentioned above.
Open a new bash command-shell.

Connect your iPhone


Create a mount point, where you want the content of your iPhone to appear.

$> mkdir -p ~/usr/mnt

Check which command executable will used, just in case you also have libimobiledevice additionally installed from the Mint repository, to avoid confusion.

$> type -p ifuse

/home/csch/usr/bin/ifuse

$> type -p idevicepair

/home/csch/usr/bin/idevicepair

Pair your iPhone with your computer


Now, grab your lightning-usb-cable and connect your iPhone to the computer.
Try to pair the iPhone with your computer.

$> idevicepair pair

ERROR: Could not validate with device 45ad6a77ae03f2d03f14a68fae178e45e70e7a04 because a passcode is set. Please enter the passcode on the device and retry.

Ooops, what's that? What happened? Again...

$> idevicepair pair

No, worry ... the ERROR just tell you that you forgot to confirm that you trust the connected computer on your phone, by entering your PIN on your phone and accept the trustworthy question.

cschmidt@pippin:~/usr/src/ifuse$ idevicepair pair
ERROR: Please accept the trust dialog on the screen of device 45ad6a77ae03f2d03f14a68fae178e45e70e7a04, then attempt to pair again.

After doing so, you finally can mount your iPhone (All good things come by in threes, therefore again)

$> idevicepair pair

SUCCESS: Paired with device 45ad6a77ae03f2d03f14a68fae178e45e70e7a04

Mount the file-system of your iPhone and check the content


Finally, mount the file-system of your phone.

$> ifuse ~/usr/mnt/
$> ls ~/usr/mnt/

AirFair com.apple.itunes.lock_sync iTunes_Control Photos Radio
Books DCIM MediaAnalysis PublicStaging Recordings
CloudAssets Downloads PhotoData Purchases Safari

Unmount and disconnect


To safely disconnect your iPhone, you have to unmount the file-system in ~/usr/mnt first with fusermount.

$> fusermount -u ~/usr/mnt

Now, you can plug-off your iPhone again.

References:

  1. gist: samrocketman/libimobiledevice_ifuse_Ubuntu.md
  2. Github repository https://github.com/libimobiledevice/
  3. type command reference


Thursday, April 16, 2015

Install Bash-Shell in favour of Ash-Shell on your Synology

Objective


I wanted to use the bash-shell on my Synology DS209+II. There are no official packages from Synology provided, but I knew there is a way to install custom and optional packages via ipkg.

Motivation


As my Synology is mostly running 24/7, I wanted establish a custom download-script which is started and stopped as a cron-job at certain periods of time. The script itself uses some commands relying on a bash-shell, but the Synology default command shell is just the less powerful ash-shell.


Prerequisites



Solution


Open a ssh-connection to your Synology


Log into your Synology as root using ssh (e.g "ssh -l root DiskStation").

Install the Bash-Shell-Package:

DiskStation$> ipkg install -A bash

You should see something like this:

DiskStation> ipkg install bash
Installing bash (3.2.54-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/bash_3.2.54-1_powerpc.ipk
Installing readline (6.1-2) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/readline_6.1-2_powerpc.ipk
Installing ncurses (5.7-3) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/ncurses_5.7-3_powerpc.ipk
Configuring bash
Configuring ncurses
update-alternatives: Linking //opt/bin/clear to /opt/bin/ncurses-clear
Configuring readline
Successfully terminated.

Now, Bash-Shell is installed, but when you log into your Synology it's not yet automatically started. You are still with Ash-Shell.

Activate automatic log-in with Bash


You could exchange the shell type for log-in in your /etc/passwd on your Synology, by exchanging the line (here it's done for user: root):

root:x:0:0:root:/root:/bin/ash

by

root:x:0:0:root:/root:/bin/bash

Unfortunatelly doing so, has the disadvantage, that you might loose the ability to log into your Synology at all from remote after an upgrade of your Firmware. Because optional packages like Bash are installed into /opt may be inavailable after a system-update. To prevent this accidental lock-out, it's preferred to continue to log-in with Ash-Shell, but start Bash automatically at once after you're successfully logged in.

To achive this you have to create/edit the file .profile in the homeaccount of the user the should be able to log-in on your Synology. Go to your homeaccount (e.g. /root/ for the user: root) and type the following as the proper user on you Synology:

DiskStation$> vi .profile

If the file has content, just add this lines to it:

# ...

if [[ -x /opt/bin/bash ]]; then
    exec /opt/bin/bash
fi

That's it. Next time, when root logs into your Synology, he is on a Bash-Shell.

Refine Configuration


If you want to use a different command prompt or to have some alias-commands, or at least the proper shell name in your "SHELL" environment variable, it's advisable also to create a .bashrc in the homeaccount, with the following example content (feel free to alter it to your convenience):

DiskStation$> vi .bashrc

PS1='\u@\h:\w \$ '
export SHELL=/opt/bin/bash

The first line gives you a nice bash prompt. The second explicitly sets the "SHELL" variable to your correct shell.

If you want also other scripts automatically using Bash instead of Ash, additionally create a symbolic link to it in /bin/:

DiskStation$> ln -s /opt/bin/bash /bin/bash

ADVICE: Keep a separate root shell window open until you have confirmed all of the changes work.

Sunday, April 12, 2015

Prepare your Synology NAS to install custom packages via ipkg

Objective


I wanted to use the bash-shell and a newer wget on my Synology DS209+II. There are no official packages from Synology provided, but I knew there is a way to install custom and optional packages via ipkg. Unfortunatelly ipkg must be so called bootstrapped, because it is already a custom package itself.

Motivation


As my Synology is mostly running 24/7, I wanted establish a custom download-script which is started and stopped as a cron-job at certain periods of time. The script itself uses some commands relying on a bash-shell, but the Synology default command shell is just the less powerful ash-shell. Also some of the wget-options I use in that script seem to be broken in the version of wget that my Synology has installed.

Prerequisites


  • DS209+II
  • Proper bootstrap script for your Synology NAS

Solution


Download the proper boostrap script


First you have to find out which processor is used on your specific Synology NAS.

Log into your Synology as root using ssh (e.g "ssh -l root DiskStation") and type the following command:

DiskStation$> cat /proc/cpuinfo

Doing so on my DS209+II printed the following information:

processor : 0
cpu : e500v2
clock : 1066.560000MHz
revision : 2.2 (pvr 8021 0022)
bogomips : 133.32
timebase : 66660000
platform : MPC8544 DS
model : MPC8544DS
Vendor : Freescale Semiconductor
PVR : 0x80210022
SVR : 0x80340011
PLL setting : 0x4
Memory : 512 MB
Memory : 512 MB

Now I know I have a Freescale PowerPC (e500v*), I can download the proper boostrap script here:

You can find a list of all bootstrap scripts here (column: "Optware-Pfad/IPKG"):
Processors used in Synology NAS Systems (German)

Now download the proper script and copy it to your Synology.

On the (still open) ssh connection "cd" into the folder where you stored the script and type (script name for your Synology type may differ!):

DiskStation$> sh syno-e500-bootstrap_1.2-7_powerpc.xsh

After you hit enter and you see something like this:

Optware Bootstrap for syno-e500.
Extracting archive... please wait
bootstrap/
bootstrap/bootstrap.sh
bootstrap/ipkg-opt.ipk
bootstrap/ipkg.sh
bootstrap/optware-bootstrap.ipk
bootstrap/wget.ipk
1330+1 records in
1330+1 records out

you already have installed an older version of ipkg.

Now you first have to remove this version, before installing the new one.

Backup your old ipkg configuration (only if you already have ipkg on your system)


If you have already installed ipkg and other custom packages via ipkg then make a backup of the following folders on you Synology:

  • /volume1/@optware
  • /usr/lib/ipkg

then remove all existing optware packages:

DiskStation$> rm -rf /volume1/@optware && rm -rf /usr/lib/ipkg

Afterwards, you must *reboot your Synology* and then restart the bootstrap script.

Re-Install ipkg


Again, log-into your Synology via ssh as root and type:

DiskStation$> sh syno-e500-bootstrap_1.2-7_powerpc.xsh

Now you should see a full install log:

Optware Bootstrap for syno-e500.
Extracting archive... please wait
bootstrap/
bootstrap/bootstrap.sh
bootstrap/ipkg-opt.ipk
bootstrap/ipkg.sh
bootstrap/optware-bootstrap.ipk
bootstrap/wget.ipk
1330+1 records in
1330+1 records out
Creating temporary ipkg repository...
Installing optware-bootstrap package...
Unpacking optware-bootstrap.ipk...Done.
Configuring optware-bootstrap.ipk...Setting up ipkg arch-file
Done.
Installing ipkg...
Unpacking ipkg-opt.ipk...Done.
Configuring ipkg-opt.ipk...WARNING: can't open config file: /usr/syno/ssl/openssl.cnf
Done.
Removing temporary ipkg repository...
Installing wget...
Installing wget (1.12-2) to root...
Configuring wget
Successfully terminated.
Creating /opt/etc/ipkg/cross-feed.conf...
Setup complete.

Update your $PATH variable, so that the ipkg can be found after reboot.
Therefore open the file $HOME/.profile and edit the line with your PATH:

PATH=/opt/bin:/opt/sbin:[the content that was already there]

Finally it's recommended to update your ipkg-package to ensure to use the newest version:

DiskStation$> ipkg update

Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/Packages.gz
Inflating http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/Packages.gz
Updated list of available packages in /opt/lib/ipkg/lists/cross
Successfully terminated.

If you use "ipkg upgrade" instead of "ipkg update", also all already installed custom packages are upgraded, too.

Boostrap done. Now you can install optional packages via the ipkg command on your Synology.

References:

  1. https://www.naschenweng.info/2012/01/17/synology-dsm-4-0-beta-breaks-ipkg/

Saturday, March 7, 2015

Linux Mint: Install new kernel version and update Virtual Box kernel module

Objective


I want to install the latest Linux Kernel available for my system. I also want still to work with my already installed VirtualBox which needs to install a kernel module after a kernel switch.

Motivation


There was no real resaon behind my plans to install the Linux Kernel 3.17.1. I just thought it's time for an upgrade. My current kernel is 3.13.

Prerequisites


  • Linux Mint 17.1 Rebecca
  • Oracle VM VirtualBox Manager 4.3.24

Solution


Install the Linux Kernel packages


To check which kernel packages are currently available you can do a search like (filtered by version "3.17"):

$> apt-cache search linux- | grep 3.17

you'll see some output like this:

linux-headers-3.17.1-031701 - Header files related to Linux kernel version 3.17.1
linux-headers-3.17.1-031701-generic - Linux kernel headers for version 3.17.1 on 64 bit x86 SMP
linux-image-3.17.1-031701-generic - Linux kernel image for version 3.17.1 on 64 bit x86 SMP

For 64-Bit systems download the following packages ...

$> wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.1-utopic/linux-headers-3.17.1-031701_3.17.1-031701.201410150735_all.deb

$> wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.1-utopic/linux-headers-3.17.1-031701-generic_3.17.1-031701.201410150735_amd64.deb

$> wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.1-utopic/linux-image-3.17.1-031701-generic_3.17.1-031701.201410150735_amd64.deb

and for 32-Bit systems download the following ...

$> wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.1-utopic/linux-headers-3.17.1-031701_3.17.1-031701.201410150735_all.deb

$> wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.1-utopic/linux-headers-3.17.1-031701-generic_3.17.1-031701.201410150735_i386.deb

$> wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.1-utopic/linux-image-3.17.1-031701-generic_3.17.1-031701.201410150735_i386.deb

Now install the packages:

$> sudo dpkg -i linux-headers-3.17.1*.deb linux-image-3.17.1*.deb

Reboot the system.

$> sudo reboot

After a successful reboot, you can delete the *.deb packages again:

$> rm linux-*


Uninstall the Linux Kernel again (if you don't like it anymore)


You can uninstall the new kernel with the following command, be aware that this may make your system unusable.

$> sudo apt-get remove 'linux-headers-3.17.1*' 'linux-image-3.17.1*'

Setup the VirtualBox Kernel module


$> sudo /etc/init.d/vboxdrv setup

You'll see output similar to:

Stopping VirtualBox kernel modules ...done.
Uninstalling old VirtualBox DKMS kernel modules ...done.
Trying to register the VirtualBox kernel modules using DKMS ...done.
Starting VirtualBox kernel modules ...done.

Now you are done!

Linux Mint: Install and configure OpenSSH

Objective


It should be possible to log-into my new desktop computer from my laptop via ssh.

Motivation


Sometimes I want to run a script or program on my more powerful desktop computer, also while I am just sitting in front of my laptop. Furthermore I want to be able to configure my desktop computer from remote. To achive this I need to install and configure openssh inclusive X11 forwarding.

Prerequisites


  • Linux Mint 17.1 Rebecca
  • A second computer or laptop with a ssh-client e.g. putty installed

Solution


Install the OpenSSH packages


Open a terminal. Download and install the openssh server and client package:

$> sudo apt-get install openssh-server openssh-client

you'll see some output like this:

Reading package lists... Done
Building dependency tree
Reading state information... Done
openssh-client is already the newest version.
Suggested packages:
rssh molly-guard monkeysphere
Recommended packages:
ncurses-term ssh-import-id
The following NEW packages will be installed:
openssh-server openssh-sftp-server
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 354 kB of archives.
After this operation, 1.072 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ trusty-updates/main openssh-sftp-server amd64 1:6.6p1-2ubuntu2 [34,1 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty-updates/main openssh-server amd64 1:6.6p1-2ubuntu2 [319 kB]
Fetched 354 kB in 0s (781 kB/s)
Preconfiguring packages ...
Selecting previously unselected package openssh-sftp-server.
(Reading database ... 159066 files and directories currently installed.)
Preparing to unpack .../openssh-sftp-server_1%3a6.6p1-2ubuntu2_amd64.deb ...
Unpacking openssh-sftp-server (1:6.6p1-2ubuntu2) ...
Selecting previously unselected package openssh-server.
Preparing to unpack .../openssh-server_1%3a6.6p1-2ubuntu2_amd64.deb ...
Unpacking openssh-server (1:6.6p1-2ubuntu2) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
Processing triggers for ufw (0.34~rc-0ubuntu2) ...
Setting up openssh-sftp-server (1:6.6p1-2ubuntu2) ...
Setting up openssh-server (1:6.6p1-2ubuntu2) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Creating SSH2 ECDSA key; this may take some time ...
Creating SSH2 ED25519 key; this may take some time ...
ssh start/running, process 3190
Processing triggers for ureadahead (0.100.0-16) ...
Processing triggers for ufw (0.34~rc-0ubuntu2) ...

Configure OpenSSH


The default configuration for OpenSSh on Linux Mint Rebecca located at /etc/ssh/sshd_config should already work fine without any further adjustment. The only limitation is that yout cannot log in as root by default.

If you want to allow remote login as root, open a shell and edit /etc/ssh/sshd_config:
$> gksu gedit /etc/ssh/sshd_config

Now change the following line to:

PermitRootLogin yes

Now you are done and can do a test log-in.

Saturday, February 28, 2015

Linux Mint: Setup autofs to mount automatically NFS-shares from a Synology

Objective


I installed Linux Mint 17.1 Rebecca on a new computer and I want to access the NFS shares from my Synology Disk Station.

Motivation


As my Synology is not always running 24/7 it would be nice just to mount the NFS shares on my client computers on access and to avoid to integrate the shares statically in fstab. Integrating the shares in fstab would work, but I will always have to wait until a timeout is fullfilled while booting my computer, when the Synology is not running. I already set-up autofs for this "mount on demand" purpose on my laptop, which eves not always in the same network as my Synology.

Prerequisites


  • Linux Mint 17.1 Rebecca
  • DS209+II

Solution


Install the autofs package


Download and install the autofs package via the following command from a shell:

$> sudo apt-get install autofs

you'll see some output like this:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Recommended packages:
nfs-common
The following NEW packages will be installed:
autofs
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 281 kB of archives.
After this operation, 1.671 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ trusty-updates/main autofs amd64 5.0.7-3ubuntu3.1 [281 kB]
Fetched 281 kB in 0s (496 kB/s)
Selecting previously unselected package autofs.
(Reading database ... 158913 files and directories currently installed.)
Preparing to unpack .../autofs_5.0.7-3ubuntu3.1_amd64.deb ...
Unpacking autofs (5.0.7-3ubuntu3.1) ...
Processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up autofs (5.0.7-3ubuntu3.1) ...
Creating config file /etc/auto.master with new version
Creating config file /etc/auto.net with new version
Creating config file /etc/auto.misc with new version
Creating config file /etc/auto.smb with new version
Creating config file /etc/default/autofs with new version
autofs start/running, process 3481
Processing triggers for ureadahead (0.100.0-16) ...

Additionally install the nfs-common package, otherwise you won't be able to access the NFS shares.

$> sudo apt-get install nfs-common

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libgssglue1 libnfsidmap2 libtirpc1 rpcbind
Suggested packages:
open-iscsi watchdog
The following NEW packages will be installed:
libgssglue1 libnfsidmap2 libtirpc1 nfs-common rpcbind
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 342 kB of archives.
After this operation, 1.375 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main libgssglue1 amd64 0.4-2ubuntu1 [19,7 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty/main libnfsidmap2 amd64 0.25-5 [32,2 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ trusty/main libtirpc1 amd64 0.2.2-5ubuntu2 [71,3 kB]
Get:4 http://archive.ubuntu.com/ubuntu/ trusty-updates/main rpcbind amd64 0.2.1-2ubuntu2.1 [37,0 kB]
Get:5 http://archive.ubuntu.com/ubuntu/ trusty-updates/main nfs-common amd64 1:1.2.8-6ubuntu1.1 [182 kB]
Fetched 342 kB in 1s (288 kB/s)
Selecting previously unselected package libgssglue1:amd64.
(Reading database ... 158963 files and directories currently installed.)
Preparing to unpack .../libgssglue1_0.4-2ubuntu1_amd64.deb ...
Unpacking libgssglue1:amd64 (0.4-2ubuntu1) ...
Selecting previously unselected package libnfsidmap2:amd64.
Preparing to unpack .../libnfsidmap2_0.25-5_amd64.deb ...
Unpacking libnfsidmap2:amd64 (0.25-5) ...
Selecting previously unselected package libtirpc1:amd64.
Preparing to unpack .../libtirpc1_0.2.2-5ubuntu2_amd64.deb ...
Unpacking libtirpc1:amd64 (0.2.2-5ubuntu2) ...
Selecting previously unselected package rpcbind.
Preparing to unpack .../rpcbind_0.2.1-2ubuntu2.1_amd64.deb ...
Unpacking rpcbind (0.2.1-2ubuntu2.1) ...
Selecting previously unselected package nfs-common.
Preparing to unpack .../nfs-common_1%3a1.2.8-6ubuntu1.1_amd64.deb ...
Unpacking nfs-common (1:1.2.8-6ubuntu1.1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Setting up libgssglue1:amd64 (0.4-2ubuntu1) ...
Setting up libnfsidmap2:amd64 (0.25-5) ...
Setting up libtirpc1:amd64 (0.2.2-5ubuntu2) ...
Setting up rpcbind (0.2.1-2ubuntu2.1) ...
Removing any system startup links for /etc/init.d/rpcbind ...
rpcbind start/running, process 5972
Processing triggers for ureadahead (0.100.0-16) ...
Setting up nfs-common (1:1.2.8-6ubuntu1.1) ...
Creating config file /etc/idmapd.conf with new version
Creating config file /etc/default/nfs-common with new version
Adding system user `statd' (UID 115) ...
Adding new user `statd' (UID 115) with group `nogroup' ...
Not creating home directory `/var/lib/nfs'.
statd start/running, process 6205
gssd stop/pre-start, process 6239
idmapd start/running, process 6286
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
Processing triggers for ureadahead (0.100.0-16) ...

Configure autofs


First create the destination directory where you want to mount the directories of your NFS server into. In my case this is below /mnt/DiskStation


$> sudo mkdir -p /mnt/DiskStation

Now add your exported NFS-Shares root-directory from your server to the "/etc/auto.master":

/mnt/DiskStation /etc/auto.nfs

$> gksu gedit /etc/auto.master

#
# Sample auto.master file
#
# ...
#
#/misc /etc/auto.misc
#/net -hosts
#
# Include /etc/auto.master.d/*.autofs
#
+dir:/etc/auto.master.d
#
# Include central master map if it can be found using
# nsswitch sources.
#
# ...
#
+auto.master
/mnt/DiskStation /etc/auto.nfs

Create a "/etc/auto.nfs" with the following content (where "192.168.0.99" is the IP of your Synology and "data" is the name of the exported directory):
data 192.168.0.99:/volume1/data

Finally restart autofs

$> sudo service autofs restart

autofs stop/waiting
autofs start/running, process 4084

Done. Now you should be able to access the files from your Synology at /mnt/DiskStation/data.


More information on autofs can be found here.

Linux Mint: Move your home-directory into a separate partition after installation

Objective


I installed Linux Mint 17.1 Rebecca on new computer with a SSD with the Mint Installer default partitioning scheme, which mounts /boot, /root and /home into the same partition.

Motivation


I decided to have my home-directory in a separate partition which I can mount into /home to make leter upgrading the system a little more painless.

Prerequisites


  • Linux Mint 17.1 Rebecca
  • 512 GB SSD

Solution


Create a new partition


Resize your system partition and create a new partition in the free space. Follow this guide to see how you can resize Ubuntu partitions to complete this step.

Copy the home files into the new partition


Open a terminal and run the following command to create a copy of your current /home directory on the new partition, where /media/HOME is the location of your newly mounted partition (I gave it the LABEL=HOME during the creation process) where the new /home should reside:

$> sudo cp -Rp /home/* /media/HOME

You should check if everything went fine to avoid to loose data:

$> ls /media/HOME

In my case I got:

csch data lost+found

Determine the UUID of the newly created partition


Use the following command to get the UUID of your new home-partition:

$> sudo blkid

In my case I got (you can see the label HOME again here)

...
/dev/sda2: UUID="f270b74b-ce14-4481-bf32-1226b4fd776e" TYPE="ext4"
/dev/sda3: LABEL="HOME" UUID="a9c81163-f588-462a-89b0-dbdad87cef9c" TYPE="ext4"
/dev/sda6: UUID="023cf9e6-199f-475c-9fe1-c70b73d3047c" TYPE="swap"
...

Adapt your mount table in fstab to mount the new partition into "/home"


Make a backup of your current fstab (with a timestamp):

$> sudo cp /etc/fstab /etc/fstab.$(date +%Y-%m-%d)_backup

and edit the original fstab:

$>gksu gedit /etc/fstab

Add this line to your fstab and save the file (replace xxxxx with your UUID):

...
# (identifier) (location) (format, eg ext3 or ext4) (some settings)
UUID=xxxxx /home ext4 nodev,nosuid 0 2

Move home-directory into a backup and create a new mount-directory


$> cd / && sudo mv /home /old_home && sudo mkdir /home

Now you're done, finally reboot and prey!

$> sudo shutdown -r now

After your system is up again, you can savely clean-up the system:

$> sudo rm -rf /home_old

Remark

Additional info on how to deal with separate home-partitions can be found here.

Saturday, December 20, 2014

Linux Mint: Install Xbian on Raspberry Pi

Objective


The following decription explains how to install a Xbian image on a SDCard to run on your Raspberry Pi. The installation is done on Linux.

Motivation


Recently, I bought a Raspberry Pi and wanted to connect to my TV to watch movies stored on my NAS via Wifi connection or Youtube videos.

Prerequisites


  • Linux Mint 17 Qiana
  • Raspberry Pi B model (both 512 MB and 256 MB version are supported)
  • 2 GB (or bigger) SD card
  • Power adapter for your Raspbery Pi
  • Something to play your media from (USB disk or network share)
  • Remote, for example your TV remote (if your TV supports CEC), smartphone (XBMC Remote app), infrared remote, keyboard/mouse
  • Computer with a SD card reader for installing XBian on your SD card
  • Ethernet cable or WiFi dongle for your Raspberry Pi

Solution


Preparation of the Xbian image file


Go to the XBian images download section and select the newest XBian image for your download. In my case this was the XBian 1.0 Release Candidate 3.

Open a command shell and go (via 'cd' command) to the folder where you downloaded the image file.

Uncompress the image by the command:

$> gunzip XBian_1.0_RC_3_Raspberry_Pi.img.gz

Preparation of the SDCard


Insert your SDCard into the SDCard slot of your computer. The card usually will be automatically mounted and integrated into the filesystem of your computer. If this is not the case, you can also mout ist via the shell command:

$> sudo mount -t vfat -o ro /dev/mmcblk0p1 /media/mmcblk0p1

The mmcblk0p1 here is the device identifier for your SDCard and may vary in your case. To determine the device identifier, you can use the command:

$> sudo fdisk -l

you will get a result similar to mine:

Disk /dev/sda: 640.1 GB, 640135028736 bytes

<skip the info of the harddisk>

Disk /dev/mmcblk0: 15.9 GB, 15931539456 bytes
4 Köpfe, 16 Sektoren/Spur, 486192 Zylinder, zusammen 31116288 Sektoren
Einheiten = Sektoren von 1 × 512 = 512 Bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Festplattenidentifikation: 0x0009be7b

Gerät boot. Anfang Ende Blöcke Id System
/dev/mmcblk0p1 2048 31116287 15557120 b W95 FAT32

Copy the downloaded image onto the SDCard:

$> sudo dd if=XBian_1.0_RC_3_Raspberry_Pi.img of=/dev/mmcblk0

The copying procedure takes some minutes, so be patient...

The final output after a successful copy will be something like:

1135488+0 Datensätze ein
1135488+0 Datensätze aus
581369856 Bytes (581 MB) kopiert, 366,661 s, 1,6 MB/s

Setup done!
Now you can remove the SDCard from your computer an put it into your Raspberry Pi and restart the Pi.

Upgrade your Qt-Installation to Qt 5.4 by a clean re-install

Objective


I wanted to upgrade my Qt 5.3.1 to new the newly released version Qt 5.4.0 by a clean re-install.
My last install was done by executing the installer script ./qt-opensource-linux-x64-5.3.1.run.
So I asked myself, how to clearly uninstall an old Qt-Version.

Motivation


I noticed that I'll run out of disk-space soon on my system disk, therefore I decided to uninstall the old version, before I wanted to install the new version. Additionally, I wanted to install QtCreator 3.3 which correlates to Qt 5.4.0.

Prerequisites


Linux Mint: 17 - Qiana
Qt-Installer Script: Qt-opensource-linux-x64-5.4.0.run

Solution


Download the installer script


1. Go to the Qt-Homepage: qt-project.org
2. Download the installer script ./qt-opensource-linux-x64-5.4.0.run
It is not necessary to download the Qt-Creator installer script, because Qt-Creator 3.3 is included by the Qt-Installer script.

Uninstall the old version (in my case: Qt 5.3.1)


1. Open a Terminal window.

2. Login as root:

$ su -

3. Navigate to the folder where you installed the older version of Qt (in my case "/opt/Qt5.3.1":

$ cd /opt/Qt5.3.1

4. Start the MaintenanceTool

$ ./MaintenanceTool

5. Choose Remove from the options od the shown dialog.

Install Qt 5.4.0


1. Within the same shell (root-shell), go to the folder where you downloaded the installer script qt-opensource-linux-x64-5.4.0.run and type:

$ chmod ugo+x qt-opensource-linux-x64-5.4.0.run
$ ./qt-opensource-linux-x64-5.4.0.run

2. Follow the instructions of the graphical installer.

Done.

Saturday, November 16, 2013

Linux Mint - Mate Desktop: Configure transmission-gtk to handle magnet-links in Google Chrome

Objective


The goal of this tutorial is to make Google Chrome to automatically to start transmission-gtk when you click on a magnet-link within your browser.

Motivation


I was using Firefox (and previously the Mozilla Suite) as my favorite Webbrowser for nearly everthing (on Linux, Window and Mac). Recently I experimented with Google Chrome and figured out that it's also a nice alternative to Firefox and in many cases much faster. But one of the drawbacks I encountered on Linux was, that it seems to handle foreign or unknown protocols differently than Firefox. It merely relies on "xdg-open", which is not always configured correctly, for any desktop environments, as in my case.

Prerequisites


Linux Mint 15 - Olivia
Desktop - MATE 1.6
Google Chrome (v31.0.1650.57)
transmission-gtk (v2.77-14031)
xdg-open (v1.0.2)

It might be that the problem occurs also with other Distributions and Versions, but the above is just my current environment.

Solution


Reproduce the problem


1. Start Google Chrome
2. Navigate to an internet site that provides a magnet-link
3. Click on the link
4. If Google Chrome opens just another window or tab, you face the problem

Solve the problem


In contrary to Firefox which handles all the management of external protocol-handlers itself, Google Chrome relies on the underlying system. In this particular environment it's the "xdg-open" script. Unfortunatelly this script does not support MATE a native Desktop environment and therefore calls the "general-handler" for urls which seems to be Google Chrome itself.

In this solution, we establish the external app "transmission-gtk" the to handle magnet-links within Google-Chrome.

1.
Check where the "transmission-gtk.desktop" file can be found. E.g. use the command "locate transmission-gtk.desktop". In my case it's located in "/usr/share/applications/".

2.
Now check the content, by opening the file with an editor of your choice. Be sure that you find the statements

Exec=transmission-gtk %U

and

MimeType=application/x-bittorrent;x-scheme-handler/magnet;

in the file. Ensure that the first statement contains "%U", because this the placeholder for the concrete URL passed through by Google Chrome.

3.
Configure your system that "transmission-gtk" is the default handler for magnet-links by executing the following command in your shell:

$ xdg-mime default transmission-gtk.desktop x-scheme-handler/magnet

4.
Enable "xdg-open" to recognize your MATE desktop as a Gnome Desktop, because it has the same ancestor and therefore is compatible to Gnome, but not recognized in the "xdg-open" script, because of the different name.

For this step you need root permission, so be careful what you are doing.
Locate the xdg-open script in your system: "which xdg-open". In my case this leads to "/usr/bin/xdg-open".
Open the file as root (again with your editor of choice) e.g. "sudo vi /usr/bin/xdg-open".
Search for a section (Note: The following part is just hack and not a solid solution):

if [ x"$DE" = x"" ]; then
    DE=generic
fi

and change it to

if [ x"$DE" = x"" ]; then
    DE=gnome
fi

Now, save the file.

5.
Restart Gnome and retry to reproduce the problem. It should be gone now and transmission-gtk should be opened to handle magnet-links instead of Google Chrome.