mercoledì 23 marzo 2011

Repository optware sulla Fonera 2.0n

Aggiungendo il repository di ipkg.nslu2-linux.org alla fonera si possono installare molti più programmi di quelli disponibili sul repo di openwrt.
In giro si trovano diverse soluzioni ognuna leggermente diversa per piccole differenze, ma fondamentalmente bisogna aggiungere l'indirizzo del repository nel file "/etc/opkg.conf" aggiungere al path la cartella "/opt" e le cartelle contenti le librerie.
L'hard disk usb nel mio caso è formattato in ext3.
Ottenuto l'accesso ssh alla fonera editiamo il file "/etc/opkg.conf"
vi /etc/opkg.conf
src snapshots http://downloads.openwrt.org/kamikaze/8.09.2/brcm-2.4/packages
#src snapshots2 http://ipkg2.nslu2-linux.org/feeds/optware/openwrt-brcm24/cross/stable
dest root /
dest ram /tmp
dest usb /tmp/mounts/Disc-A1
lists_dir ext /var/opkg-lists
Digitate <ESC> ":wq" per salvare e chiudere l'editor. Con "dest usb /tmp/mounts/Disc-A1" abbiamo aggiunto come destinazione per opkg l'hard disk o pen drive usb, mi raccomando di sostiture la destinazione con quella della vostra periferica.
EDIT: è prefereribile tenere un solo repository attivo per volta così da poter scegliere con chiarezza quello in uso.
mkdir -p /usr/lib/opkg
opkg update
così creiamo una cartella necessaria a opkg e aggiorniamo la lista dei pacchetti disponibili.
opkg -dest usb install ldconfig
così installiamo ldconfig necessario per far trovare le librerie al sistema senza aggiungerne la destinazione in "/etc/profile"
vi /etc/ld.so.conf
/opt/lib
/opt/usr/lib
/tmp/mounts/Disc-A1/usr/lib
/tmp/mounts/Disc-A1/lib
Aggiungiamo al profilo le parti in rosso
vi /etc/profile
ext_path='/tmp/mounts/Disc-A1'
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:$ext_path/bin:$ext_path/sbin:$ext_path/usr/bin:$ext_path/usr/sbin:/opt/bin:/opt/sbin
. /etc/profile
per ricaricare il profilo senza riavviare
questo altro script serve per non avere l'errore postinst 127 dopo l'installazione di un pacchetto dal repo di nslu2-linux.org
mkdir -p /tmp/mounts/Disc-A1/opt/bin
cd /tmp/mounts/Disc-A1/opt/bin/
vi update-alternatives
incollate il seguente codice:
#!/bin/sh
# update-alternatives
#
# Copyright (C) 2001 Carl D. Worth
#
# This program was inspired by the Debian update-alternatives program
# which is Copyright (C) 1995 Ian Jackson. This version of
# update-alternatives is command-line compatible with Debian's for a
# subset of the options, (only --install, --remove, and --help)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

set -e

# admin dir
ad="$IPKG_OFFLINE_ROOT/usr/lib/ipkg/alternatives"

usage() {
echo "update-alternatives: $*

Usage: update-alternatives --install

update-alternatives --remove
update-alternatives --help

is the link pointing to the provided path (ie. /usr/bin/foo).
is the name in $ad/alternatives (ie. foo)

is the name referred to (ie. /usr/bin/foo-extra-spiffy)

is an integer; options with higher numbers are chosen.
" >&2
exit 2
}

quit() {
echo "update-alternatives: $*" >&2
exit 2
}

