Kategorien
CL-35B2 Linux

mtd-utils für NAND Sicherung übersetzen

Es gibt im Netz viele Anleitungen zum Übersetzen der mtd-utils. Leider ist keine Einziger von mir aufgefundener Artikel auf meine Anforderungen zugeschnitten. Die meisten Anleitungen sind für sehr alte Versionen der mtd-utils verfasst, so das sie zum Beispiel davon ausgehen das kein ./configure Script für diese Software existiert oder die Anleitungen beziehen sich auf die besonderheiten des Cross-Compilings und lassen alles andere weg.

Hier ist meine Anleitung für das übersetzen der mtd-utils auf der NAS CL-35B2. Diese Anleitung wird benötigt um die Werkzeuge nanddump und nandwrite zu erhalten welche für ein Backup und Restore der NAS benötigt werden.

Die Anleitung kann direkt nach dem vorbereiten eines Buildsystems für die CL-35B2, und einem chroot in das Buildysystem, verwendet werden.

Die Bibliotheken werden direkt in das Buildsystem geschrieben und ich verwende das Paketmanagement nicht da es sich nur um das Buildsystem handelt, welches nach dem erfolgreichen übersetzten der Quellen wieder gelöscht wird. Sollte Dein Buildsystem Dauerhaft bestehen sollen empfehle ich Dir rpm-Pakete entsprechend dieser Anleitung zu erstellen.

1.) Vorbereitungen und Download der Sourcecodes

cd /usr/src
wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.10.tar.gz
wget http://www.zlib.net/zlib-1.2.11.tar.gz
git clone git://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
git clone git://git.infradead.org/mtd-utils.git

2.) zlib erstellen

tar xzf zlib-1.2.11.tar.gz
cd /usr/src/zlib-1.2.11
./configure
make
make install
cd /usr/src
rm -r zlib-1.2.11
rm zlib-1.2.11.tar.gz

3.) lzo erstellen

tar xzf lzo-2.10.tar.gz
cd /usr/src/lzo-2.10
./configure
make
make check
make install
cd /usr/src
rm -r lzo-2.10
rm lzo-2.10.tar.gz

4.) e2sfprogs erstellen

cd /usr/src/e2fsprogs
./configure
make
make install
make install-libs
cd /usr/src
rm -r e2fsprogs

5.) Die mtd-utils übersetzen

cd /usr/src/mtd-utils
./autogen.sh
./configure --disable-tests
make
make install

nach der Installation sind folgende Werkzeuge zusätzlich verfügbar.:

ToolNutzen
ubiupdatevol
ubimkvol
ubirmvol
ubicrc32
ubinfo Ausgabe von Informationen zum NAND Speicher und zur Partitionierung und zu den Details einer UBI-Partition
ubiattach
ubidetach
ubinize
ubiformat
ubirename
mtdinfoAusgabe von Informationen zum NAND Speicher und zur Partitionierung und zu den Details einer MTD-Partition
ubirsvol
ubiblock
ftl_format
doc_loadbios
ftl_check
mtd_debug
docfdisk
serve_image
recv_image
flash_erase
flash_lock
flash_unlock
flash_otp_info
flash_otp_dump
flash_otp_lock
flash_otp_write
flashcp
mtdpart Partitionierungswerkzeug für einen NAND Speicher
nanddump Export des Inhalts einer NAND-Partition
nandwrite zurückschreiben einer Sicherung in den NAND Speicher
nandtest
nftldump
nftl_format
rfddump
rfdformat
mkfs.ubifs
mkfs.jffs2
jffs2dump
jffs2reader
sumtool
Kategorien
Linux

git als static binary compilieren

Was ist eine “static binary”?

Während der Übersetzung eines Quellcodes in ein ausführbares Programm verknüpft der Compiler die ausführbare Datei des Programms, um später bei der Ausführung des Programms Arbeitsspeicher zu sparen, mit “shared dynamic libraries”.

Diese Bibliotheken sind eine Sammlung von Funktionen welche von mehreren Programmen geteilt verwendet werden um bestimmte Aufgaben zu zu erfüllen. Durch die gemeinsame Nutzung dieser Bibliotheken kann der Arbeitsspeicher des Computers geschont werden, da nur eine Kopie der Bibliothek für viele verschiedene Programme im Speicher geladen sein muss. Um ein unerwartetes Verhalten von Programmen zu vermeiden, ist es manchmal unumgänglich das Programm mit einer bestimmten Version einer Bibliothek zu Übersetzen. Auch um die Portabilität eines Programms zu verbessern ist es wichtig die Abhängigkeit vom vorhanden sein einer dynamischen Bibiothek zu vermeiden. In Linux Systemen sorgt ein Paketmanager dafür, dass Versionsabhängigkeiten korrekt erfüllt werden. Wenn Du auf einem Computer arbeitest über den Du keine Administrative Kontrolle besitzt kannst Du die Version der verwendeten Bibliothek nicht bestimmen oder eine aktualisiert verhindern.
Programme können, wenn sie mit “shared dynamic libraries” übersetzt wurden nur auf andere Computer übertragen werden auf der, die gleiche Prozessorarchitektur und die gleichen Bibliotheken verfügbar sind.
Falls die Bibliotheken des Computers auf den das Programm übertragen wurde aktualisiert werden, eine Bibliothek entfernt wird oder eine der Bibliotheken auf dem Zielrechner werden kompromittiert oder durch bösartige Versionen ersetzt. Hier kommt das bauen einer “static binary” ins Spiel.   Wie wird GIT als “static binary” übersetzt?

in diesem Beispiel gehe ich davon aus das auf der NAS, entsprechend meiner Anleitung, bereits mit dem hier notwendigen Buildsystem ausgestattet wurde. Im Anschluss kann die entstehende GIT Binärdatei auf allen identischen ARM Prozessoren verwendet werden.
Die aktuellste GIT Version kann auf http://git-scm.com gefunden werden.

Die Folgenden 3 Schritte sind auszuführen:

1) Lade den GIT Quellcode herunter, entpacke die tar.gz-Datei und wechsle in das GIT Buildverzeichnis:

