Category Archives: Ubuntu

Git: Staging Area aka “index”

  • Working Tree
  • Index / Stage / Staging Area / Cache
  • Repository

The Staging Area (also called the “index”) is where Git remembers which changes are marked to be committed. If a change is not “staged” it will not be committed. A change can be as granular as a single changed line in a file, leading to very precise commits. If, after staging a change, you decide you don’t want that change to go into the next commit, you can also “unstage” it.

Stage file: $ git add
Unstage file: $ git reset HEAD

Git Basics – Undoing Things

Removing untracked files from your git working copy
$ git clean -f

git-clean
Removing untracked files from your git working copy

Ubuntu: Add new PPA (Personal Package Archive) repository

PPA = Personal Package Archives
Repository = A collection of software you can download quickly and easily.

Personal Package Archives for everyone!

Add Repository

$ sudo add-apt-repository ppa:vala-team
$ sudo add-apt-repository ppa:irie/blender   ==>   https://launchpad.net/~irie/+archive/blender
$ sudo apt-get update
$ sudo apt-get install [...]

Remove Repository

$ sudo add-apt-repository --remove ppa:vala-team

How can PPAs be removed?

Show current version of package

$ apt-cache policy blender
blender:
  Installed: 2.66a-3ubuntu2
  Candidate: 2.70+git201403201745.dfa5ced-0irie1~saucy1
  Version table:
     2.70+git201403201745.dfa5ced-0irie1~saucy1 0
        500 http://ppa.launchpad.net/irie/blender/ubuntu/ saucy/main i386 Packages
 *** 2.66a-3ubuntu2 0
        500 http://mirror.switch.ch/ftp/mirror/ubuntu/ saucy/universe i386 Packages
        100 /var/lib/dpkg/status

How to check the version before install packages using apt-get
Check package version using apt-get/aptitude?

GNOME tools: gnome-common, intltool

$ sudo apt-get install gnome-common
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  autopoint intltool
The following NEW packages will be installed:
  autopoint gnome-common intltool
0 upgraded, 3 newly installed, 0 to remove and 1163 not upgraded.
Need to get 673 kB of archives.
After this operation, 1,127 kB of additional disk space will be used.
Do you want to continue [Y/n]? y

$ sudo apt-get install gtk-doc-tools
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  docbook docbook-dsssl docbook-to-man jade libsp1c2 sp
Suggested packages:
  docbook-defguide psgml jadetex docbook-dsssl-doc
The following NEW packages will be installed:
  docbook docbook-dsssl docbook-to-man gtk-doc-tools jade libsp1c2 sp
0 upgraded, 7 newly installed, 0 to remove and 1163 not upgraded.
Need to get 2,895 kB of archives.
After this operation, 13.9 MB of additional disk space will be used.
Do you want to continue [Y/n]? y

$ sudo apt-get install yelp
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libyelp0
The following packages will be upgraded:
  libyelp0 yelp
2 upgraded, 0 newly installed, 0 to remove and 1161 not upgraded.
Need to get 179 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y

$ sudo apt-get install yelp-tools
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  itstool
The following NEW packages will be installed:
  itstool yelp-tools
0 upgraded, 2 newly installed, 0 to remove and 1161 not upgraded.
Need to get 35.4 kB of archives.
After this operation, 408 kB of additional disk space will be used.
Do you want to continue [Y/n]? y

$ sudo apt-get install gobject-introspection
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libgirepository-1.0-1
The following NEW packages will be installed:
  gobject-introspection
The following packages will be upgraded:
  libgirepository-1.0-1
1 upgraded, 1 newly installed, 0 to remove and 1160 not upgraded.
Need to get 384 kB of archives.
After this operation, 1,162 kB of additional disk space will be used.
Do you want to continue [Y/n]? y

$ sudo apt-get install libxml2-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  gstreamer0.10-plugins-base gstreamer0.10-plugins-base:i386 libcroco3 libcroco3:i386 librsvg2-2 librsvg2-2:i386 librsvg2-common librsvg2-common:i386 libsoup2.4-1 libsoup2.4-1:i386 libxml2 libxml2:i386
  libxslt1.1 libxslt1.1:i386
Suggested packages:
  librsvg2-bin librsvg2-bin:i386
Recommended packages:
  xml-core:i386
The following NEW packages will be installed:
  libxml2-dev
