Waou ! This is great ! Thanks for this<br><br>Hum, I just tried and I got this error:<br><br>debian-gta02:~# apt-get-file install <a href="http://projects.openmoko.org/frs/download.php/575/ledclock_0.6_all.ipk">http://projects.openmoko.org/frs/download.php/575/ledclock_0.6_all.ipk</a><br>
trap: 26: ERR: bad trap<br><br>Any clue ?<br><br><br><div class="gmail_quote">2009/5/10 Rask Ingemann Lambertsen <span dir="ltr"><<a href="mailto:rask@sygehus.dk">rask@sygehus.dk</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
For part 1, please see the mailing list archive:<br>
<a href="http://lists.openmoko.org/pipermail/community/2009-March/043753.html" target="_blank">http://lists.openmoko.org/pipermail/community/2009-March/043753.html</a><br>
<br>
Below you will find a shell script to install a package from a .deb, .opk<br>
or .ipk file on a Debian system. It will<br>
<br>
- download the package if necessary.<br>
- repack gzipped tar archives if necessary (some *.ipk).<br>
- edit the control file for Debian compatibility (*.opk and *.ipk).<br>
- jump through hoops so apt-get can be used for installation,<br>
so dependencies can be resolved necessary.<br>
- delete all temporary files created.<br>
<br>
Dependencies: dpkg-dev wget file binutils tar gzip<br>
<br>
Usage: apt-get-file [--verbose] install <file> [apt-get options]<br>
<br>
I'm sure there are still small bugs around the edges, so this is only<br>
alpha quality. I'm posting the script now because it mostly does what it's<br>
supposed to do and I want to get some feedback.<br>
<br>
Example run:<br>
<br>
# ~rask/bin/apt-get-file install <a href="http://projects.openmoko.org/frs/download.php/575/ledclock_0.6_all.ipk%0A--2009-05-10" target="_blank">http://projects.openmoko.org/frs/download.php/575/ledclock_0.6_all.ipk<br>
--2009-05-10</a> 06:49:26-- <a href="http://projects.openmoko.org/frs/download.php/575/ledclock_0.6_all.ipk" target="_blank">http://projects.openmoko.org/frs/download.php/575/ledclock_0.6_all.ipk</a><br>
Resolving projects.openmoko.org... 88.198.93.218<br>
Connecting to <a href="http://projects.openmoko.org" target="_blank">projects.openmoko.org</a>|88.198.93.218|:80... connected.<br>
HTTP request sent, awaiting response... 200 OK<br>
Length: 13214 (13K) [application/binary]<br>
Saving to: `ledclock_0.6_all.ipk'<br>
<br>
100%[================================================================>] 13,214 --.-K/s in 0.1s<br>
<br>
2009-05-10 06:49:28 (99.5 KB/s) - `ledclock_0.6_all.ipk' saved [13214/13214]<br>
<br>
** Packages in archive but missing from override file: **<br>
ledclock<br>
<br>
Wrote 1 entries to output Packages file.<br>
Reading package lists... Done<br>
Building dependency tree<br>
Reading state information... Done<br>
The following extra packages will be installed:<br>
python-pygtk python-subprocess python2.6-minimal<br>
Suggested packages:<br>
binfmt-support<br>
Recommended packages:<br>
python2.6<br>
The following NEW packages will be installed:<br>
ledclock python-pygtk python-subprocess python2.6-minimal<br>
0 upgraded, 4 newly installed, 0 to remove and 112 not upgraded.<br>
Need to get 1331kB/1344kB of archives.<br>
After this operation, 4780kB of additional disk space will be used.<br>
Do you want to continue [Y/n]?<br>
WARNING: The following packages cannot be authenticated!<br>
python-pygtk python-subprocess ledclock<br>
Install these packages without verification [y/N]? y<br>
Get:1 <a href="http://ftp.dk.debian.org" target="_blank">http://ftp.dk.debian.org</a> experimental/main python2.6-minimal 2.6.1-3 [1330kB]<br>
Get:2 <a href="http://nospamnospam.homepage.dk" target="_blank">http://nospamnospam.homepage.dk</a> python-pygtk 2.14.1-2 [576B]<br>
Get:3 <a href="http://nospamnospam.homepage.dk" target="_blank">http://nospamnospam.homepage.dk</a> python-subprocess 2.6.1-3 [582B]<br>
Fetched 1331kB in 2s (451kB/s)<br>
debconf: delaying package configuration, since apt-utils is not installed<br>
Selecting previously deselected package python-pygtk.<br>
(Reading database ... 45694 files and directories currently installed.)<br>
Unpacking python-pygtk (from .../python-pygtk_2.14.1-2_all.deb) ...<br>
Selecting previously deselected package python2.6-minimal.<br>
Unpacking python2.6-minimal (from .../python2.6-minimal_2.6.1-3_armel.deb) ...<br>
Selecting previously deselected package python-subprocess.<br>
Unpacking python-subprocess (from .../python-subprocess_2.6.1-3_all.deb) ...<br>
Selecting previously deselected package ledclock.<br>
Unpacking ledclock (from .../ledclock_0.6_all.deb) ...<br>
Processing triggers for man-db ...<br>
Setting up python-pygtk (2.14.1-2) ...<br>
Setting up python2.6-minimal (2.6.1-3) ...<br>
Could not find platform dependent libraries <exec_prefix><br>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]<br>
Setting up python-subprocess (2.6.1-3) ...<br>
Setting up ledclock (0.6) ...<br>
#<br>
<br>
And the script itself:<br>
<br>
#!/bin/sh<br>
<br>
# apt-get-file - Install package from .deb, .opk or .ipk file.<br>
# Copyright (c) 2009 Rask Ingemann Lambertsen <<a href="mailto:ccc94453@vip.cybercity.dk">ccc94453@vip.cybercity.dk</a>><br>
<br>
# This program is free software: you can redistribute it and/or modify<br>
# it under the terms of the GNU General Public License version 3 as<br>
# published by the Free Software Foundation.<br>
<br>
# This program is distributed in the hope that it will be useful,<br>
# but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>
# GNU General Public License for more details.<br>
<br>
# You should have received a copy of the GNU General Public License<br>
# along with this program. If not, see <<a href="http://www.gnu.org/licenses/" target="_blank">http://www.gnu.org/licenses/</a>>.<br>
<br>
exit_clean () {<br>
cd / || true<br>
[ -z "${APTSRC}" ] || rm -rf -- "${APTSRC}"<br>
[ -z "${APTLIST}" ] || rm -rf -- "${APTLIST}"<br>
[ -z "${PKG_TMPDIR}" ] || rm -rf -- "${PKG_TMPDIR}"<br>
exit 1<br>
}<br>
<br>
trap exit_clean ERR<br>
set -o errexit<br>
set -o errtrace<br>
<br>
if [ "--verbose" = "$1" ]; then<br>
shift<br>
AR_VERBOSE=v<br>
TAR_VERBOSE=v<br>
set -o xtrace<br>
else<br>
AR_VERBOSE=<br>
TAR_VERBOSE=<br>
fi<br>
<br>
if [ "install" != "$1" ]; then<br>
echo "Usage: $0 [--verbose] install <file> <apt-get options>"<br>
exit 1<br>
fi<br>
shift<br>
<br>
PKG_URL="$1"; shift<br>
PKG_FILE=$(basename "${PKG_URL}")<br>
<br>
case "${PKG_FILE}" in<br>
*.opk)<br>
PKG_FORMAT=opk<br>
;;<br>
*.deb)<br>
PKG_FORMAT=deb<br>
;;<br>
*)<br>
PKG_FORMAT=ipk<br>
;;<br>
esac<br>
<br>
PKG_TMPDIR=$(mktemp -d)<br>
cd "${PKG_TMPDIR}" || exit $?<br>
<br>
# A debian package file can be used directly, everything else<br>
# needs a copy.<br>
case "${PKG_URL}" in<br>
http://* | https://* | ftp://*)<br>
wget -O "${PKG_FILE}" -- "${PKG_URL}"<br>
;;<br>
*)<br>
PKG_URL=$(echo "${PKG_URL}" | sed -e 's/^file://')<br>
if [ "deb" = "${PKG_FORMAT}" ]; then<br>
ln -s "${PKG_URL}" "${PKG_FILE}"<br>
else<br>
cp "${PKG_URL}" "${PKG_FILE}"<br>
fi<br>
;;<br>
esac<br>
<br>
PKG_DEB=$(echo "${PKG_FILE}" | sed -e 's/\.[^.]*$/.deb/')<br>
PKG_FILE_FORMAT=$(file --brief --dereference -- "${PKG_FILE}")<br>
<br>
case "${PKG_FILE_FORMAT}" in<br>
"gzip compressed data"*)<br>
PKG_FORMAT=ipk<br>
;;<br>
"Debian binary package"*)<br>
if [ "ipk" = "${PKG_FORMAT}" ]; then<br>
PKG_FORMAT=opk<br>
fi<br>
;;<br>
*)<br>
echo "Unsupported package format ${PKG_FILE_FORMAT}.";<br>
exit 1<br>
;;<br>
esac<br>
<br>
# Unpack the package if not .deb format.<br>
case "${PKG_FORMAT}" in<br>
ipk)<br>
tar -zx${TAR_VERBOSE}f "${PKG_FILE}"<br>
rm -f "${PKG_FILE}"<br>
;;<br>
opk)<br>
ar xo${AR_VERBOSE} "${PKG_FILE}" control.tar.gz<br>
mv "${PKG_FILE}" "${PKG_DEB}"<br>
;;<br>
esac<br>
<br>
# Debian uses architectures 'armel' and 'all'. There appears to<br>
# be no way of telling dpkg/APT of compatible architectures.<br>
# Edit the control file.<br>
if [ "${PKG_FORMAT}" != "deb" ]; then<br>
mkdir control<br>
tar -C control -zx${TAR_VERBOSE}f control.tar.gz<br>
<br>
sed -i -e 's/^Architecture: any$/Architecture: all/' \<br>
-e 's/^Architecture: \(armv[1234]t\?\|arm\|om-gta02\)$/Architecture: armel/' \<br>
control/control<br>
<br>
(cd control && tar -zc${TAR_VERBOSE}f ../control.tar.gz *)<br>
fi<br>
<br>
# Repack the .ipk or .opk package as .deb.<br>
if [ "ipk" = "${PKG_FORMAT}" ]; then<br>
ar qc${AR_VERBOSE} "${PKG_DEB}" debian-binary control.tar.gz data.tar.gz<br>
elif [ "opk" = "${PKG_FORMAT}" ]; then<br>
ar r${AR_VERBOSE} "${PKG_DEB}" control.tar.gz<br>
fi<br>
<br>
# What follows is an ugly hack, but you just can't pass a filename to<br>
# apt-get. So fake a repository with the package in it and install it<br>
# by package name.<br>
<br>
# mktemp brain damage: You can't make a file ending in .list.<br>
APTSRC=$(mktemp /etc/apt/sources.list.d/00-apt-get-file-XXXXXXXXXX)<br>
ln "${APTSRC}" "${APTSRC}.list" && rm -f "${APTSRC}"<br>
APTSRC="${APTSRC}.list"<br>
echo "deb file:${PKG_TMPDIR}/ /" >"${APTSRC}"<br>
<br>
APTLIST=/var/lib/apt/lists/$(echo "${PKG_TMPDIR}/Packages" | tr / _)<br>
dpkg-scanpackages . /dev/null | sed -e 's_^Filename: ./_Filename: _' >"${APTLIST}"<br>
<br>
PKG_NAME=$(dpkg-deb --field "${PKG_DEB}" Package)<br>
apt-get install "$@" "${PKG_NAME}"<br>
<br>
# Clean up.<br>
cd /<br>
rm -r -f -- "${APTSRC}" "${APTLIST}" "${PKG_TMPDIR}"<br>
<font color="#888888"><br>
<br>
--<br>
Rask Ingemann Lambertsen<br>
Danish law requires addresses in e-mail to be logged and stored for a year<br>
<br>
_______________________________________________<br>
Openmoko community mailing list<br>
<a href="mailto:community@lists.openmoko.org">community@lists.openmoko.org</a><br>
<a href="http://lists.openmoko.org/mailman/listinfo/community" target="_blank">http://lists.openmoko.org/mailman/listinfo/community</a><br>
</font></blockquote></div><br>