wget --no-check-certificate https://kernel.org/pub/software/scm/git/git-2.9.5.tar.gz
tar xzf git-2.9.5.tar.gz
cd git-2.9.5

2) Setze die Compilervariablen und konfiguriere ihn mittels ./configure. Hierbei kannst du ein  separates Verzeichnis zum übersetzen angeben.:

mkdir /usr/src/git-static
CHOST="armv6j-hardfloat-linux-gnueabi"
CFLAGS="-Os -march=arm1136jf-s -mfpu=vfp -mfloat-abi=hard -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
./configure --prefix=/usr/src/git-static CFLAGS="${CFLAGS} -static"

3) übersetze GIT:

make

…und installiere GIT in das Zielverzeichnis

make install

4) Prüfe anschließend das deine neue GIT-Version wie erwartet funktioniert

cd /usr/src/git-static
./git --version
Kategorien
Linux Raspberry Pi

Raspberry Pi: Animiertes Bootlogo (splash screen)

Ich suchte für meinen MAME-Retro-Arcasde Automaten nach einer Möglichkeit ein Bootlogo anzuzeigen, so das ersichtlich ist das der Automat noch startet. (und nicht etwa hängen geblieben ist)

Leider dauert das laden des Linux-Systems und des MAME mehrere Minuten auf dem Raspberry Pi, so das ein stehendes Bild wie ein abgestürztes System erscheinen. Die Linux Boot-Meldungen hingegen passen nicht zu einem Spielautomaten.

Ich persönlich verwende für meinen Spielautomaten ein statisches Bild, das MAME-Logo, vor welches ich einen loading spinner! gelegt habe.
Sehr schön für einen Spielautomaten sind auch animierte Charaktere aus klassischen Spielen, wie die Eule aus Apydia. Suche bei der Suchmaschine deine Wahl nach “animated gif sprites” um einige zu finden.Agony (1992) Art & Magic / Psygnosis

Die Bootmeldungen können über die drei Einträge “consoleblank=0 loglevel=1 quiet” in der Datei cmdline.txt im Verzeichnis /boot abgeschaltet werden.
Ebenfalls in der Datei cmdline.txt kann das Bootlogo, die Himbeeren die oben links erscheinen, mittels “logo.nologo” abgeschaltet werden.
Mit dem Eintrag disable_splash=1 in der Datei config.txt im Ordner /boot schaltet Ihr auch noch das Regenbogen-Startbild des Raspberry Pi ab.

Splashscreen Werkzeuge wie FbiPlymouth oder FMI unterstützen leider keine Animationen. Das Werkzeug bannerd von Alexander Lukichev füllt genau diese Lücke und bietet die Möglichkeit eine Serie von BMP-Bildern als Animation wiederzugeben. (Die Letzte Aktualisierung des von bannerd ist leider aus dem September 2012)

Im Raspbian Repository ist bannerd aktuell leider nicht vorhanden, kann jedoch einfach aus den Quellen übersetzt werden.
Hierzu holen wir den Quellcode aus dem GIT-Repository und übersetzen es im Anschluss mittels make.:

git clone https://github.com/alukichev/bannerd.git
cd bannerd
make

Im Anschluss muss die entstandene Datei bannerd in den Ordner /usr/local/bin/ oder /bin kopiert werden, ausführbar gemacht werden sowie der Eigentümer und die Gruppe auf root geändert werden.

sudo cp bannerd /usr/local/bin/
sudo chown root:root /usr/local/bin/bannerd
sudo chmod 755 /usr/local/bin/bannerd

Als Bootanimation ist bei bannerd ausschließlich eine Sequenz von BMP Bildern möglich. Wenn die Boot-Animation bereits als Videodatei oder als animiertes Gif vorliegt kann diese mittels ffmpeg in eine Bildsequenz umgewandelt werden.

ffmpeg -i original_animation.gif %04d.bmp

Da mein Beispiel GIF eine Transparenz hat und ffmpeg leider automatisch weiß als Hintergrundfarbe bei der Umwandlung in Dateiformate ohne Apha Kanal.
Wenn Du eine andere Hintergrundfarbe als weiß benötigst können solche animierte GIFs leider nicht direkt umgewandelt werden.
Mit dem Umweg über PNG Bilder mit Alpha Transparenz können den BMPs auch andere Hintergundfarben gegeben werden.:

ffmpeg -i original_animation.gif %04d.png
mogrify -background black -flatten -format bmp *.png

Wenn das animierte GIF als kleine Animation in der unteren rechten Ecke des Bootbildes angezeigt werden soll können die Animationphasen mit folgenden Befehlen mit einem Hintergrundbild zusammengefügt werden. (Das Hintergrundbild wird im folgenden Beispiel mittels Imagemagic als leeres schwarzes Bild erzeugt.)

convert -size 800x480 xc:black hintergrund.jpg
wget https://loteks.de/wp-content/uploads/2017/10/agonyamiga.gif
ffmpeg -i agonyamiga.gif %04d.png
for f in *.png ; do composite -gravity southeast -geometry +25+25 "$f" hintergrund.jpg "${f%.png}.bmp" ; done
sudo mkdir /etc/bootanimation
sudo mv *.bmp /etc/bootanimation/
sudo chown root:root /etc/bootanimation -R

Nach dem wir jetzt den Dienst bannerd haben und die anzuzeigende Animation abgelegt haben brauchen wir noch einen systemd Service der im Bootvorgang bannerd startet.

der Service kann in Form der folgenden Datei /etc/systemd/system/bootlogo.service erzeugt werden:

[Unit]
Description=bootlogo
DefaultDependencies=no
After=local-fs.target

[Service]
ExecStart=/bin/sh -c '/usr/local/bin/bannerd -vD /etc/bootanimation/*.bmp'
StandardInput=tty
StandardOutput=tty

[Install]
WantedBy=sysinit.target

Jetzt muss der nrur Dienst noch aktualisiert werden.: sudo systemctl enable bootlogo
Das Bootlogo kann mit dem Befehl systemctl start bootlogo oder mit einem neustart des Computers getestet werden.