The following packages will be upgraded:
  gstreamer0.10-plugins-base gstreamer0.10-plugins-base:i386 libcroco3 libcroco3:i386 librsvg2-2 librsvg2-2:i386 librsvg2-common librsvg2-common:i386 libsoup2.4-1 libsoup2.4-1:i386 libxml2 libxml2:i386
  libxslt1.1 libxslt1.1:i386
14 upgraded, 1 newly installed, 0 to remove and 1146 not upgraded.
Need to get 5,027 kB of archives.
After this operation, 2,888 kB of additional disk space will be used.
Do you want to continue [Y/n]? y

Ubuntu: install build dependencies

$ sudo apt-get build-dep wireshark-dev
[sudo] password for andreas: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Picking 'wireshark' as source package instead of 'wireshark-dev'
Note, selecting 'libcap-dev' instead of 'libcap2-dev'
The following NEW packages will be installed:
  comerr-dev debhelper dh-apparmor geoip-bin html2text krb5-multidev libasound2-dev libatk1.0-dev libc-ares-dev libcairo-script-interpreter2 libcairo2-dev libcap-dev libdbus-1-dev libexpat1-dev
  libfontconfig1-dev libfreetype6-dev libgcrypt11-dev libgdk-pixbuf2.0-dev libgeoip-dev libglib2.0-dev libgnutls-dev libgnutls-openssl27 libgnutlsxx27 libgpg-error-dev libgssrpc4 libgtk2.0-dev
  libjack-jackd2-dev libkadm5clnt-mit8 libkadm5srv-mit8 libkdb5-6 libkrb5-dev liblua5.1-0-dev libp11-kit-dev libpango1.0-dev libpcap0.8-dev libpcre3-dev libpcrecpp0 libpixman-1-dev libpng12-dev
  libportaudiocpp0 libreadline-dev libreadline6-dev libsmi2-dev libtasn1-3-dev libxcb-render0-dev libxcb-shm0-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxext-dev libxfixes-dev libxft-dev libxi-dev
  libxinerama-dev libxrandr-dev libxrender-dev po-debconf portaudio19-dev python-ply x11proto-composite-dev x11proto-damage-dev x11proto-fixes-dev x11proto-randr-dev x11proto-render-dev x11proto-xext-dev
  x11proto-xinerama-dev xsltproc
The following packages will be upgraded:
  bluez-alsa bluez-alsa:i386 gir1.2-atk-1.0 gir1.2-gdkpixbuf-2.0 glib-networking glib-networking:i386 glib-networking-common glib-networking-services gstreamer0.10-plugins-good gstreamer0.10-plugins-good:i386
  gtk2-engines-pixbuf:i386 libasound2 libasound2:i386 libatk1.0-0 libatk1.0-0:i386 libatk1.0-data libcairo-gobject2 libcairo-gobject2:i386 libcairo2 libcairo2:i386 libcanberra-pulse libcanberra0
  libcanberra0:i386 libcap2 libcap2:i386 libdbus-1-3 libdbus-1-3:i386 libexpat1 libexpat1:i386 libfreetype6 libfreetype6:i386 libgail-common libgail-common:i386 libgail18 libgail18:i386 libgdk-pixbuf2.0-0
  libgdk-pixbuf2.0-0:i386 libgdk-pixbuf2.0-common libgl1-mesa-glx libgl1-mesa-glx:i386 libglapi-mesa libglapi-mesa:i386 libglib2.0-0 libglib2.0-0:i386 libglib2.0-bin libgnutls26 libgnutls26:i386 libgpg-error0
  libgpg-error0:i386 libgtk2.0-0 libgtk2.0-0:i386 libjack-jackd2-0 libjack-jackd2-0:i386 libpcre3 libpcre3:i386 libportaudio2 libreadline6 libvisual-0.4-plugins libvisual-0.4-plugins:i386 libxcb-render0
  libxcb-render0:i386 libxcb-shm0 libxcb-shm0:i386 libxcomposite1 libxcomposite1:i386 libxcursor1 libxcursor1:i386 libxdamage1 libxdamage1:i386 libxext6 libxext6:i386 libxfixes3 libxfixes3:i386 libxi6
  libxi6:i386 libxinerama1 libxinerama1:i386 libxrandr2 libxrandr2:i386 libxrender1 libxrender1:i386
81 upgraded, 67 newly installed, 0 to remove and 1161 not upgraded.
Need to get 34.3 MB of archives.
After this operation, 62.7 MB of additional disk space will be used.
Do you want to continue [Y/n]? y

Publickey auf SSH-Target: Login ohne Passwort

Anleitung