register_alt() {
[ $# -lt 2 ] && return 1
local name="$1"
local link="$2"

if [ ! -d $ad ]; then
mkdir -p $ad
fi

if [ -e "$ad/$name" ]; then
local olink=`head -n 1 $ad/$name`
if [ "$link" != "$olink" ]; then
echo "update-alternatives: Error: cannot register alternative $name to $link since it is already registered to $olink" >&2
return 1
fi
else
echo "$link" > "$ad/$name"
fi

return 0
}

protect_slashes() {
sed -e 's/\//\\\//g'
}

remove_alt() {
[ $# -lt 2 ] && return 1
local name="$1"
local path="$2"

[ ! -f $ad/$name ] && return 0

path=`echo $path | protect_slashes`
sed -ne "/^$path\>.*/!p" $ad/$name > $ad/$name.new
mv $ad/$name.new $ad/$name
}

add_alt() {
[ $# -lt 3 ] && return 1
local name="$1"
local path="$2"
local priority="$3"
remove_alt $name $path
echo "$path $priority" >> $ad/$name
}

find_best_alt() {
[ $# -lt 1 ] && return 1
[ ! -f $ad/$name ] && return 0

link=$IPKG_OFFLINE_ROOT/`head -n 1 $ad/$name`

## path=`sed -ne "1!p" $ad/$name | sort -nr -k2 | head -1 | sed 's/ .*//'`
## busybox safe:
path=`sed -ne "1!p" $ad/$name | sed -e "s/\(.*\) \(.*\)/\2 \1/g" | sort -nr | head -n 1 | sed 's/[^ ]* //'`
if [ -z "$path" ]; then
echo "update-alternatives: removing $link as no more alternatives exist for it"
rm $ad/$name
if [ -L $link ]; then
rm $link
fi
return 0
fi

if [ ! -e $link -o -L $link ]; then
local link_dir=`dirname $link`
if [ ! -d $link_dir ]; then
mkdir -p $link_dir
fi
ln -sf $path $link
echo "update-alternatives: Linking $link to $path"
else
echo "update-alternatives: Error: not linking $link to $path since $link exists and is not a link"
return 1
fi

return 0
}

do_install() {
if [ $# -lt 4 ]; then
usage "--install needs

"
fi
local link="$1"
local name="$2"
local path="$3"
local priority="$4"

path=`echo $path | sed 's|/\+|/|g'`

# This is a bad hack, but I haven't thought of a cleaner solution yet...
[ -n "$IPKG_OFFLINE_ROOT" ] && path=`echo $path | sed "s|^$IPKG_OFFLINE_ROOT/*|/|"`

register_alt $name $link
add_alt $name $path $priority
find_best_alt $name
}

do_remove() {
if [ $# -lt 2 ]; then
usage "--remove needs
"
fi
local name="$1"
local path="$2"

path=`echo $path | sed 's|/\+|/|g'`

# This is a bad hack, but I haven't thought of a cleaner solution yet...
[ -n "$IPKG_OFFLINE_ROOT" ] && path=`echo $path | sed "s|^$IPKG_OFFLINE_ROOT/*|/|"`

remove_alt $name $path
find_best_alt $name
}

###
# update-alternatives "main"
###

while [ $# -gt 0 ]; do
arg="$1"
shift

case $arg in
--help)
usage "help:"
exit 0
;;
--install)
do_install $*
exit $?
;;
--remove)
do_remove $*
exit $?
;;
*)
usage "unknown argument \`$arg'"
;;
esac
done

usage "at least one of --install or --remove must appear"

exit 0
chmod +x update-alternatives
opkg update
ln -s /tmp/mounts/Disc-A1/opt /opt
L'ultimo comando crea un link simbolico tra l'hd e la flash interna. Dopo aver installato un qualsiasi programma vi dovrebbe bastare usare ldconfig per indicizzare (credo) le librerie.
ldconfig -p
dà la lista con le librerie trovate.
opkg -dest usb install NOMEPACCHETTO
Per installare qualsiasi pacchetto sull'hd.
Se il pacchetto proviene da nslu2-linux.org sarà installato in "/tmp/mounts/Disc-A1/opt" e se invece è di openwrt sarà installato in "/tmp/mounts/Disc-A1" in ogni caso verrà trovato dal sistema.
Spero di essere stato chiaro e in qualche modo d'aiuto ;)

---Aggiornamento---
Mi ero dimenticato di scrivere come aggiungere gli script necessari per quei pacchetti installati da nslu2-linux.org che contengono uno script all'avvio (mysql, lighttpd, etc..)
vi /etc/init.d/optware
come prima incollate il codice:
#!/bin/sh /etc/rc.common

START=80

start() {
echo "Starting Optware."
[ -x /opt/etc/rc.optware ] && /opt/etc/rc.optware start
}

stop() {
echo "Shutting down Optware."
[ -x /opt/etc/rc.optware ] && /opt/etc/rc.optware stop
}
chmod +x /etc/init.d/optware
mkdir -p /opt/etc
vi /opt/etc/rc.optware
codice:
#!/bin/sh

# Start all init scripts in /opt/etc/init.d
# executing them in numerical order.
#
if [ x$1 == xstop ] ; then
progs="/opt/etc/init.d/K??*"
rc=stop
else
progs="/opt/etc/init.d/S??*"
rc=start
fi

for i in $progs ;do

# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue

echo starting $i
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set $rc
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i $rc
;;
esac
done
chmod +x /opt/etc/rc.optware
e infine per abilitare lo script come si fa su openwrt dare
/etc/init.d/optware enable
Quest'ultimo passaggio non l'ho testato sulla fonera2.0n ma su openwrt (ovviamente) funziona.

Fonti:



1 commento:

  1. Se il pacchetto proviene da nslu2-linux.org sarà installato in "/tmp/mounts/Disc-A1/opt" e se invece è di openwrt sarà installato in "/tmp/mounts/Disc-A1" in ogni caso verrà trovato dal sistema.
    shawls for dresses , shawls for women , shawls for sale , black shawl , white shawl , shawl , silver shawl , gold shawl , navy shawl , woolen shawl

    RispondiElimina