Kategorien
Linux Raspberry Pi

Neuer Linux Kernel für Raspberry Pi

Manchmal brauche ich einfach das eine oder andere Kernel Modul welches sich nicht im Vanilla Kernel meines Rasbian befindet, oder ich möchte unbedingt einige Module loswerden oder ich will einen aktuelleren linux Kernel.
Um eines oder alle diese Ziele zu erreichen muss ein neuer Linux Kernel für den Raspberry Pi angefertigt werden. Hier die Kurzanleitung wie dies in fünf einfach Schritten zu schaffen ist.:

1.) Linux Kernel Quellen herunterladen

Um den Aktuellen Kernel übersetzen zu können brauchen wir einige Module. Um diese zu Installieren nutzen wir apt-get install.:

sudo apt-get install bc git build-essential

Um den “aktuellen” Linux Kernel zu bekommen holen wir über Git die Quellen:

git clone --depth=1 https://github.com/raspberrypi/linux

alternativ können wir auch einen aktuelleren Kernel (im Beispiel 4.5) holen lassen.:

git clone --depth=1 --branch=rpi-4.5.y https://github.com/raspberrypi/linux

und wechseln in das Installationsverzeichnis.

cd linux

2.) Default Konfiguration erstellen

Im Anschluss muss ich die default Linux Konfiguration für meinen Raspberry Pi erstellen, für Raspberry Pi 1 A oder B und das Compute Module:

KERNEL=kernel
make bcmrpi_defconfig

für den Raspberry Pi 2 geht dies über:

KERNEL=kernel7
make bcm2709_defconfig

3.) Kernel konfiguration anpassen (optional)

um die Konfiguration des Linux Kernels anzupassen bietet Linux die

make menuconfig

oder alternativ

make nconfig

4.) Kernel übersetzen

um den Kernel im Anschluss zu compilieren die folgenden Zeilen ausführen:

make zImage modules dtbs

5.) Kernel Installieren