user@notebook $ ssh-keygen -t rsa
user@notebook $ cat .ssh/id_rsa.pub | \
                ssh user@server 'cat >> .ssh/authorized_keys'

Now without password
user@notebook $ ssh user@server
user@server $

Diverses

Ursache:

root@target:~ /etc/rc.d/S16openssh stop
root@target:~ /usr/sbin/sshd -d
[...]
Connection from 192.168.1.1 port 59187
[...]
debug1: trying public key file /home/.ssh/authorized_keys
Authentication refused: bad ownership or modes for directory /home

Lösung:
Im beiliegenden Script ändert sich in der Benutzerverwaltung der Benutzer “root”:
Home-Verzeichnis: /root
Shell: /bin/bash

andreas@host:~ ssh-keygen -t rsa
andreas@host:~ ssh-keygen -t dsa
andreas@host:~ ssh-copy-id -i ~/.ssh/id_rsa.pub root@target
andreas@host:~ ssh-copy-id -i ~/.ssh/id_dsa.pub root@target

Kopiert die zwei Publickeys aufs Target ins ~/.ssh/authorized_keys

Da das Verzeichnis /root die Berechtigung “drwx——” hat (nur User-Berechtigt), erlaubt OpenSSH nun über ein Publickey einzuloggen.

Wenn es noch nicht funktioniert, geh über die Serial-Console, stoppe den OpenSSH-Server und starte ihn im Debug-Modus:

root@target:~ /etc/rc.d/S16openssh stop
root@target:~ /usr/sbin/sshd -d

Das gleiche Spiel auf Client-Seite (mit Verbose-Flag!!):

andreas@host:~ ssh -v root@target

SSH ohne Passwort — Kurze Anleitung zur Nutzung
SSH login without password
SSH Without a Password
SSH/OpenSSH/Keys

Doxygen

Installation

$ sudo apt-get install doxygen doxygen-gui doxygen-doc graphviz

Ubuntu User Wiki: Doxygen

Konfiguration

MACRO_EXPANSION        = YES
EXPAND_ONLY_PREDEF     = NO

Dokumentation

Hauptseite

/** @mainpage XCTL 
 *  
 *  @section sec1 Einleitung 
 *  Hier folgt eine kurze Einleitung... 
 * 
 *  @section sec2 Subsysteme 
 *  @subsection sec2_1 Motorsteuerung 
 *  @subsection sec2_2 Ablaufsteuerung  
 */

Klassen

/** Klasse realisiert Beispiel2.  
 *   
 *  @author David Damm  
 *  @date 2.7.2004 
 * 
 *  @version 0.2 
 *  Toten Code entfernt. 
 * 
 *  @version 0.1 
 *  Kommentare hinzugefügt (Doxygen). 
 */
class Beispiel2
{
} 

Funktionen

/** Klasse realisiert Beispiel3.  
 *  
 *  @author David Damm 
 *  @date 2.7.2004 
 */
class Beispiel3
{
  public:
  /** Addiert zwei ganze Zahlen.  
   *  @param[in] a Die erste Zahl. 
   *  @param[in] b Die zweite Zahl.  
   *  @return Die Summe der beiden Zahlen a und b.  
   *  @see Addiere(double,double)  
   */
  int Addiere(int a, int b);
  double Addiere(double a, double b);
}

Strukturen

/**
 * @brief Use brief, otherwise the index won't have a brief explanation.
 *
 * Detailed explanation.
 */
typedef struct BoxStruct_struct {
  int a;    /**< Some documentation for the member BoxStruct#a. */
  int b;    /**< Some documentation for the member BoxStruct#b. */
  double c; /**< Etc. */
} BoxStruct;

oder

/**
 * @struct BoxStruct_struct
 * @brief  brief explanation
 *
 * @var    BoxStruct_struct::a
 * @brief  Some documentation for the member
 */

Links

Doxygen
David Damm: Dokumentationswerkzeug Doxygen
Doxygen usage example (for C)
Document the code with Doxygen

Subversion

Video-Tutorial

Software Carpentry – Version Control with Subversion

General

What do “branch”, “tag” and “trunk” mean in Subversion repositories?
What is trunk, branch and tag in Subversion?

Externals

Externals Definitions
Adding an External Repository to an SVN Project

Properties / Eigenschaften

Eigenschaften

$ svn proplist -v .
$ svn propset <name> <value>
$ svn propedit
$ svn propdel

Branch and Merge

Versionskontrolle nach Art von Subversion
Verwenden von Zweigen
Subversion Howto Branch, Merge, Reintegrate

