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

Thursday, July 11, 2019

Windows 10: Compile the Lua interpreter from source and install it for the local user

Objective


Compile the latest version of the Lua language interpreter from source (in this case version 5.3.5). Build a locally installed Lua interpreter for the current user only, in order to have the possibility to safely remove it when necessary.

Motivation


As I already mentioned in my previous post "Linux Mint: Compile the Lua interpreter from source and build your own Debian package to install it", I wanted to have a scripting language that smoothly can be integrated and combined with C++. I figured that Lua would be very handy for that job. This time, I didn't just want to have the language interpreter build for my main operating system, which is Linux Mint, but also for Windows 10. I wanted to have the installation build from the same sources for both operating systems. This article describes the process to get a local portable installation of the Lua interpreter on per user basis. It tries to describe how to compile your own Lua interpreter on Windows 10 using the (command line interface) CLI compiler from Microsoft e.g. Visual Studio 2019 Community Edition.

Prerequisites


  • Windows 10 (64 Bit)
  • Microsoft Visual Studio 2019

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 that "tmp" folder.

Get the latest source of the Lua interpreter from their homepage


Open a cmd shell, by right-clicking the Windows icon in the lower-left corner of your screen. Select "Run" from the context-menu and type "cmd".
You should get a command shell, where the current directory is already your home-directory, but to be sure, navigate to that location and create the sub-directories "tmp\lua" by typing:

$> cd %HOMEDRIVE%\%HOMEPATH%
$> mkdir tmp\lua
$> cd tmp\lua

To see, where "%HOMEDRIVE%\%HOMEPATH%" is pointing to, type in your cmd-shell:

$> echo %HOMEDRIVE%\%HOMEPATH%

C:\Users\cschmidt>

Now, open your preferred browser and navigate to the Lua FTP download page. Download the latest version of thte source code, and save it in your home-directory under the newly created folder "%HOMEDRIVE%\%HOMEPATH%\tmp\lua". Im my case the current source package of Lua was "lua-5.3.5.tar.gz".

Now you have to unpack the newly downloaded package "lua-5.3.5.tar.gz" into the "tmp\lua" folder. I am not sure if the standard Window 10 unzip mechanism is able to unpack archives packed by "*.tar.gz" compression, which usually is used on *nix-like systems e.g. Linux. I recommend to install an archive manager like 7-Zip anyway.

Once you have successfully unpacked the "lua-5.3.5.tar.gz" source code package, you should get an additional directory named "lua-5.3.5" within your "tmp\lua" folder. If you just have an intermediate file called "lua-5.3.5.tar", you have to unpack that file again.

$> dir

Directory of C:\Users\cschmidt\tmp\lua

11.07.2019 14:19 <DIR> .
11.07.2019 14:19 <DIR> ..
26.06.2018 18:21 <DIR> lua-5.3.5
21.06.2019 15:11 303.543 lua-5.3.5.tar.gz
1 File(s) 303.543 bytes
3 Dir(s) 160.112.115.712 bytes free

Everything from the source code package will be unpacked into the sub-directory "lua-5.3.5"
To see, what we got, type:

$> cd lua-5.3.5
$> dir /s

Volume in drive C has no label.
Volume Serial Number is 62D3-5614

Directory of C:\Users\cschmidt\tmp\lua\lua-5.3.5

[...]

Directory of C:\Users\cschmidt\tmp\lua\lua-5.3.5\doc

[...]

Directory of C:\Users\cschmidt\tmp\lua\lua-5.3.5\src

11.07.2019 14:53 <DIR> .
11.07.2019 14:53 <DIR> ..
06.12.2017 20:35 31.352 lapi.c
19.04.2017 19:20 545 lapi.h
19.04.2017 19:20 30.495 lauxlib.c
19.04.2017 19:20 8.632 lauxlib.h
[...]
19.04.2017 19:20 1.305 lualib.h
19.04.2017 19:20 6.179 lundump.c
19.04.2017 19:20 803 lundump.h
19.04.2017 19:29 7.075 lutf8lib.c
19.04.2017 19:39 44.393 lvm.c
19.04.2017 19:20 3.685 lvm.h
19.04.2017 19:20 1.365 lzio.c
19.04.2017 19:20 1.481 lzio.h
25.06.2018 19:46 6.911 Makefile
63 File(s) 694.458 bytes

Total Files Listed:
75 File(s) 1.088.257 bytes
8 Dir(s) 160.102.793.216 bytes free

Compile the Lua interpreter from the sources


In order to compile the Lua interpreters source code, we need a compiler. I assume that you have already a "Visual Studio 2019" (Community Edition will be sufficient) or similar installed.

We now need a new command shell with the compiler tool chain set up. The easiest way, to get this "special" shell, is to start up Visual Studio and launch the command shell from the menu:
"Tools --> Visual Studio Command Prompt"