sudo make modules_install
sudo cp arch/arm/boot/dts/*.dtb /boot/
sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/
sudo scripts/mkknlimg arch/arm/boot/zImage /boot/$KERNEL.img

Wenn der Kernel einen abweichenden Namen erhalten soll kann in der Datei config.txt die Zeile “kernel” für den verwendeten Kernel angepasst werden.:

kernel=meinKernel.img
Kategorien
Allgemein

shellshock II (RPM-Paket erstellen)

In der chroot-Umgebung aus der ersten Anleitung kann auch direkt ein rpm Paket erstellen, welches eine saubere Installation der aktualisierten Bash ermöglicht.

Die Anleitung beginnt an Punkt 2 (2. Bash Quellen bereitstellen) der ersten Anleitung!

In der chroot-Umgebung des Build Systems einen Benutzer für den Paketbau anlegen:

chroot /mnt/chroot
adduser builder  && su builder && cd ~

Im Anschluß werden die für rpmbuild notwendigen Verzeichnisse, die drei Bash Konfigurations-Dateien .bashrc, .bash_profile, .bash_logout und die Specs-Datei für den rpm-Paketbau angelegt und die Bash Quellcodes sowie Patches heruntergeaden.:

mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
cd ~/rpmbuild/SOURCES/
wget ftp://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz
wget ftp://ftp.gnu.org/gnu/bash/bash-4.3-patches/ -m -nd
cat <<'EOF' > dot-bash_logout
# ~/.bash_logout: executed by bash(1) when login shell exits.

# when leaving the console clear the screen to increase privacy

if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
EOF
cat <<'EOF' > dot-bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
EOF
cat <<'EOF' > dot-bashrc
# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=10000
HISTFILESIZE=20000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi

if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi

export LANG=de_DE.utf8
export LC_CTYPE=de_DE.UTF-8

test "$SSH_AUTH_SOCK" || exec ssh-agent $SHELL -c "ssh-add; exec $SHELL -login"
EOF
cd ~/rpmbuild/SPECS
cat < <'EOF' > bash.spec
# BASH spec File TEST
#%define beta_tag rc1
%define patchlevel .30
%define baseversion 4.3

# Build auch mit unpackaged files abschliessen
%define _unpackaged_files_terminate_build 0
%define _missing_doc_files_terminate_build 0

Version: %{baseversion}%{patchlevel}
Name: bash
Summary: The GNU Bourne Again shell
Release: 1%{?dist}
Group: System Environment/Shells
License: GPLv3+
Url: http://www.gnu.org/software/bash
Source0: ftp://ftp.gnu.org/gnu/bash/bash-%{baseversion}.tar.gz

Source1: dot-bashrc
Source2: dot-bash_profile
Source3: dot-bash_logout

# Official upstream patches
Patch001: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-001
Patch002: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-002
Patch003: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-003
Patch004: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-004
Patch005: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-005
Patch006: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-006
Patch007: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-007
Patch008: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-008
Patch009: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-009
Patch010: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-010
Patch011: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-011
Patch012: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-012
Patch013: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-013
Patch014: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-014
Patch015: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-015
Patch016: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-016
Patch017: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-017
Patch018: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-018
Patch019: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-019
Patch020: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-020
Patch021: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-021
Patch022: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-022
Patch023: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-023
Patch024: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-024
Patch025: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-025
Patch026: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-026
Patch027: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-027
Patch028: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-028
Patch029: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-029
Patch030: ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-030

Requires(post): ncurses-libs
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires: ncurses-devel
BuildRequires: autoconf, gettext

%description
The GNU Bourne Again shell (Bash) is a shell or command language
interpreter that is compatible with the Bourne shell (sh). Bash
incorporates useful features from the Korn shell (ksh) and the C shell
(csh). Most sh scripts can be run by bash without modification.

%define pkgdocdir %{_datadir}/doc/%{name}-%{version}

%prep
#%setup -q -a 2
%setup -q -n %{name}-%{baseversion}

# Official upstream patches
%patch001 -p0 -b .001
%patch002 -p0 -b .002
%patch003 -p0 -b .003
%patch004 -p0 -b .004
%patch005 -p0 -b .005
%patch006 -p0 -b .006
%patch007 -p0 -b .007
%patch008 -p0 -b .008
%patch009 -p0 -b .009
%patch010 -p0 -b .010
%patch011 -p0 -b .011
%patch012 -p0 -b .012
%patch013 -p0 -b .013
%patch014 -p0 -b .014
%patch015 -p0 -b .015
%patch016 -p0 -b .016
%patch017 -p0 -b .017
%patch018 -p0 -b .018
%patch019 -p0 -b .019
%patch020 -p0 -b .020
%patch021 -p0 -b .021
%patch022 -p0 -b .022
%patch023 -p0 -b .023
%patch024 -p0 -b .024
%patch025 -p0 -b .025
%patch026 -p0 -b .026
%patch027 -p0 -b .027
%patch028 -p0 -b .028
%patch029 -p0 -b .029
%patch030 -p0 -b .030

echo %{version} > _distribution
echo %{release} > _patchlevel

%build
autoconf
%configure --with-bash-malloc=no --with-afs --with-installed-readline
make "CPPFLAGS=-D_GNU_SOURCE -DRECYCLES_PIDS `getconf LFS_CFLAGS`"
%check
make check
strip bash
strip bashversion

%install
rm -rf $RPM_BUILD_ROOT

if [ -e autoconf ]; then
  export PATH=.:$PATH
fi

# Fix bug #83776
perl -pi -e 's,bashref\.info,bash.info,' doc/bashref.info

make DESTDIR=$RPM_BUILD_ROOT install

mkdir -p $RPM_BUILD_ROOT/etc

# Not for printf, true and false (conflict with coreutils)
rm -f $RPM_BUILD_ROOT/%{_mandir}/man1/printf.1
rm -f $RPM_BUILD_ROOT/%{_mandir}/man1/true.1
rm -f $RPM_BUILD_ROOT/%{_mandir}/man1/false.1

pushd $RPM_BUILD_ROOT
mkdir ./bin
mv ./usr/bin/bash ./bin
ln -sf bash ./bin/sh
rm -f .%{_infodir}/dir
popd
mkdir -p $RPM_BUILD_ROOT/etc/skel
install -c -m644 %SOURCE1 $RPM_BUILD_ROOT/etc/skel/.bashrc
install -c -m644 %SOURCE2 $RPM_BUILD_ROOT/etc/skel/.bash_profile
install -c -m644 %SOURCE3 $RPM_BUILD_ROOT/etc/skel/.bash_logout
LONG_BIT=$(getconf LONG_BIT)
mv $RPM_BUILD_ROOT%{_bindir}/bashbug \
   $RPM_BUILD_ROOT%{_bindir}/bashbug-"${LONG_BIT}"

%find_lang %{name}

# lua-code von Jesse Keating  so das keine Externen Abhängigkeiten benötigt werden.
# lua-Code von Ignacio Vazquez-Abrams
%post -p 
bashfound = false;
shfound = false;

f = io.open("/etc/shells", "r");
if f == nil
then
  f = io.open("/etc/shells", "w");
else
  repeat
    t = f:read();
    if t == "/bin/bash"
    then
      bashfound = true;
    end
    if t == "/bin/sh"
    then
      shfound = true;
    end
  until t == nil;
end
f:close()

f = io.open("/etc/shells", "a");
if not bashfound
then
  f:write("/bin/bash\n")
end
if not shfound
then
  f:write("/bin/sh\n")
end
f:close()

%postun
if [ "$1" = 0 ]; then
    /bin/grep -v '^/bin/bash$' < /etc/shells | \       /bin/grep -v '^/bin/sh$' > /etc/shells.new
    /bin/mv /etc/shells.new /etc/shells
fi

%files -f %{name}.lang
%defattr(-,root,root)
%config(noreplace) /etc/skel/.b*
/bin/sh
/bin/bash
%attr(0755,root,root) %{_bindir}/bashbug-*
EOF

Die bash.spec-Datei enthält die Konfigutarion des Paketes sowie die bei der Installation und deinstallation notwendigen Scripte. Die Vorliegende SPECS Datei ist eine bearbeitung der Original Quelle von Fedora Core 12, welche ich für die aktuelle BASH angepasst habe.

Jetzt kann mit rpmbuild das Paket erstellt werden, welches direkt im Anschluss mit rpm Installiert werden kann. Das alte Bash Paket wird hierbei durch das neue Paket ersetzt.

rpmbuild -ba  bash.spec
rpm -U --force --replacefiles /mnt/chroot/home/builder/rpmbuild/RPMS/armv6l/bash-4.3.30-1.fc12.armv6l.rpm

Das aus diesem Tutorial entstehende Bash-Binary und RPM-Datei zur Installation

Kategorien
CL-35B2 Linux

howto – Shellshock auf der NAS

Leider ist auch die Bash-Shell der NAS CL-35B2 vom shellshock betroffen.

Hier meine Anleitung, wie die Bash auf der NAS durch eine neue, selbst compilierte ersetzt werden kann

1.) Bash auf Shelshock Verwundbarkeit testen

curl -k https://shellshocker.net/shellshock_test.sh 2> /dev/null| bash 2> /dev/null

Sollte bei einem der Tests die Meldung “VULNERABLE” erscheinen, sollte die “Bash” mit dieser Anleitung aktualisiert werden.
Sollten alle Tests “not vulnerable” ausgeben ist diese Anleitung nicht interessant für Sie.
Ein Mirror des Scriptes ist unter der URL http://dl.loteks.de/shellshock_test.sh zu finden.

1.) Build Umgebung erstellen

Leider enthält die NAS CL-35B2 keine installierte Build-Umgebung. Von den 195MB Speicherplatz sind nur noch ca 40 frei, der Speicherplatz auf der NAS ist einfach zu klein um GCC und make zu installieren.

Ich habe einen USB stick angeschlossen, der sich als /dev/sdc meldet. (herauszufinden via dmesg)
via cfdisk habe ich auf diesem USB Stick zwei Partitionen angelegt, zuerst eine ein Gigabyte Swap Partition und im Anschluss den Rest als Linux Partition.

Im Anschluss den swap Speicher Partitionieren und aktivieren:

mkswap /dev/sdc1
swapon /dev/sdc1

Das Dateisystem auf /dev/sdc2 erstellen und Das Laufwerk Mounten:

mkfs.ext2 /dev/sdc2
mount /dev/sdc2 /mnt

Anschließend die RPM Pakete der Verwendeten Linux Distribution herunterladen. Bei der Fantec CL-35B2 ist es leider noch Fedora ARM 12, welches ein wenig betagt ist. Ich habe unter http://dl.loteks.de/fedora12arm_rpms.tar.gz (größe 119 MB) ein Paket mit den, für das Compilieren der Bash notwendigen rpm-Paketen abgelegt.

mkdir -pv /mnt/{chroot,rpm}
cd /mnt/
wget http://dl.loteks.de/fedora12arm_rpms.tar.gz
tar xzf fedora12arm_rpms.tar.gz
rpm --install --nodeps --root=/mnt/chroot/ rpm/*.rpm

Nach dieser, sehr sehr lange dauernden Installation (dies dauert auf der NAS mehrere Stunden!) befindet sich die chroot umgebung im Order /mnt/chroot

2.) Bash Quellen bereitstellen

Jetzt brauchen wir die Bash Quellen und Patches in der chroot-Ubgebung:

mkdir -pv /mnt/chroot/usr/src/bash
cd /mnt/chroot/usr/src/bash
wget ftp://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz
tar xzf bash-4.3.tar.gz
wget ftp://ftp.gnu.org/gnu/bash/bash-4.3-patches/ -m -nd
chroot /mnt/chroot/
cd /usr/src/bash/bash-4.3 
for file in ../bash43-0[0-9][0-9] ; do patch -p0 < $file; done

Ab diesem Punkt liegen die Quellen der Bash gepatched im Verzeichnis /mnt/chroot/usr/src/bash-4.3. Das herunter geladene sstrip.c brauchen wir am ende um die Datei “bash” auf ein der NAS angepasste Größe zu kürzen.
Jetzt können je nach Wunsch beliebige Compiler Flags gesetzt werden und die Configurationsoptionen gesetzt werden.

CHOST="armv6j-hardfloat-linux-gnueabi"
CFLAGS="-Os -march=armv6j -mcpu=arm1136jf-s -mfpu=vfp -mfloat-abi=hard -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
./configure --with-installed-readline
make
strip bash
exit

mit dem “strip bash” werden alle, für die Ausführung der bash, nicht benötigten teile der elf-Datei entfernt. Die Datei wird von fast 1,5 MB auf unter 840KB reduziert.

3. bash Installieren

cp /mnt/chroot/usr/src/bash/bash-4.3/bash /bin/bash1
/bin/bash1
cp /bin/bash /bin/bash_
cp /bin/bash1 /bin/bash
exit
rm /bin/bash1 /bin/bash_
curl -k https://shellshocker.net/shellshock_test.sh 2> /dev/null| bash 2> /dev/null

CVE-2014-6271 (original shellshock): not vulnerable
CVE-2014-6278 (Florian’s patch): not vulnerable
CVE-2014-7169 (taviso bug): not vulnerable
CVE-2014-//// (exploit 3 on https://shellshocker.net/ ): not vulnerable
CVE-2014-7186 (redir_stack bug): not vulnerable
CVE-2014-7187 (nested loops off by one): not vulnerable

Die Anleitung wurde vom mir zuletzt am 05.10.2014 getestet.
Sollten Irrtümer, Fehler oder Verbesserungen zum Artikel auffallen bitte ich dies mir mit einem Kommentar zu melden.

Besser wäre ein rpm-Paket, ich hoffe die Anleitung demnächst bezüglich rpm-Paket bau erweitern zu können.


Das aus diesem Tutorial entstehende Bash-Binary und RPM-Datei aus dem RPM-Tutorial zur Installation

Kategorien
CL-35B2 Linux

Linux Buildsystem auf der NAS erstellen (fedora Core12)

Auf meiner NAS CL-35B2 benötige ich ein Buildsystem um einige Dienste zu aktualisieren. (und vermutete Sicherheitslücken zu schließen)

Um ein Build System zu installieren reicht der Speicherplatz der NAS, der NAND ist nur 200MB groß, nicht aus. Ich habe einen 4GB USB Stick angeschlossen, der als /dev/sdc auftaucht.

Nach dem Partitionieren via cfdisk bleiben 3GB für meine chroot-Umgebung und 1GB für den Swap.

Die Pakete sind der URL http://ftp.linux.org.uk/pub/linux/arm/fedora/pub/fedora/linux/releases/12/Everything/arm/os/Packages/ entnommen, ich habe einen vollständigen Mirror unter http://fc12.arm.loteks.de/ angelegt.

mkfs.ext4 /dev/sdc1
mount /dev/sdc1 /mnt/

1.) Initialisiere die RPM Datenbank

mkdir -p /mnt/chroot/var/lib/rpm
cd /mnt
wget http://fc12.arm.loteks.de/fedora-release-12-1.fa2.noarch.rpm
rpm --rebuilddb --root=/mnt/chroot
wget http://fc12.arm.loteks.de/A4D647E9.txt
wget http://fc12.arm.loteks.de/DE7F38BD.txt
rpm --root=/mnt/chroot --import A4D647E9.txt
rpm --root=/mnt/chroot --import DE7F38BD.txt
rpm --root=/mnt/chroot -i fedora-release-12-1.fa2.noarch.rpm
rpm --root=/mnt/chroot --import /mnt/chroot/etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-12-primary

2.) Das Basesystem

wget http://fc12.arm.loteks.de/basesystem-10.0-3.noarch.rpm
wget http://fc12.arm.loteks.de/setup-2.8.9-1.fc12.noarch.rpm
wget http://fc12.arm.loteks.de/filesystem-2.4.30-2.fc12.armv5tel.rpm
rpm --root=/mnt/chroot -i basesystem-10.0-3.noarch.rpm setup-2.8.9-1.fc12.noarch.rpm filesystem-2.4.30-2.fc12.armv5tel.rpm

3.) Die Bash installieren

wget http://fc12.arm.loteks.de/bash-4.0.33-1.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/glibc-common-2.11-2.fa3.armv5tel.rpm
wget http://fc12.arm.loteks.de/glibc-2.11-2.fa3.armv5tel.rpm
wget http://fc12.arm.loteks.de/libgcc-4.4.2-5.fc12.fa4.armv5tel.rpm
wget http://fc12.arm.loteks.de/nss-softokn-freebl-3.12.4-10.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/ncurses-libs-5.7-3.20090207.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/ncurses-base-5.7-3.20090207.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/tzdata-2009o-2.fc12.noarch.rpm
rpm --root=/mnt/chroot -i bash-4.0.33-1.fc12.armv5tel.rpm glibc-common-2.11-2.fa3.armv5tel.rpm glibc-2.11-2.fa3.armv5tel.rpm libgcc-4.4.2-5.fc12.fa4.armv5tel.rpm nss-softokn-freebl-3.12.4-10.fc12.armv5tel.rpm ncurses-libs-5.7-3.20090207.fc12.armv5tel.rpm ncurses-base-5.7-3.20090207.fc12.armv5tel.rpm tzdata-2009o-2.fc12.noarch.rpm

Da es noch keine lokale gibt erscheint jetzt die Fehlermeldung:

/usr/sbin/build-locale-archive: cannot map archive header: Invalid argument
warning: %post(glibc-common-2.11-2.fa3.armv5tel) scriptlet failed, exit status 1

3.) Coreutils

wget http://fc12.arm.loteks.de/coreutils-7.6-5.fc12.fa1.armv5tel.rpm
wget http://fc12.arm.loteks.de/coreutils-libs-7.6-5.fc12.fa1.armv5tel.rpm
wget http://fc12.arm.loteks.de/info-4.13a-7.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/grep-2.5.3-6.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libacl-2.2.47-5.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libattr-2.4.43-4.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libcap-2.16-5.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/pam-1.1.0-7.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libselinux-2.0.87-1.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/ncurses-5.7-3.20090207.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/ncurses-base-5.7-3.20090207.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/util-linux-ng-2.16-10.2.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/zlib-1.2.3-23.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/audit-libs-2.0.1-1.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libsepol-2.0.38-1.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/cracklib-2.8.13-6.armv5tel.rpm
wget http://fc12.arm.loteks.de/cracklib-dicts-2.8.13-6.armv5tel.rpm
wget http://fc12.arm.loteks.de/gzip-1.3.12-11.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/pcre-7.8-3.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/less-436-2.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/db4-4.7.25-13.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/db4-utils-4.7.25-13.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libblkid-2.16-10.2.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/popt-1.13-6.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libuuid-2.16-10.2.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libstdc++-4.4.2-5.fc12.fa4.armv5tel.rpm

rpm --root=/mnt/chroot -i coreutils-7.6-5.fc12.fa1.armv5tel.rpm coreutils-libs-7.6-5.fc12.fa1.armv5tel.rpm info-4.13a-7.fc12.armv5tel.rpm grep-2.5.3-6.fc12.armv5tel.rpm libacl-2.2.47-5.fc12.armv5tel.rpm libattr-2.4.43-4.fc12.armv5tel.rpm libcap-2.16-5.fc12.armv5tel.rpm pam-1.1.0-7.fc12.armv5tel.rpm libselinux-2.0.87-1.fc12.armv5tel.rpm ncurses-5.7-3.20090207.fc12.armv5tel.rpm util-linux-ng-2.16-10.2.fc12.armv5tel.rpm zlib-1.2.3-23.fc12.armv5tel.rpm audit-libs-2.0.1-1.fc12.armv5tel.rpm libsepol-2.0.38-1.fc12.armv5tel.rpm cracklib-2.8.13-6.armv5tel.rpm cracklib-dicts-2.8.13-6.armv5tel.rpm gzip-1.3.12-11.fc12.armv5tel.rpm pcre-7.8-3.fc12.armv5tel.rpm less-436-2.fc12.armv5tel.rpm db4-4.7.25-13.fc12.armv5tel.rpm db4-utils-4.7.25-13.fc12.armv5tel.rpm libblkid-2.16-10.2.fc12.armv5tel.rpm popt-1.13-6.fc12.armv5tel.rpm libuuid-2.16-10.2.fc12.armv5tel.rpm libstdc++-4.4.2-5.fc12.fa4.armv5tel.rpm

4.) Findutils, flex, e2fsprogs, diffutils

wget http://fc12.arm.loteks.de/findutils-4.4.2-4.fc12.armv5tel.rpm
rpm --root=/mnt/chroot -i findutils-4.4.2-4.fc12.armv5tel.rpm

wget http://fc12.arm.loteks.de/flex-2.5.35-7.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/m4-1.4.13-4.fc12.armv5tel.rpm
rpm --root=/mnt/chroot -i flex-2.5.35-7.fc12.armv5tel.rpm m4-1.4.13-4.fc12.armv5tel.rpm

wget http://fc12.arm.loteks.de/e2fsprogs-1.41.9-5.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/e2fsprogs-libs-1.41.9-5.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/e2tools-0.0.16-14.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libcom_err-1.41.9-5.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libss-1.41.9-5.fc12.armv5tel.rpm
rpm --root=/mnt/chroot -i e2tools-0.0.16-14.fc12.armv5tel.rpm e2fsprogs-libs-1.41.9-5.fc12.armv5tel.rpm e2fsprogs-1.41.9-5.fc12.armv5tel.rpm libcom_err-1.41.9-5.fc12.armv5tel.rpm libss-1.41.9-5.fc12.armv5tel.rpm

wget http://fc12.arm.loteks.de/diffutils-2.8.1-25.fc12.armv5tel.rpm
rpm --root=/mnt/chroot -i diffutils-2.8.1-25.fc12.armv5tel.rpm

5.) libtool, autoconf, automake, gcc, sed, binutils, Perl

wget http://fc12.arm.loteks.de/libtool-2.2.6-15.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/autoconf-2.63-3.fc12.noarch.rpm
wget http://fc12.arm.loteks.de/automake-1.11-3.fc12.noarch.rpm
wget http://fc12.arm.loteks.de/gcc-4.4.2-5.fc12.fa4.armv5tel.rpm
wget http://fc12.arm.loteks.de/sed-4.2.1-4.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/cpp-4.4.2-5.fc12.fa4.armv5tel.rpm
wget http://fc12.arm.loteks.de/binutils-2.19.51.0.14-34.fc12.fa1.armv5tel.rpm
wget http://fc12.arm.loteks.de/glibc-devel-2.11-2.fa3.armv5tel.rpm
wget http://fc12.arm.loteks.de/glibc-headers-2.11-2.fa3.armv5tel.rpm
wget http://fc12.arm.loteks.de/libgomp-4.4.2-5.fc12.fa4.armv5tel.rpm
wget http://fc12.arm.loteks.de/gmp-4.3.1-5.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/mpfr-2.4.1-3.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/perl-Module-Pluggable-3.90-82.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/perl-Pod-Simple-3.07-82.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/perl-Pod-Escapes-1.04-82.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/perl-5.10.0-82.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/perl-libs-5.10.0-82.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/perl-version-0.74-82.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/gdbm-1.8.0-33.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/kernel-headers-2.6.31.5-122.fc12.armv5tel.rpm
rpm --root=/mnt/chroot -i kernel-headers-2.6.31.5-122.fc12.armv5tel.rpm perl-5.10.0-82.fc12.armv5tel.rpm perl-libs-5.10.0-82.fc12.armv5tel.rpm perl-version-0.74-82.fc12.armv5tel.rpm gdbm-1.8.0-33.fc12.armv5tel.rpm libtool-2.2.6-15.fc12.armv5tel.rpm autoconf-2.63-3.fc12.noarch.rpm automake-1.11-3.fc12.noarch.rpm gcc-4.4.2-5.fc12.fa4.armv5tel.rpm sed-4.2.1-4.fc12.armv5tel.rpm cpp-4.4.2-5.fc12.fa4.armv5tel.rpm binutils-2.19.51.0.14-34.fc12.fa1.armv5tel.rpm glibc-devel-2.11-2.fa3.armv5tel.rpm glibc-headers-2.11-2.fa3.armv5tel.rpm libgomp-4.4.2-5.fc12.fa4.armv5tel.rpm gmp-4.3.1-5.fc12.armv5tel.rpm mpfr-2.4.1-3.fc12.armv5tel.rpm perl-5.10.0-82.fc12.armv5tel.rpm perl-libs-5.10.0-82.fc12.armv5tel.rpm perl-version-0.74-82.fc12.armv5tel.rpm kernel-headers-2.6.31.5-122.fc12.armv5tel.rpm gdbm-1.8.0-33.fc12.armv5tel.rpm perl-Module-Pluggable-3.90-82.fc12.armv5tel.rpm perl-Pod-Simple-3.07-82.fc12.armv5tel.rpm perl-Pod-Escapes-1.04-82.fc12.armv5tel.rpm

6.) rpm, bzip2, curl, elfutils

wget http://fc12.arm.loteks.de/rpm-4.7.1-6.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/rpm-libs-4.7.1-6.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/curl-7.19.6-10.fc12.fa1.armv5tel.rpm
wget http://fc12.arm.loteks.de/libacl-2.2.47-5.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/bzip2-libs-1.0.5-6.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/bzip2-devel-1.0.5-6.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libcap-2.16-5.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libtdb-1.1.5-2.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/elfutils-0.143-1.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/elfutils-libelf-0.143-1.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/lua-5.1.4-4.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/file-libs-5.03-9.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/nss-3.12.4-14.fc12.fa1.armv5tel.rpm
wget http://fc12.arm.loteks.de/lzma-libs-4.32.7-3.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libselinux-2.0.87-1.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/lzma-4.32.7-3.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/lzma-libs-4.32.7-3.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libcurl-7.19.6-10.fc12.fa1.armv5tel.rpm
wget http://fc12.arm.loteks.de/nspr-4.8.2-1.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/nss-softokn-3.12.4-10.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/nss-util-3.12.4-8.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/elfutils-libs-0.143-1.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libsqlite3x-20071018-8.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/xz-libs-4.999.9-0.1.beta.20091007git.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/krb5-libs-1.7-8.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libidn-1.9-5.armv5tel.rpm
wget http://fc12.arm.loteks.de/openldap-2.4.18-5.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libssh2-1.2-2.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/readline-6.0-3.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/sqlite-3.6.17-1.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/keyutils-libs-1.2-6.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/openssl-1.0.0-0.10.beta3.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/cyrus-sasl-lib-2.1.23-2.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/ca-certificates-2009-2.fc12.noarch.rpm
rpm --root=/mnt/chroot -i rpm-4.7.1-6.fc12.armv5tel.rpm rpm-libs-4.7.1-6.fc12.armv5tel.rpm curl-7.19.6-10.fc12.fa1.armv5tel.rpm bzip2-libs-1.0.5-6.fc12.armv5tel.rpm bzip2-devel-1.0.5-6.fc12.armv5tel.rpm libtdb-1.1.5-2.fc12.armv5tel.rpm elfutils-0.143-1.fc12.armv5tel.rpm elfutils-libelf-0.143-1.fc12.armv5tel.rpm lua-5.1.4-4.fc12.armv5tel.rpm file-libs-5.03-9.fc12.armv5tel.rpm nss-3.12.4-14.fc12.fa1.armv5tel.rpm lzma-libs-4.32.7-3.fc12.armv5tel.rpm lzma-libs-4.32.7-3.fc12.armv5tel.rpm lzma-4.32.7-3.fc12.armv5tel.rpm libcurl-7.19.6-10.fc12.fa1.armv5tel.rpm nspr-4.8.2-1.fc12.armv5tel.rpm nss-3.12.4-14.fc12.fa1.armv5tel.rpm nss-softokn-3.12.4-10.fc12.armv5tel.rpm nss-util-3.12.4-8.fc12.armv5tel.rpm elfutils-libs-0.143-1.fc12.armv5tel.rpm libsqlite3x-20071018-8.fc12.armv5tel.rpm xz-libs-4.999.9-0.1.beta.20091007git.fc12.armv5tel.rpm krb5-libs-1.7-8.fc12.armv5tel.rpm libidn-1.9-5.armv5tel.rpm openldap-2.4.18-5.fc12.armv5tel.rpm libssh2-1.2-2.fc12.armv5tel.rpm readline-6.0-3.fc12.armv5tel.rpm sqlite-3.6.17-1.fc12.armv5tel.rpm keyutils-libs-1.2-6.fc12.armv5tel.rpm openssl-1.0.0-0.10.beta3.fc12.armv5tel.rpm cyrus-sasl-lib-2.1.23-2.fc12.armv5tel.rpm ca-certificates-2009-2.fc12.noarch.rpm

7.) Development Pakete & awk

wget http://fc12.arm.loteks.de/gawk-3.1.7-1.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/keyutils-libs-devel-1.2-6.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/krb5-devel-1.7-8.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libcom_err-devel-1.41.9-5.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libselinux-devel-2.0.87-1.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/libsepol-devel-2.0.38-1.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/openssl-devel-1.0.0-0.10.beta3.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/pkgconfig-0.23-9.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/zlib-devel-1.2.3-23.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/wget-1.11.4-5.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/make-3.81-18.fc12.armv5tel.rpm
wget http://fc12.arm.loteks.de/pam-devel-1.1.0-7.fc12.armv5tel.rpm
rpm --root=/mnt/chroot -i wget-1.11.4-5.fc12.armv5tel.rpm make-3.81-18.fc12.armv5tel.rpm pam-devel-1.1.0-7.fc12.armv5tel.rpm gawk-3.1.7-1.fc12.armv5tel.rpm keyutils-libs-devel-1.2-6.fc12.armv5tel.rpm krb5-devel-1.7-8.fc12.armv5tel.rpm libcom_err-devel-1.41.9-5.fc12.armv5tel.rpm libselinux-devel-2.0.87-1.fc12.armv5tel.rpm libsepol-devel-2.0.38-1.fc12.armv5tel.rpm openssl-devel-1.0.0-0.10.beta3.fc12.armv5tel.rpm pkgconfig-0.23-9.fc12.armv5tel.rpm zlib-devel-1.2.3-23.fc12.armv5tel.rpm

Installierte RPM Pakete anzeigen Lassen:

rpm -qa

Zu welchem RPM Paket gehört die Datei?

rpm -qf /lib/libm.so.6

Kategorien
lighttpd Linux

Lighttpd 1.5 – rebuild

System vorbereiten

aptitude install checkinstall python-mysqldb liblua5.1-dev libmysqlclient-dev \
libssl-dev libbz2-dev libpcre3-dev libgtkhtml2-0 libgtkhtml2-dev \
libsqlite-dev libsqlite3-dev libmemcache-dev libaio-dev libldap2-dev \
automake1.9 libgeoip-dev e2fsprogs e2fsprogs-devel \
aptitude remove --purge automake1.4 automake1.7 automake1.8

alleine wegen den Konfigurations und startscripten:

aptitude install lighttpd

Quellen herunterladen

cd /usr/src svn co svn://svn.lighttpd.net/lighttpd/trunk/
mv /usr/src/trunk /usr/src/lighttpd-1.5.0
cd /usr/src/lighttpd-1.5.0
./autogen.sh

GeoIP Modul für Lighttpd 1.5

wget http://redmine.lighttpd.net/attachments/download/717/mod_geoip_for_1.5.c
mv mod_geoip_for_1.5.c src/mod_geoip.c
vi src/Makefile.am
nach der letzter "lib_LTLIBRARIES" Zeile folgendes einfügen:
lib_LTLIBRARIES += mod_geoip.la
mod_geoip_la_SOURCES = mod_geoip.c
mod_geoip_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_geoip_la_LIBADD = $(common_libadd) -lGeoIP

GeoIP Datenbanken herunterladen

wget -O /var/www/GeoIP.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
wget -O /var/www/GeoLiteCity.dat.gz http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip /var/www/*.dat.gz

 

/etc/lighttpd/conf-available/10-geoip.conf
#### GeoIP
geoip.db-filename = “/var/www/GeoIP.dat”
geoip.memory-cache = “enable”
#### GeoIP Lite City
# geoip.db-filename = “/var/www/GeoLiteCity.dat”
# geoip.memory-cache = disable
server.modulesi += ( “mod_geoip” )

./configure –enable-maintainer-mode –prefix=/usr –with-openssl –with-lua=lua5.1 –with-memcache –with-gdbm –with-webdav-props –with-ldap –with-attr –with-linux-aio –with-mysql –with-webdav-locks

make
checkinstall –install=no -D –default –pakdir=/usr/src –gzman=yes

aptitude remove lighttpd

dpkg -i lighttpd_1.5.0-1_i386.deb

Kategorien
Programmieren

“Hallo Welt” in C detailliert erklärt

Hallo Welt in C99:

#include

int main(void){
printf("hello world!\n");
return 0;
}

Explain the Source:

Zeile 1:
holen der stdio.h aus der standart C Bibiothek welche unter anderem die Funktion printf für die Textausgabe in Zeile 4 enthält.

Zeile 3:
Definition der Funktion mit dem Namen main welche einen int Wert als Rückgabe liefern wird, void bedeutet hierbei das an diese Funktion keine Werte übergeben werden.

Zeile 4:
Es wird die Funktion printf ausgeführt, welche den übergebenen Text in die Standartausgabe zurückgibt. Die Zeichenfolge “\n” erzeugt einen Unix Zeilenumbruch. (DOS “\r\n”, MAC “\r”)

Zeile 5:
Die Funktion main wird abgebrochen und 0 als Fehlercode übergeben. 0 bedeutet das das Programm fehlerfrei beendet wurde.