How do I make Subversion use a third-party diff tool?

Problems with Merging

Reintegrate can only be used if revisions X through Y were previously merged from to reintegrate the source, but this is not the case
svn merge with –reintegrate complains about missing ranges but mergeinfo seems correct
Subversion 1.5 Mergeinfo – Understanding the Internals
svn mergeinfo
Grundlegendes Zusammenführen – Mergeinfo und Vorschauen

# Get
$ svn propget -R svn:mergeinfo .

# Delete
$ svn propdel -R svn:mergeinfo .

# Commit
$ svn commit -m "removed property svn:mergeinfo from all files"

Fedora askpassword/pinentry GUI

How to disable pinentry-qt in fedora 20 for git-svn ?
Disable the pinentry GUI window (for ssh, svn+ssh, gpg, …) under Linux

$ ps aux | grep pinentry-gtk-2
andreas  15078 91.0  0.0 249508  2780 ?        RL   11:13  22:19 /usr/bin/pinentry-gtk-2
$ export PINENTRY_USER_DATA="USE_CURSES=1"
$ unset GPG_AGENT_INFO
$ export | grep ask
declare -x SSH_ASKPASS="/usr/libexec/openssh/gnome-ssh-askpass"
$ unset SSH_ASKPASS

Migration

Subversion

$ svnadmin dump http://projectname.googlecode.com/svn > repodump
svnadmin: 'http://projectname.googlecode.com/svn' is an URL when it should be a path

> svnadmin create c:/rep_new
$ svnadmin create /home/svn/repo_new

> echo > c:\rep_new\hooks\pre-revprop-change.cmd
$ echo ‘#!/bin/sh’ > /home/svn/repo_new/hooks/pre-revprop-change
$ chmod +x /home/svn/repo_new/hooks/pre-revprop-change

> svnsync init file:///c:/repository https://example.googlecode.com/svn
$ svnsync init file:///home/svn/repo_new https://example.googlecode.com/svn

> svnsync sync file:///c:/repository
$ svnsync sync file:///home/svn/repo_new

git

How to migrate svn to another repository
Migrate to Git from SVN
SVN copy between repositories with history