In that shell, navigate again to our source code folder:

$> cd %HOMEDRIVE%\%HOMEPATH%\tmp\lua\lua-5.3.5\src

To compile the source, type:

$> cl /MD /O2 /c /DLUA_BUILD_AS_DLL *.c
$> ren lua.obj lua.o
$> ren luac.obj luac.o
$> link /DLL /IMPLIB:lua5.3.5.lib /OUT:lua5.3.5.dll *.obj
$> link /OUT:lua.exe lua.o lua5.3.5.lib
$> lib /OUT:lua5.3.5-static.lib *.obj
$> link /OUT:luac.exe luac.o lua5.3.5-static.lib

Alternatively, you can put all the instructions in a file named "buildLua5.3.5.bat" and just execute that file:

cl /MD /O2 /c /DLUA_BUILD_AS_DLL *.c
ren lua.obj lua.o
ren luac.obj luac.o
link /DLL /IMPLIB:lua5.3.5.lib /OUT:lua5.3.5.dll *.obj
link /OUT:lua.exe lua.o lua5.3.5.lib
lib /OUT:lua5.3.5-static.lib *.obj
link /OUT:luac.exe luac.o lua5.3.5-static.lib

$> buildLua5.3.5.bat

C:\Users\cschmidt\tmp\lua\lua-5.3.5\src>cl /MD /O2 /c /DLUA_BUILD_AS_DLL *.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.21.27702.2 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

lapi.c
lauxlib.c
lbaselib.c
lbitlib.c
[...]
lua.c
luac.c
lundump.c
lutf8lib.c
lvm.c
lzio.c
Generating Code...

C:\Users\cschmidt\tmp\lua\lua-5.3.5\src>ren lua.obj lua.o

C:\Users\cschmidt\tmp\lua\lua-5.3.5\src>ren luac.obj luac.o

C:\Users\cschmidt\tmp\lua\lua-5.3.5\src>link /DLL /IMPLIB:lua5.3.5.lib /OUT:lua5.3.5.dll *.obj
Microsoft (R) Incremental Linker Version 14.21.27702.2
Copyright (C) Microsoft Corporation. All rights reserved.

Creating library lua5.3.5.lib and object lua5.3.5.exp

C:\Users\cschmidt\tmp\lua\lua-5.3.5\src>link /OUT:lua.exe lua.o lua5.3.5.lib
Microsoft (R) Incremental Linker Version 14.21.27702.2
Copyright (C) Microsoft Corporation. All rights reserved.


C:\Users\cschmidt\tmp\lua\lua-5.3.5\src>lib /OUT:lua5.3.5-static.lib *.obj
Microsoft (R) Library Manager Version 14.21.27702.2
Copyright (C) Microsoft Corporation. All rights reserved.


C:\Users\cschmidt\tmp\lua\lua-5.3.5\src>link /OUT:luac.exe luac.o lua5.3.5-static.lib
Microsoft (R) Incremental Linker Version 14.21.27702.2
Copyright (C) Microsoft Corporation. All rights reserved.

Creating library luac.lib and object luac.exp

Fine, everything is build locally into the current folder "src". If we want to use the result of this compilation, we can just move everything we need to a folder called "lua" in our home-directory:

$> mkdir %HOMEDRIVE%\%HOMEPATH%\lua
$> copy *.dll %HOMEDRIVE%\%HOMEPATH%\lua\
$> copy *.h %HOMEDRIVE%\%HOMEPATH%\lua\
$> copy *.hpp %HOMEDRIVE%\%HOMEPATH%\lua\
$> copy *.exp %HOMEDRIVE%\%HOMEPATH%\lua\
$> copy *.lib %HOMEDRIVE%\%HOMEPATH%\lua\
$> copy *.exe %HOMEDRIVE%\%HOMEPATH%\lua\

Finally we need to expand the "PATH" environment variable (in the system-settings) by that location to the Lua interpreter binary.


After doing so, we open a new command shell, as described at the beginning of this article, in order to test if everything is working:

$> lua

> Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio

To exit the interpreter, just type "CTRL-C".

Fine! Now, we can safely delete the folder "tmp\lua".

References:

  1. Lua homepage
  2. How to compile Lua 5.3.0 for Windows

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


Sunday, December 4, 2016

Blogger: Host "SyntaxHighlighter" on GitHub-Pages

Objective


I would like to host my "SyntaxHighlighter" on Github-Pages to make it easy to format my source-code on my blog on Blogger. This is needed, because the original hosting service of Google-Drive is not working anymore..

Motivation


In a comment, a reader of my blog made me aware, that the syntax highlighting for source-code stopped working a while ago. So I investigated into the issue and found out that unfortunately Google stopped web-hosting of pages via Google-Drive.