1. Get a git svn clone of each repository:
    git svn clone <SVN-REPOSITORY-FROM> source-repo
    git svn clone <SVN-REPOSITORY-TO> dest-repo

 2. Create patches to be imported:
    cd source-repo/
    export commitFrom=`git log --pretty=%H | tail -1`
    git format-patch -o /tmp/mergepatchs ${commitFrom}..HEAD .

 3. Import the patches
    cd dest-repo/
    git am /tmp/mergepatchs/*.patch

 4. Check difference (= svn status)
    git diff --name-status remotes/git-svn
  
 5. Commit to remote repository
    git svn dcommit

pitfalls svn -> git migration
After “git svn clone”, I still don’t have fantastic branch-merging commit?
Fixing SVN Merge History in Git Repositories

External Diff Program

Send your svn diff to meld

$ svn diff --diff-cmd='meld' file.c

How to make svn diff produce file that patch would apply, when svn cp or svn mv was used?

$ svn diff --diff-cmd /usr/bin/diff -x "-i -b -U" > mypatch

Unversioned Files

$ svn status --no-ignore | grep '^\?' | sed 's/^\?      //'
$ svn status --no-ignore | grep '^\?' | sed 's/^\?      //'  | xargs -Ixx rm -rf xx

Delete Unversioned Files Under SVN

Keywords

Subversion Keywords: Id Rev Author Date


[miscellany]
enable-auto-props = yes

[auto-props]
*.c = svn:keywords=Author Date Id Rev URL;svn:eol-style=native
*.h = svn:keywords=Author Date Id Rev URL;svn:eol-style=native

Undo / revert commit

How do I return to an older version of our code in Subversion?
subversion: How to revert a bad commit
Reverting a Commit in Subversion

svn merge -r [current_version]:[previous_version] [repository_url]
svn commit -m “Reverting previous commit and going back to revision [previous_version].”

Add folder without included files

$ svn add --depth=empty <directory>

Add directory structure to SVN, without files

Undo added files

$ svn revert --recursive <file/directory>
or
$ svn delete --keep-local <file/directory>

“unadd” a file to svn before commit
Undo svn add without reverting local edits

Remove .svn folders

find -type d -name .svn | xargs rm -rf

Remove .svn folders

Ignore files/directories

Individual:

$ svn propset svn:ignore <file to ignore> <folder to set>
$ svn propset svn:ignore -F file_list.txt <folder to set>

svn propset — Den Wert von PROPNAME für Dateien, Verzeichnisse oder Revisionen auf PROPVAL setzen

Global

[miscellany]
global-ignores = <files to ignore>

Resolve conflicts

# Use manually solved files, recursively
$ svn resolve --accept working -R <directory>
base Auswahl der Datei, die die BASE-Revision gewesen war, bevor Sie Ihre Arbeitskopie aktualisierten. Das heißt, die Datei, die Sie ausgecheckt hatten, bevor Sie Ihre letzten Änderungen vornahmen.
working Auswahl der aktuellen Datei in Ihrer Arbeitskopie unter der Annahme, dass Sie Konflikte manuell aufgelöst haben.
mine-full Auswahl der Kopien konfliktbehafteter Dateien, mit dem Inhalt zum Zeitpunkt unmittelbar vor Ihrem Aufruf von svn update.
theirs-full Auswahl der Kopien konfliktbehafteter Dateien, mit dem Inhalt der Revisionen, die Sie durch den Aufruf von svn update vom Server geholt haben.

svn resolve — Konflikte in Dateien und Verzeichnissen der Arbeitskopie auflösen

E160013: ‘/svn/XXX/!svn/me’ path not found

$ dpkg -l | grep subversion
ii  subversion                             1.7.5-1ubuntu2                             amd64        Advanced version control system

Server:
Powered by Apache Subversion version 1.7.4 (r1295709)
$ svn commit -m "add [...]"
svn: E160013: Commit failed (details follow):
svn: E160013: '/svn/XXX/!svn/me' path not found

Connection reset by peer

Solving checkout problems with svn repositories
Timeouts/connection reset using SVN 1.6.11/Apache 2.2.15
Laufzeit-Konfigurationsbereich
SVN Operations Taking Longer than an Hour Time Out
SVN commit doesn’t complete

Client:
%APPDATA%\Subversion\servers: http-timeout = 900
%LOCALAPPDATA%\Subversion\servers: http-timeout = 900
"~/.subversion/servers: http-timeout = 900

Server:
apache2/httpd.conf: TimeOut 900

TortoiseSVN

How do I configure TortoiseSVN’s external merge behavior?

%base   - the original file without your or the others changes
%bname  - The window title for the base file
%mine   - your own file, with your changes
%yname  - The window title for your file
%theirs - the file as it is in the repository
%tname  - The window title for the file in the repository
%merged - the conflicted file, the result of the merge operation
%mname  - The window title for the merged file 

WinMerge

C:\Program Files (x86)\WinMerge\WinMergeU.exe -e -ub -dl %bname -dr %yname %base %mine

Meld

Meld (official)
GNOME: Meld
Meld Installer for Windows (inactive)
Using Meld as external diff tool with Tortoise SVN
How to set up svn conflict resolution with meld?

merge-tool-cmd = /opt/svn-merge-meld
C:\Program Files (x86)\Meld\meld\meld.exe %theirs %merged %mine
C:\Program Files (x86)\Meld\meld\meld.exe --auto-merge --output %merged %mine %base %theirs

Filter

meld_text_filter_freebsd

SvnMapper

SvnMapper
Graphical representation of SVN branch/merge activity [closed]
Visualising Subversion branching/merging history
Anyone use SvnMapper? please help me!
Download the Corflags.exe

C:\Program Files (x86)\SvnMapper>corflags.exe SvnMapper.exe
Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  2.0.50727.42
Copyright (c) Microsoft Corporation.  All rights reserved.

Version   : v2.0.50727
CLR Header: 2.5
PE        : PE32
CorFlags  : 1
ILONLY    : 1
32BIT     : 0
Signed    : 0

C:\Program Files (x86)\SvnMapper>corflags.exe SvnMapper.exe /32bit+
Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  2.0.50727.42
Copyright (c) Microsoft Corporation.  All rights reserved.

corflags : error CF001 : Could not open file for writing
C:\Program Files (x86)\SvnMapper>corflags.exe SvnMapper.exe /32bit+
Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  2.0.50727.42
Copyright (c) Microsoft Corporation.  All rights reserved.


C:\Program Files (x86)\SvnMapper>corflags.exe SvnMapper.exe
Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  2.0.50727.42
Copyright (c) Microsoft Corporation.  All rights reserved.

Version   : v2.0.50727
CLR Header: 2.5
PE        : PE32
CorFlags  : 3
ILONLY    : 1
32BIT     : 1
Signed    : 0