Google deprecated web-hosting support in Google-Drive as of 31. August 2015 (Reference: https://gsuiteupdates.googleblog.com/2015/08/deprecating-web-hosting-support-in.html).
However, the web-hosting via Google-Drive stopped working only a year later as of 31. August 2016.

I did neither want to move on to Google Domains nor to the Google Cloud Platform,because both services are not free, so I decided to give Github-Pages a try.

Prerequisites



Setup your Hosting of SyntaxHighlighter on Github-Pages


Prepare your local repository


Follow the instructions in to get the sources for SyntaxHighlighter.

Create a directory for your new repository named e.g. syntaxhighlighter-pages/docs:
$> mkdir -p syntaxhighlighter-pages/docs
$> cd syntaxhighlighter-pages
$> git init

Initialized empty Git repository in /home/cschmidt/syntaxhighlighter-pages/.git/

Assuming your SyntaxHighlighter files are at the some location as your syntaxhighlighter-pages folder, copy all the source files your need to be hosted into your docs folder:

$> cd docs
$> cp -r ../../syntaxhighlighter_3.0.83/scripts .
$> cp -r ../../syntaxhighlighter_3.0.83/styles .
$> git add *
$> git commit -m "hosted syntaxhighlighter files"

[master (root-commit) 3556ca1] hosted syntaxhighlighter files
45 files changed, 5483 insertions(+)
create mode 100644 docs/scripts/shAutoloader.js
create mode 100644 docs/scripts/shBrushAS3.js
create mode 100644 docs/scripts/shBrushAppleScript.js
create mode 100644 docs/scripts/shBrushBash.js
...
create mode 100644 docs/styles/shThemeEmacs.css
create mode 100644 docs/styles/shThemeFadeToGrey.css
create mode 100755 docs/styles/shThemeMDUltra.css
create mode 100644 docs/styles/shThemeMidnight.css
create mode 100644 docs/styles/shThemeRDark.css

Finally push your local repository to your github:

$> cd ..
$> git remote add origin https://github.com/cwschmidt/syntaxhighlighter-pages.git
$> git push -u origin master

Counting objects: 50, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (49/49), done.
Writing objects: 100% (50/50), 47.03 KiB | 0 bytes/s, done.
Total 50 (delta 24), reused 0 (delta 0)
remote: Resolving deltas: 100% (24/24), done.
To https://github.com/cwschmidt/syntaxhighlighter-pages_.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.


Prepare your github repository


Now log into your github account and create a new repository named "syntaxhighlighter-pages". Herefore click on the "+" on the upper-right corner of the Github webpage.



Fill in the name of the repository and make it "public" as shown below (didn't test, whether publiching pages also works with "private" ones):



Select the actual created repository and go to the settings tab shown below.
Scroll down until you reach the section "Github Pages". From the combo-box where "None" is selected right now, select "master branch /docs folder".



Click "Save" and after some seconds, your pages are successfully published:




Prepare your template to support code formatting


Go to your Blogger's blog online editor and choose "Template" from the menu at the left.




Click on "Edit HTML".

Within the code search for the closing head-tag

</b:template-skin>
    <b:include data='blog' name='google-analytics'/>
  </head>

  <body expr:class='&quot;loading&quot; + data:blog.mobileClass'>
  <b:section class='navbar' id='navbar' maxwidgets='1' name='Navbar' showaddelement='no'>

And copy the following code (only the links to the files you prepared for hosting) right before the end head-tag

<!-- Begin SyntaxHighlighter-->
    <link href='https://<username>.github.io/syntaxhighlighter-pages/styles/shCore.css' rel='stylesheet' type='text/css'/> 
    <link href='https://<username>.github.io/syntaxhighlighter-pages/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shCore.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushCpp.js' type='text/javascript'/> 
    <!--script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushCpp.js' type='text/javascript'/--> 
    <!--script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushCSharp.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushCss.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/shBrushJava.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushJScript.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushPhp.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushPython.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushRuby.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushSql.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushVb.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushXml.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushPerl.js' type='text/javascript'/--> 
    <script type='text/javascript'>
    window.setTimeout(function() {
        SyntaxHighlighter.config.bloggerMode = true;
        SyntaxHighlighter.all();
    }, 20);
    </script>
<!-- End SyntaxHighlighter-->
</head>

Exchange the "<username>" within the URL with your own username on Github.


Test it


For Testing go back to my blog post Blogger: Setup "SyntaxHighlighter" for your blog - Test it

References:

  1. http://alexgorbatchev.com/SyntaxHighlighter/
  2. Github-Pages
  3. Blogger: Setup "SyntaxHighlighter" for your blog