| 1 |
# ipkg - the itsy package management system |
|---|
| 2 |
# |
|---|
| 3 |
# Copyright (C) 2001 Carl D. Worth |
|---|
| 4 |
# |
|---|
| 5 |
# This program is free software; you can redistribute it and/or modify |
|---|
| 6 |
# it under the terms of the GNU General Public License as published by |
|---|
| 7 |
# the Free Software Foundation; either version 2, or (at your option) |
|---|
| 8 |
# any later version. |
|---|
| 9 |
# |
|---|
| 10 |
# This program is distributed in the hope that it will be useful, |
|---|
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 |
# GNU General Public License for more details. |
|---|
| 14 |
|
|---|
| 15 |
set -e |
|---|
| 16 |
|
|---|
| 17 |
# By default do not do globbing. Any command wanting globbing should |
|---|
| 18 |
# explicitly enable it first and disable it afterwards. |
|---|
| 19 |
set -o noglob |
|---|
| 20 |
|
|---|
| 21 |
ipkg_is_upgrade () { |
|---|
| 22 |
local A B a b |
|---|
| 23 |
A=$(echo $1 | sed -r "s/([0-9]+)[^[:alnum:]]*/ \1 /g"). |
|---|
| 24 |
B=$(echo $2 | sed -r "s/([0-9]+)[^[:alnum:]]*/ \1 /g"). |
|---|
| 25 |
while [ \! -z "$A" ] && [ \! -z "$B" ]; do { |
|---|
| 26 |
set $A; a=$1; shift; A=$* |
|---|
| 27 |
set $B; b=$1; shift; B=$* |
|---|
| 28 |
[ "$a" -lt "$b" ] 2>&- && return 1 ||: |
|---|
| 29 |
{ [ "$a" -gt "$b" ] 2>&- || [ "$a" ">" "$b" ]; } && return ||: |
|---|
| 30 |
}; done |
|---|
| 31 |
return 1 |
|---|
| 32 |
} |
|---|
| 33 |
|
|---|
| 34 |
ipkg_srcs() { |
|---|
| 35 |
local srcre="$1" |
|---|
| 36 |
sed -ne "s/^src[[:space:]]\+$srcre[[:space:]]\+//p" < $IPKG_CONF |
|---|
| 37 |
} |
|---|
| 38 |
|
|---|
| 39 |
ipkg_src_names() { |
|---|
| 40 |
sed -ne "s/^src[[:space:]]\+\([^[:space:]]\+\).*/\1/p" < $IPKG_CONF |
|---|
| 41 |
} |
|---|
| 42 |
|
|---|
| 43 |
ipkg_src_byname() { |
|---|
| 44 |
local src="$1" |
|---|
| 45 |
ipkg_srcs $src | head -n 1 |
|---|
| 46 |
} |
|---|
| 47 |
|
|---|
| 48 |
ipkg_dests() { |
|---|
| 49 |
local destre="`echo $1 | ipkg_protect_slashes`" |
|---|
| 50 |
sed -ne "/^dest[[:space:]]\+$destre/{ |
|---|
| 51 |
s/^dest[[:space:]]\+[^[:space:]]\+[[:space:]]\+// |
|---|
| 52 |
s/^/`echo $IPKG_OFFLINE_ROOT | ipkg_protect_slashes`/ |
|---|
| 53 |
p |
|---|
| 54 |
}" < $IPKG_CONF |
|---|
| 55 |
} |
|---|
| 56 |
|
|---|
| 57 |
ipkg_dest_names() { |
|---|
| 58 |
sed -ne "s/^dest[[:space:]]\+\([^[:space:]]\+\).*/\1/p" < $IPKG_CONF |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
ipkg_dests_all() { |
|---|
| 62 |
ipkg_dests '.*' |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
ipkg_state_dirs() { |
|---|
| 66 |
ipkg_dests_all | sed "s|\$|/$IPKG_DIR_PREFIX|" |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
ipkg_dest_default() { |
|---|
| 70 |
ipkg_dests_all | head -n 1 |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
ipkg_dest_default_name() { |
|---|
| 74 |
ipkg_dest_names | head -n 1 |
|---|
| 75 |
} |
|---|
| 76 |
|
|---|
| 77 |
ipkg_dest_byname() { |
|---|
| 78 |
local dest="$1" |
|---|
| 79 |
ipkg_dests $dest | head -n 1 |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
ipkg_option() { |
|---|
| 83 |
local option="$1" |
|---|
| 84 |
sed -ne "s/^option[[:space:]]\+$option[[:space:]]\+//p" < $IPKG_CONF |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
ipkg_load_configuration() { |
|---|
| 88 |
if [ -z "$IPKG_CONF_DIR" ]; then |
|---|
| 89 |
IPKG_CONF_DIR=/etc |
|---|
| 90 |
fi |
|---|
| 91 |
|
|---|
| 92 |
IPKG_CONF="$IPKG_CONF_DIR/ipkg.conf" |
|---|
| 93 |
|
|---|
| 94 |
if [ -z "$IPKG_OFFLINE_ROOT" ]; then |
|---|
| 95 |
IPKG_OFFLINE_ROOT="`ipkg_option offline_root`" |
|---|
| 96 |
fi |
|---|
| 97 |
# Export IPKG_OFFLINE_ROOT for use by update-alternatives |
|---|
| 98 |
export IPKG_OFFLINE_ROOT |
|---|
| 99 |
if [ -n "$DEST_NAME" ]; then |
|---|
| 100 |
IPKG_ROOT="`ipkg_dest_byname $DEST_NAME`" |
|---|
| 101 |
if [ -z "$IPKG_ROOT" ]; then |
|---|
| 102 |
if [ -d "$IPKG_OFFLINE_ROOT$DEST_NAME" ]; then |
|---|
| 103 |
IPKG_ROOT="$IPKG_OFFLINE_ROOT$DEST_NAME"; |
|---|
| 104 |
else |
|---|
| 105 |
echo "ipkg: invalid destination specification: $DEST_NAME |
|---|
| 106 |
Valid destinations are directories or one of the dest names from $IPKG_CONF:" >&2 |
|---|
| 107 |
ipkg_dest_names >&2 |
|---|
| 108 |
return 1 |
|---|
| 109 |
fi |
|---|
| 110 |
fi |
|---|
| 111 |
else |
|---|
| 112 |
IPKG_ROOT="`ipkg_dest_default`" |
|---|
| 113 |
fi |
|---|
| 114 |
|
|---|
| 115 |
# Global ipkg state directories |
|---|
| 116 |
IPKG_DIR_PREFIX=usr/lib/ipkg |
|---|
| 117 |
IPKG_LISTS_DIR=$IPKG_OFFLINE_ROOT/$IPKG_DIR_PREFIX/lists |
|---|
| 118 |
IPKG_PENDING_DIR=$IPKG_OFFLINE_ROOT/$IPKG_DIR_PREFIX/pending |
|---|
| 119 |
if [ -z "$IPKG_TMP" ]; then |
|---|
| 120 |
IPKG_TMP=$IPKG_ROOT/tmp/ipkg |
|---|
| 121 |
fi |
|---|
| 122 |
|
|---|
| 123 |
[ -e "$IPKG_TMP" ] || mkdir -p $IPKG_TMP |
|---|
| 124 |
|
|---|
| 125 |
# Destination specific ipkg meta-data directory |
|---|
| 126 |
IPKG_STATE_DIR=$IPKG_ROOT/$IPKG_DIR_PREFIX |
|---|
| 127 |
|
|---|
| 128 |
# Proxy Support |
|---|
| 129 |
IPKG_PROXY_USERNAME="`ipkg_option proxy_username`" |
|---|
| 130 |
IPKG_PROXY_PASSWORD="`ipkg_option proxy_password`" |
|---|
| 131 |
IPKG_HTTP_PROXY="`ipkg_option http_proxy`" |
|---|
| 132 |
IPKG_FTP_PROXY="`ipkg_option ftp_proxy`" |
|---|
| 133 |
IPKG_NO_PROXY="`ipkg_option no_proxy`" |
|---|
| 134 |
if [ -n "$IPKG_HTTP_PROXY" ]; then |
|---|
| 135 |
export http_proxy="$IPKG_HTTP_PROXY" |
|---|
| 136 |
fi |
|---|
| 137 |
|
|---|
| 138 |
if [ -n "$IPKG_FTP_PROXY" ]; then |
|---|
| 139 |
export ftp_proxy="$IPKG_FTP_PROXY" |
|---|
| 140 |
fi |
|---|
| 141 |
|
|---|
| 142 |
if [ -n "$IPKG_NO_PROXY" ]; then |
|---|
| 143 |
export no_proxy="$IPKG_NO_PROXY" |
|---|
| 144 |
fi |
|---|
| 145 |
|
|---|
| 146 |
IPKG_STATUS_FIELDS='\(Package\|Status\|Essential\|Version\|Conffiles\|Root\)' |
|---|
| 147 |
} |
|---|
| 148 |
|
|---|
| 149 |
ipkg_usage() { |
|---|
| 150 |
[ $# -gt 0 ] && echo "ipkg: $*" ||: |
|---|
| 151 |
echo " |
|---|
| 152 |
usage: ipkg [options...] sub-command [arguments...] |
|---|
| 153 |
where sub-command is one of: |
|---|
| 154 |
|
|---|
| 155 |
Package Manipulation: |
|---|
| 156 |
update Update list of available packages |
|---|
| 157 |
upgrade Upgrade all installed packages to latest version |
|---|
| 158 |
install <pkg> Download and install <pkg> (and dependencies) |
|---|
| 159 |
install <file.ipk> Install package <file.ipk> |
|---|
| 160 |
install <file.deb> Install package <file.deb> |
|---|
| 161 |
remove <pkg> Remove package <pkg> |
|---|
| 162 |
|
|---|
| 163 |
Informational Commands: |
|---|
| 164 |
list List available packages and descriptions |
|---|
| 165 |
files <pkg> List all files belonging to <pkg> |
|---|
| 166 |
search <file> Search for a packaging providing <file> |
|---|
| 167 |
info [pkg [<field>]] Display all/some info fields for <pkg> or all |
|---|
| 168 |
status [pkg [<field>]] Display all/some status fields for <pkg> or all |
|---|
| 169 |
depends <pkg> Print uninstalled package dependencies for <pkg> |
|---|
| 170 |
|
|---|
| 171 |
Options: |
|---|
| 172 |
-d <dest_name> Use <dest_name> as the the root directory for |
|---|
| 173 |
-dest <dest_name> package installation, removal, upgrading. |
|---|
| 174 |
<dest_name> should be a defined dest name from the |
|---|
| 175 |
configuration file, (but can also be a directory |
|---|
| 176 |
name in a pinch). |
|---|
| 177 |
-o <offline_root> Use <offline_root> as the root for offline installation. |
|---|
| 178 |
-offline <offline_root> |
|---|
| 179 |
|
|---|
| 180 |
Wget Options: |
|---|
| 181 |
-q Quiet option for wget |
|---|
| 182 |
-c Continue option for wget |
|---|
| 183 |
|
|---|
| 184 |
Force Options (use when ipkg is too smart for its own good): |
|---|
| 185 |
-force-depends Make dependency checks warnings instead of errors |
|---|
| 186 |
-force-defaults Use default options for questions asked by ipkg. |
|---|
| 187 |
(no prompts). Note that this will not prevent |
|---|
| 188 |
package installation scripts from prompting. |
|---|
| 189 |
" >&2 |
|---|
| 190 |
exit 1 |
|---|
| 191 |
} |
|---|
| 192 |
|
|---|
| 193 |
ipkg_dir_part() { |
|---|
| 194 |
local dir="`echo $1 | sed -ne 's/\(.*\/\).*/\1/p'`" |
|---|
| 195 |
if [ -z "$dir" ]; then |
|---|
| 196 |
dir="./" |
|---|
| 197 |
fi |
|---|
| 198 |
echo $dir |
|---|
| 199 |
} |
|---|
| 200 |
|
|---|
| 201 |
ipkg_file_part() { |
|---|
| 202 |
echo $1 | sed 's/.*\///' |
|---|
| 203 |
} |
|---|
| 204 |
|
|---|
| 205 |
ipkg_protect_slashes() { |
|---|
| 206 |
sed -e 's/\//\\\//g' |
|---|
| 207 |
} |
|---|
| 208 |
|
|---|
| 209 |
ipkg_download() { |
|---|
| 210 |
local src="$1" |
|---|
| 211 |
local dest="$2" |
|---|
| 212 |
|
|---|
| 213 |
local src_file="`ipkg_file_part $src`" |
|---|
| 214 |
local dest_dir="`ipkg_dir_part $dest`" |
|---|
| 215 |
if [ -z "$dest_dir" ]; then |
|---|
| 216 |
dest_dir="$IPKG_TMP" |
|---|
| 217 |
fi |
|---|
| 218 |
|
|---|
| 219 |
local dest_file="`ipkg_file_part $dest`" |
|---|
| 220 |
if [ -z "$dest_file" ]; then |
|---|
| 221 |
dest_file="$src_file" |
|---|
| 222 |
fi |
|---|
| 223 |
|
|---|
| 224 |
# Proxy support |
|---|
| 225 |
local proxyuser="" |
|---|
| 226 |
local proxypassword="" |
|---|
| 227 |
local proxyoption="" |
|---|
| 228 |
|
|---|
| 229 |
if [ -n "$IPKG_PROXY_USERNAME" ]; then |
|---|
| 230 |
proxyuser="--proxy-user=\"$IPKG_PROXY_USERNAME\"" |
|---|
| 231 |
proxypassword="--proxy-passwd=\"$IPKG_PROXY_PASSWORD\"" |
|---|
| 232 |
fi |
|---|
| 233 |
|
|---|
| 234 |
if [ -n "$IPKG_PROXY_HTTP" -o -n "$IPKG_PROXY_FTP" ]; then |
|---|
| 235 |
proxyoption="--proxy=on" |
|---|
| 236 |
fi |
|---|
| 237 |
|
|---|
| 238 |
echo "Downloading $src ..." |
|---|
| 239 |
rm -f $IPKG_TMP/$src_file |
|---|
| 240 |
case "$src" in |
|---|
| 241 |
http://* | ftp://*) |
|---|
| 242 |
if ! wget $additional_options --passive-ftp $proxyoption $proxyuser $proxypassword -P $IPKG_TMP $src; then |
|---|
| 243 |
echo "ipkg_download: ERROR: Failed to retrieve $src, returning $err" |
|---|
| 244 |
return 1 |
|---|
| 245 |
fi |
|---|
| 246 |
mv $IPKG_TMP/$src_file $dest_dir/$dest_file 2>/dev/null |
|---|
| 247 |
;; |
|---|
| 248 |
file:/* ) |
|---|
| 249 |
ln -s `echo $src | sed 's/^file://'` $dest_dir/$dest_file 2>/dev/null |
|---|
| 250 |
;; |
|---|
| 251 |
*) |
|---|
| 252 |
echo "DEBUG: $src" |
|---|
| 253 |
;; |
|---|
| 254 |
esac |
|---|
| 255 |
|
|---|
| 256 |
echo "Done." |
|---|
| 257 |
return 0 |
|---|
| 258 |
} |
|---|
| 259 |
|
|---|
| 260 |
ipkg_update() { |
|---|
| 261 |
if [ ! -e "$IPKG_LISTS_DIR" ]; then |
|---|
| 262 |
mkdir -p $IPKG_LISTS_DIR |
|---|
| 263 |
fi |
|---|
| 264 |
|
|---|
| 265 |
local err= |
|---|
| 266 |
for src_name in `ipkg_src_names`; do |
|---|
| 267 |
local src="`ipkg_src_byname $src_name`" |
|---|
| 268 |
if ! ipkg_download $src/Packages $IPKG_LISTS_DIR/$src_name; then |
|---|
| 269 |
echo "ipkg_update: Error downloading $src/Packages to $IPKG_LISTS_DIR/$src_name" >&2 |
|---|
| 270 |
err=t |
|---|
| 271 |
else |
|---|
| 272 |
echo "Updated list of available packages in $IPKG_LISTS_DIR/$src_name" |
|---|
| 273 |
fi |
|---|
| 274 |
done |
|---|
| 275 |
|
|---|
| 276 |
[ -n "$err" ] && return 1 ||: |
|---|
| 277 |
|
|---|
| 278 |
return 0 |
|---|
| 279 |
} |
|---|
| 280 |
|
|---|
| 281 |
ipkg_list() { |
|---|
| 282 |
for src in `ipkg_src_names`; do |
|---|
| 283 |
if ipkg_require_list $src; then |
|---|
| 284 |
# black magic... |
|---|
| 285 |
sed -ne " |
|---|
| 286 |
/^Package:/{ |
|---|
| 287 |
s/^Package:[[:space:]]*\<\([a-z0-9.+-]*$1[a-z0-9.+-]*\).*/\1/ |
|---|
| 288 |
h |
|---|
| 289 |
} |
|---|
| 290 |
/^Description:/{ |
|---|
| 291 |
s/^Description:[[:space:]]*\(.*\)/\1/ |
|---|
| 292 |
H |
|---|
| 293 |
g |
|---|
| 294 |
s/\\ |
|---|
| 295 |
/ - / |
|---|
| 296 |
p |
|---|
| 297 |
} |
|---|
| 298 |
" $IPKG_LISTS_DIR/$src |
|---|
| 299 |
fi |
|---|
| 300 |
done |
|---|
| 301 |
} |
|---|
| 302 |
|
|---|
| 303 |
ipkg_extract_paragraph() { |
|---|
| 304 |
local pkg="$1" |
|---|
| 305 |
sed -ne "/Package:[[:space:]]*$pkg[[:space:]]*\$/,/^\$/p" |
|---|
| 306 |
} |
|---|
| 307 |
|
|---|
| 308 |
ipkg_extract_field() { |
|---|
| 309 |
local field="$1" |
|---|
| 310 |
# blacker magic... |
|---|
| 311 |
sed -ne " |
|---|
| 312 |
: TOP |
|---|
| 313 |
/^$field:/{ |
|---|
| 314 |
p |
|---|
| 315 |
n |
|---|
| 316 |
b FIELD |
|---|
| 317 |
} |
|---|
| 318 |
d |
|---|
| 319 |
: FIELD |
|---|
| 320 |
/^$/b TOP |
|---|
| 321 |
/^[^[:space:]]/b TOP |
|---|
| 322 |
p |
|---|
| 323 |
n |
|---|
| 324 |
b FIELD |
|---|
| 325 |
" |
|---|
| 326 |
} |
|---|
| 327 |
|
|---|
| 328 |
ipkg_extract_value() { |
|---|
| 329 |
sed -e "s/^[^:]*:[[:space:]]*//" |
|---|
| 330 |
} |
|---|
| 331 |
|
|---|
| 332 |
ipkg_require_list() { |
|---|
| 333 |
[ $# -lt 1 ] && return 1 ||: |
|---|
| 334 |
local src="$1" |
|---|
| 335 |
if [ ! -f "$IPKG_LISTS_DIR/$src" ]; then |
|---|
| 336 |
echo "ERROR: File not found: $IPKG_LISTS_DIR/$src" >&2 |
|---|
| 337 |
echo " You probably want to run \`ipkg update'" >&2 |
|---|
| 338 |
return 1 |
|---|
| 339 |
fi |
|---|
| 340 |
return 0 |
|---|
| 341 |
} |
|---|
| 342 |
|
|---|
| 343 |
ipkg_info() { |
|---|
| 344 |
for src in `ipkg_src_names`; do |
|---|
| 345 |
if ipkg_require_list $src; then |
|---|
| 346 |
case $# in |
|---|
| 347 |
0) |
|---|
| 348 |
cat $IPKG_LISTS_DIR/$src |
|---|
| 349 |
;; |
|---|
| 350 |
1) |
|---|
| 351 |
ipkg_extract_paragraph $1 < $IPKG_LISTS_DIR/$src |
|---|
| 352 |
;; |
|---|
| 353 |
*) |
|---|
| 354 |
ipkg_extract_paragraph $1 < $IPKG_LISTS_DIR/$src | ipkg_extract_field $2 |
|---|
| 355 |
;; |
|---|
| 356 |
esac |
|---|
| 357 |
fi |
|---|
| 358 |
done |
|---|
| 359 |
} |
|---|
| 360 |
|
|---|
| 361 |
ipkg_status_sd() { |
|---|
| 362 |
[ $# -lt 1 ] && return 0 ||: |
|---|
| 363 |
sd="$1" |
|---|
| 364 |
shift |
|---|
| 365 |
if [ -f $sd/status ]; then |
|---|
| 366 |
case $# in |
|---|
| 367 |
0) |
|---|
| 368 |
cat $sd/status |
|---|
| 369 |
;; |
|---|
| 370 |
1) |
|---|
| 371 |
ipkg_extract_paragraph $1 < $sd/status |
|---|
| 372 |
;; |
|---|
| 373 |
*) |
|---|
| 374 |
ipkg_extract_paragraph $1 < $sd/status | ipkg_extract_field $2 |
|---|
| 375 |
;; |
|---|
| 376 |
esac |
|---|
| 377 |
fi |
|---|
| 378 |
return 0 |
|---|
| 379 |
} |
|---|
| 380 |
|
|---|
| 381 |
ipkg_status_all() { |
|---|
| 382 |
for sd in `ipkg_state_dirs`; do |
|---|
| 383 |
ipkg_status_sd $sd $* |
|---|
| 384 |
done |
|---|
| 385 |
} |
|---|
| 386 |
|
|---|
| 387 |
ipkg_status() { |
|---|
| 388 |
if [ -n "$DEST_NAME" ]; then |
|---|
| 389 |
ipkg_status_sd $IPKG_STATE_DIR $* |
|---|
| 390 |
else |
|---|
| 391 |
ipkg_status_all $* |
|---|
| 392 |
fi |
|---|
| 393 |
} |
|---|
| 394 |
|
|---|
| 395 |
ipkg_status_matching_sd() { |
|---|
| 396 |
local sd="$1" |
|---|
| 397 |
local re="$2" |
|---|
| 398 |
if [ -f $sd/status ]; then |
|---|
| 399 |
sed -ne " |
|---|
| 400 |
: TOP |
|---|
| 401 |
/^Package:/{ |
|---|
| 402 |
s/^Package:[[:space:]]*// |
|---|
| 403 |
s/[[:space:]]*$// |
|---|
| 404 |
h |
|---|
| 405 |
} |
|---|
| 406 |
/$re/{ |
|---|
| 407 |
g |
|---|
| 408 |
p |
|---|
| 409 |
b NEXT |
|---|
| 410 |
} |
|---|
| 411 |
d |
|---|
| 412 |
: NEXT |
|---|
| 413 |
/^$/b TOP |
|---|
| 414 |
n |
|---|
| 415 |
b NEXT |
|---|
| 416 |
" < $sd/status |
|---|
| 417 |
fi |
|---|
| 418 |
return 0 |
|---|
| 419 |
} |
|---|
| 420 |
|
|---|
| 421 |
ipkg_status_matching_all() { |
|---|
| 422 |
for sd in `ipkg_state_dirs`; do |
|---|
| 423 |
ipkg_status_matching_sd $sd $* |
|---|
| 424 |
done |
|---|
| 425 |
} |
|---|
| 426 |
|
|---|
| 427 |
ipkg_status_matching() { |
|---|
| 428 |
if [ -n "$DEST_NAME" ]; then |
|---|
| 429 |
ipkg_status_matching_sd $IPKG_STATE_DIR $* |
|---|
| 430 |
else |
|---|
| 431 |
ipkg_status_matching_all $* |
|---|
| 432 |
fi |
|---|
| 433 |
} |
|---|
| 434 |
|
|---|
| 435 |
ipkg_status_installed_sd() { |
|---|
| 436 |
local sd="$1" |
|---|
| 437 |
local pkg="$2" |
|---|
| 438 |
ipkg_status_sd $sd $pkg Status | grep -q "Status: install ok installed" |
|---|
| 439 |
} |
|---|
| 440 |
|
|---|
| 441 |
ipkg_status_installed_all() { |
|---|
| 442 |
local ret=1 |
|---|
| 443 |
for sd in `ipkg_state_dirs`; do |
|---|
| 444 |
if `ipkg_status_installed_sd $sd $*`; then |
|---|
| 445 |
ret=0 |
|---|
| 446 |
fi |
|---|
| 447 |
done |
|---|
| 448 |
return $ret |
|---|
| 449 |
} |
|---|
| 450 |
|
|---|
| 451 |
ipkg_status_mentioned_sd() { |
|---|
| 452 |
local sd="$1" |
|---|
| 453 |
local pkg="$2" |
|---|
| 454 |
[ -n "`ipkg_status_sd $sd $pkg Status`" ] |
|---|
| 455 |
} |
|---|
| 456 |
|
|---|
| 457 |
ipkg_files() { |
|---|
| 458 |
local pkg="$1" |
|---|
| 459 |
if [ -n "$DEST_NAME" ]; then |
|---|
| 460 |
dests=$IPKG_ROOT |
|---|
| 461 |
else |
|---|
| 462 |
dests="`ipkg_dests_all`" |
|---|
| 463 |
fi |
|---|
| 464 |
for dest in $dests; do |
|---|
| 465 |
if [ -f $dest/$IPKG_DIR_PREFIX/info/$pkg.list ]; then |
|---|
| 466 |
dest_sed="`echo $dest | ipkg_protect_slashes`" |
|---|
| 467 |
sed -e "s/^/$dest_sed/" < $dest/$IPKG_DIR_PREFIX/info/$pkg.list |
|---|
| 468 |
fi |
|---|
| 469 |
done |
|---|
| 470 |
} |
|---|
| 471 |
|
|---|
| 472 |
ipkg_search() { |
|---|
| 473 |
local pattern="$1" |
|---|
| 474 |
|
|---|
| 475 |
for dest_name in `ipkg_dest_names`; do |
|---|
| 476 |
dest="`ipkg_dest_byname $dest_name`" |
|---|
| 477 |
dest_sed="`echo $dest | ipkg_protect_slashes`" |
|---|
| 478 |
|
|---|
| 479 |
set +o noglob |
|---|
| 480 |
local list_files="`ls -1 $dest/$IPKG_DIR_PREFIX/info/*.list 2>/dev/null`" |
|---|
| 481 |
set -o noglob |
|---|
| 482 |
for file in $list_files; do |
|---|
| 483 |
if sed "s/^/$dest_sed/" $file | grep -q $pattern; then |
|---|
| 484 |
local pkg="`echo $file | sed "s/^.*\/\(.*\)\.list/\1/"`" |
|---|
| 485 |
[ "$dest_name" != `ipkg_dest_default_name` ] && pkg="$pkg ($dest_name)" ||: |
|---|
| 486 |
sed "s/^/$dest_sed/" $file | grep $pattern | sed "s/^/$pkg: /" |
|---|
| 487 |
fi |
|---|
| 488 |
done |
|---|
| 489 |
done |
|---|
| 490 |
} |
|---|
| 491 |
|
|---|
| 492 |
ipkg_status_remove_sd() { |
|---|
| 493 |
local sd="$1" |
|---|
| 494 |
local pkg="$2" |
|---|
| 495 |
|
|---|
| 496 |
if [ ! -f $sd/status ]; then |
|---|
| 497 |
mkdir -p $sd |
|---|
| 498 |
touch $sd/status |
|---|
| 499 |
fi |
|---|
| 500 |
sed -ne "/Package:[[:space:]]*$pkg[[:space:]]*\$/,/^\$/!p" < $sd/status > $sd/status.new |
|---|
| 501 |
mv $sd/status.new $sd/status |
|---|
| 502 |
} |
|---|
| 503 |
|
|---|
| 504 |
ipkg_status_remove_all() { |
|---|
| 505 |
for sd in `ipkg_state_dirs`; do |
|---|
| 506 |
ipkg_status_remove_sd $sd $* |
|---|
| 507 |
done |
|---|
| 508 |
} |
|---|
| 509 |
|
|---|
| 510 |
ipkg_status_remove() { |
|---|
| 511 |
if [ -n "$DEST_NAME" ]; then |
|---|
| 512 |
ipkg_status_remove_sd $IPKG_STATE_DIR $* |
|---|
| 513 |
else |
|---|
| 514 |
ipkg_status_remove_all $* |
|---|
| 515 |
fi |
|---|
| 516 |
} |
|---|
| 517 |
|
|---|
| 518 |
ipkg_status_update_sd() { |
|---|
| 519 |
local sd="$1" |
|---|
| 520 |
local pkg="$2" |
|---|
| 521 |
|
|---|
| 522 |
ipkg_status_remove_sd $sd $pkg |
|---|
| 523 |
ipkg_extract_field "$IPKG_STATUS_FIELDS" >> $sd/status |
|---|
| 524 |
echo "" >> $sd/status |
|---|
| 525 |
} |
|---|
| 526 |
|
|---|
| 527 |
ipkg_status_update() { |
|---|
| 528 |
ipkg_status_update_sd $IPKG_STATE_DIR $* |
|---|
| 529 |
} |
|---|
| 530 |
|
|---|
| 531 |
ipkg_unsatisfied_dependences() { |
|---|
| 532 |
local pkg=$1 |
|---|
| 533 |
local deps="`ipkg_get_depends $pkg`" |
|---|
| 534 |
local remaining_deps= |
|---|
| 535 |
for dep in $deps; do |
|---|
| 536 |
local installed="`ipkg_get_installed $dep`" |
|---|
| 537 |
if [ "$installed" != "installed" ] ; then |
|---|
| 538 |
remaining_deps="$remaining_deps $dep" |
|---|
| 539 |
fi |
|---|
| 540 |
done |
|---|
| 541 |
## echo "ipkg_unsatisfied_dependences pkg=$pkg $remaining_deps" > /dev/console |
|---|
| 542 |
echo $remaining_deps |
|---|
| 543 |
} |
|---|
| 544 |
|
|---|
| 545 |
ipkg_safe_pkg_name() { |
|---|
| 546 |
local pkg=$1 |
|---|
| 547 |
local spkg="`echo pkg_$pkg | sed -e y/-+./___/`" |
|---|
| 548 |
echo $spkg |
|---|
| 549 |
} |
|---|
| 550 |
|
|---|
| 551 |
ipkg_set_depends() { |
|---|
| 552 |
local pkg=$1; shift |
|---|
| 553 |
local new_deps="$*" |
|---|
| 554 |
pkg="`ipkg_safe_pkg_name $pkg`" |
|---|
| 555 |
## setvar ${pkg}_depends "$new_deps" |
|---|
| 556 |
echo $new_deps > $IPKG_TMP/${pkg}.depends |
|---|
| 557 |
} |
|---|
| 558 |
|
|---|
| 559 |
ipkg_get_depends() { |
|---|
| 560 |
local pkg=$1 |
|---|
| 561 |
pkg="`ipkg_safe_pkg_name $pkg`" |
|---|
| 562 |
cat $IPKG_TMP/${pkg}.depends |
|---|
| 563 |
## eval "echo \$${pkg}_depends" |
|---|
| 564 |
} |
|---|
| 565 |
|
|---|
| 566 |
ipkg_set_installed() { |
|---|
| 567 |
local pkg=$1 |
|---|
| 568 |
pkg="`ipkg_safe_pkg_name $pkg`" |
|---|
| 569 |
echo installed > $IPKG_TMP/${pkg}.installed |
|---|
| 570 |
## setvar ${pkg}_installed "installed" |
|---|
| 571 |
} |
|---|
| 572 |
|
|---|
| 573 |
ipkg_set_uninstalled() { |
|---|
| 574 |
local pkg=$1 |
|---|
| 575 |
pkg="`ipkg_safe_pkg_name $pkg`" |
|---|
| 576 |
### echo ipkg_set_uninstalled $pkg > /dev/console |
|---|
| 577 |
echo uninstalled > $IPKG_TMP/${pkg}.installed |
|---|
| 578 |
## setvar ${pkg}_installed "uninstalled" |
|---|
| 579 |
} |
|---|
| 580 |
|
|---|
| 581 |
ipkg_get_installed() { |
|---|
| 582 |
local pkg=$1 |
|---|
| 583 |
pkg="`ipkg_safe_pkg_name $pkg`" |
|---|
| 584 |
if [ -f $IPKG_TMP/${pkg}.installed ]; then |
|---|
| 585 |
cat $IPKG_TMP/${pkg}.installed |
|---|
| 586 |
fi |
|---|
| 587 |
## eval "echo \$${pkg}_installed" |
|---|
| 588 |
} |
|---|
| 589 |
|
|---|
| 590 |
ipkg_depends() { |
|---|
| 591 |
local new_pkgs="$*" |
|---|
| 592 |
local all_deps= |
|---|
| 593 |
local installed_pkgs="`ipkg_status_matching_all 'Status:.*[[:space:]]installed'`" |
|---|
| 594 |
for pkg in $installed_pkgs; do |
|---|
| 595 |
ipkg_set_installed $pkg |
|---|
| 596 |
done |
|---|
| 597 |
while [ -n "$new_pkgs" ]; do |
|---|
| 598 |
all_deps="$all_deps $new_pkgs" |
|---|
| 599 |
local new_deps= |
|---|
| 600 |
for pkg in $new_pkgs; do |
|---|
| 601 |
if echo $pkg | grep -q '[^a-z0-9.+-]'; then |
|---|
| 602 |
echo "ipkg_depends: ERROR: Package name $pkg contains illegal characters (should be [a-z0-9.+-])" >&2 |
|---|
| 603 |
return 1 |
|---|
| 604 |
fi |
|---|
| 605 |
# TODO: Fix this. For now I am ignoring versions and alternations in dependencies. |
|---|
| 606 |
new_deps="$new_deps "`ipkg_info $pkg '\(Pre-\)\?Depends' | ipkg_extract_value | sed -e 's/([^)]*)//g |
|---|
| 607 |
s/\(|[[:space:]]*[a-z0-9.+-]\+[[:space:]]*\)\+//g |
|---|
| 608 |
s/,/ /g |
|---|
| 609 |
s/ \+/ /g'` |
|---|
| 610 |
ipkg_set_depends $pkg $new_deps |
|---|
| 611 |
done |
|---|
| 612 |
|
|---|
| 613 |
new_deps=`echo $new_deps | sed -e 's/[[:space:]]\+/\n/g' | sort | uniq` |
|---|
| 614 |
|
|---|
| 615 |
local maybe_new_pkgs= |
|---|
| 616 |
for pkg in $new_deps; do |
|---|
| 617 |
if ! echo $installed_pkgs | grep -q "\<$pkg\>"; then |
|---|
| 618 |
maybe_new_pkgs="$maybe_new_pkgs $pkg" |
|---|
| 619 |
fi |
|---|
| 620 |
done |
|---|
| 621 |
|
|---|
| 622 |
new_pkgs= |
|---|
| 623 |
for pkg in $maybe_new_pkgs; do |
|---|
| 624 |
if ! echo $all_deps | grep -q "\<$pkg\>"; then |
|---|
| 625 |
if [ -z "`ipkg_info $pkg`" ]; then |
|---|
| 626 |
echo "ipkg_depends: Warning: $pkg mentioned in dependency but no package found in $IPKG_LISTS_DIR" >&2 |
|---|
| 627 |
ipkg_set_installed $pkg |
|---|
| 628 |
else |
|---|
| 629 |
new_pkgs="$new_pkgs $pkg" |
|---|
| 630 |
ipkg_set_uninstalled $pkg |
|---|
| 631 |
fi |
|---|
| 632 |
else |
|---|
| 633 |
ipkg_set_uninstalled $pkg |
|---|
| 634 |
fi |
|---|
| 635 |
done |
|---|
| 636 |
done |
|---|
| 637 |
|
|---|
| 638 |
echo $all_deps |
|---|
| 639 |
} |
|---|
| 640 |
|
|---|
| 641 |
ipkg_get_install_dest() { |
|---|
| 642 |
local dest="$1" |
|---|
| 643 |
shift |
|---|
| 644 |
local sd=$dest/$IPKG_DIR_PREFIX |
|---|
| 645 |
local info_dir=$sd/info |
|---|
| 646 |
|
|---|
| 647 |
local requested_pkgs="$*" |
|---|
| 648 |
local pkgs="`ipkg_depends $*`" |
|---|
| 649 |
|
|---|
| 650 |
mkdir -p $info_dir |
|---|
| 651 |
for pkg in $pkgs; do |
|---|
| 652 |
if ! ipkg_status_mentioned_sd $sd $pkg; then |
|---|
| 653 |
echo "Package: $pkg |
|---|
| 654 |
Status: install ok not-installed" | ipkg_status_update_sd $sd $pkg |
|---|
| 655 |
fi |
|---|
| 656 |
done |
|---|
| 657 |
## mark the packages that we were directly requested to install as uninstalled |
|---|
| 658 |
for pkg in $requested_pkgs; do ipkg_set_uninstalled $pkg; done |
|---|
| 659 |
|
|---|
| 660 |
local new_pkgs= |
|---|
| 661 |
local pkgs_installed=0 |
|---|
| 662 |
while [ -n "pkgs" ]; do |
|---|
| 663 |
curcheck=0 |
|---|
| 664 |
## echo "pkgs to install: {$pkgs}" > /dev/console |
|---|
| 665 |
for pkg in $pkgs; do |
|---|
| 666 |
curcheck="`expr $curcheck + 1`" |
|---|
| 667 |
local is_installed="`ipkg_get_installed $pkg`" |
|---|
| 668 |
if [ "$is_installed" = "installed" ]; then |
|---|
| 669 |
echo "$pkg is installed" > /dev/console |
|---|
| 670 |
continue |
|---|
| 671 |
fi |
|---|
| 672 |
|
|---|
| 673 |
local remaining_deps="`ipkg_unsatisfied_dependences $pkg`" |
|---|
| 674 |
if [ -n "$remaining_deps" ]; then |
|---|
| 675 |
new_pkgs="$new_pkgs $pkg" |
|---|
| 676 |
### echo "Dependences not satisfied for $pkg: $remaining_deps" |
|---|
| 677 |
if [ $curcheck -ne `echo $pkgs|wc -w` ]; then |
|---|
| 678 |
continue |
|---|
| 679 |
fi |
|---|
| 680 |
fi |
|---|
| 681 |
|
|---|
| 682 |
local filename= |
|---|
| 683 |
for src in `ipkg_src_names`; do |
|---|
| 684 |
if ipkg_require_list $src; then |
|---|
| 685 |
filename="`ipkg_extract_paragraph $pkg < $IPKG_LISTS_DIR/$src | ipkg_extract_field Filename | ipkg_extract_value`" |
|---|
| 686 |
[ -n "$filename" ] && break ||: |
|---|
| 687 |
fi |
|---|
| 688 |
done |
|---|
| 689 |
|
|---|
| 690 |
if [ -z "$filename" ]; then |
|---|
| 691 |
echo "ipkg_get_install: ERROR: Cannot find package $pkg in $IPKG_LISTS_DIR" |
|---|
| 692 |
echo "ipkg_get_install: Check the spelling and maybe run \`ipkg update'." |
|---|
| 693 |
ipkg_status_remove_sd $sd $pkg |
|---|
| 694 |
return 1; |
|---|
| 695 |
fi |
|---|
| 696 |
|
|---|
| 697 |
echo "" |
|---|
| 698 |
local tmp_pkg_file="$IPKG_TMP/"`ipkg_file_part $filename` |
|---|
| 699 |
if ! ipkg_download `ipkg_src_byname $src`/$filename $tmp_pkg_file; then |
|---|
| 700 |
echo "ipkg_get_install: Perhaps you need to run \`ipkg update'?" |
|---|
| 701 |
return 1 |
|---|
| 702 |
fi |
|---|
| 703 |
|
|---|
| 704 |
if ! ipkg_install_file_dest $dest $tmp_pkg_file; then |
|---|
| 705 |
echo "ipkg_get_install: ERROR: Failed to install $tmp_pkg_file" |
|---|
| 706 |
echo "ipkg_get_install: I'll leave it there for you to try a manual installation" |
|---|
| 707 |
return 1 |
|---|
| 708 |
fi |
|---|
| 709 |
|
|---|
| 710 |
ipkg_set_installed $pkg |
|---|
| 711 |
pkgs_installed="`expr $pkgs_installed + 1`" |
|---|
| 712 |
rm $tmp_pkg_file |
|---|
| 713 |
done |
|---|
| 714 |
### echo "Installed $pkgs_installed package(s) this round" |
|---|
| 715 |
if [ $pkgs_installed -eq 0 ]; then |
|---|
| 716 |
if [ -z "$new_pkgs" ]; then |
|---|
| 717 |
break |
|---|
| 718 |
fi |
|---|
| 719 |
fi |
|---|
| 720 |
pkgs_installed=0 |
|---|
| 721 |
pkgs="$new_pkgs" |
|---|
| 722 |
new_pkgs= |
|---|
| 723 |
curcheck=0 |
|---|
| 724 |
done |
|---|
| 725 |
} |
|---|
| 726 |
|
|---|
| 727 |
ipkg_get_install() { |
|---|
| 728 |
ipkg_get_install_dest $IPKG_ROOT $* |
|---|
| 729 |
} |
|---|
| 730 |
|
|---|
| 731 |
ipkg_install_file_dest() { |
|---|
| 732 |
local dest="$1" |
|---|
| 733 |
local filename="$2" |
|---|
| 734 |
local sd=$dest/$IPKG_DIR_PREFIX |
|---|
| 735 |
local info_dir=$sd/info |
|---|
| 736 |
|
|---|
| 737 |
if [ ! -f "$filename" ]; then |
|---|
| 738 |
echo "ipkg_install_file: ERROR: File $filename not found" |
|---|
| 739 |
return 1 |
|---|
| 740 |
fi |
|---|
| 741 |
|
|---|
| 742 |
local pkg="`ipkg_file_part $filename | sed 's/\([a-z0-9.+-]\+\)_.*/\1/'`" |
|---|
| 743 |
local ext="`echo $filename | sed 's/.*\.//'`" |
|---|
| 744 |
local pkg_extract_stdout |
|---|
| 745 |
if [ "$ext" = "ipk" ]; then |
|---|
| 746 |
pkg_extract_stdout="tar -xzOf" |
|---|
| 747 |
elif [ "$ext" = "deb" ]; then |
|---|
| 748 |
pkg_extract_stdout="ar p" |
|---|
| 749 |
else |
|---|
| 750 |
echo "ipkg_install_file: ERROR: File $filename has unknown extension $ext (not .ipk or .deb)" |
|---|
| 751 |
return 1 |
|---|
| 752 |
fi |
|---|
| 753 |
|
|---|
| 754 |
# Check dependencies |
|---|
| 755 |
local depends="`ipkg_depends $pkg | sed -e "s/\<$pkg\>//"`" |
|---|
| 756 |
|
|---|
| 757 |
# Don't worry about deps that are scheduled for installation |
|---|
| 758 |
local missing_deps= |
|---|
| 759 |
for dep in $depends; do |
|---|
| 760 |
if ! ipkg_status_all $dep | grep -q 'Status:[[:space:]]install'; then |
|---|
| 761 |
missing_deps="$missing_deps $dep" |
|---|
| 762 |
fi |
|---|
| 763 |
done |
|---|
| 764 |
|
|---|
| 765 |
if [ ! -z "$missing_deps" ]; then |
|---|
| 766 |
if [ -n "$FORCE_DEPENDS" ]; then |
|---|
| 767 |
echo "ipkg_install_file: Warning: $pkg depends on the following uninstalled programs: $missing_deps" |
|---|
| 768 |
else |
|---|
| 769 |
echo "ipkg_install_file: ERROR: $pkg depends on the following uninstalled programs: |
|---|
| 770 |
$missing_deps" |
|---|
| 771 |
echo "ipkg_install_file: You may want to use \`ipkg install' to install these." |
|---|
| 772 |
return 1 |
|---|
| 773 |
fi |
|---|
| 774 |
fi |
|---|
| 775 |
|
|---|
| 776 |
mkdir -p $IPKG_TMP/$pkg/control |
|---|
| 777 |
mkdir -p $IPKG_TMP/$pkg/data |
|---|
| 778 |
mkdir -p $info_dir |
|---|
| 779 |
|
|---|
| 780 |
if ! $pkg_extract_stdout $filename ./control.tar.gz | (cd $IPKG_TMP/$pkg/control; tar -xzf - ) ; then |
|---|
| 781 |
echo "ipkg_install_file: ERROR unpacking control.tar.gz from $filename" |
|---|
| 782 |
return 1 |
|---|
| 783 |
fi |
|---|
| 784 |
|
|---|
| 785 |
if [ -n "$IPKG_OFFLINE_ROOT" ]; then |
|---|
| 786 |
if grep -q '^InstallsOffline:[[:space:]]*no' $IPKG_TMP/$pkg/control/control; then |
|---|
| 787 |
echo "*** Warning: Package $pkg may not be installed in offline mode" |
|---|
| 788 |
echo "*** Warning: Scheduling $filename for pending installation (installing into $IPKG_PENDING_DIR)" |
|---|
| 789 |
echo "Package: $pkg |
|---|
| 790 |
Status: install ok pending" | ipkg_status_update_sd $sd $pkg |
|---|
| 791 |
mkdir -p $IPKG_PENDING_DIR |
|---|
| 792 |
cp -f $filename $IPKG_PENDING_DIR |
|---|
| 793 |
rm -r $IPKG_TMP/$pkg/control |
|---|
| 794 |
rm -r $IPKG_TMP/$pkg/data |
|---|
| 795 |
rmdir $IPKG_TMP/$pkg |
|---|
| 796 |
return 0 |
|---|
| 797 |
fi |
|---|
| 798 |
fi |
|---|
| 799 |
|
|---|
| 800 |
|
|---|
| 801 |
echo -n "Unpacking $pkg..." |
|---|
| 802 |
set +o noglob |
|---|
| 803 |
for file in $IPKG_TMP/$pkg/control/*; do |
|---|
| 804 |
local base_file="`ipkg_file_part $file`" |
|---|
| 805 |
mv $file $info_dir/$pkg.$base_file |
|---|
| 806 |
done |
|---|
| 807 |
set -o noglob |
|---|
| 808 |
rm -r $IPKG_TMP/$pkg/control |
|---|
| 809 |
|
|---|
| 810 |
if ! $pkg_extract_stdout $filename ./data.tar.gz | (cd $IPKG_TMP/$pkg/data; tar -xzf - ) ; then |
|---|
| 811 |
echo "ipkg_install_file: ERROR unpacking data.tar.gz from $filename" |
|---|
| 812 |
return 1 |
|---|
| 813 |
fi |
|---|
| 814 |
echo "Done." |
|---|
| 815 |
|
|---|
| 816 |
echo -n "Configuring $pkg..." |
|---|
| 817 |
export PKG_ROOT=$dest |
|---|
| 818 |
if [ -x "$info_dir/$pkg.preinst" ]; then |
|---|
| 819 |
if ! $info_dir/$pkg.preinst install; then |
|---|
| 820 |
echo "$info_dir/$pkg.preinst failed. Aborting installation of $pkg" |
|---|
| 821 |
rm -rf $IPKG_TMP/$pkg/data |
|---|
| 822 |
rmdir $IPKG_TMP/$pkg |
|---|
| 823 |
return 1 |
|---|
| 824 |
fi |
|---|
| 825 |
fi |
|---|
| 826 |
|
|---|
| 827 |
local old_conffiles="`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`" |
|---|
| 828 |
local new_conffiles= |
|---|
| 829 |
if [ -f "$info_dir/$pkg.conffiles" ]; then |
|---|
| 830 |
for conffile in `cat $info_dir/$pkg.conffiles`; do |
|---|
| 831 |
if [ -f "$dest/$conffile" ] && ! echo " $old_conffiles " | grep -q " $conffile "`md5sum $dest/$conffile | sed 's/ .*//'`; then |
|---|
| 832 |
local use_maintainers_conffile= |
|---|
| 833 |
if [ -z "$FORCE_DEFAULTS" ]; then |
|---|
| 834 |
while true; do |
|---|
| 835 |
echo -n "Configuration file \`$conffile' |
|---|
| 836 |
==> File on system created by you or by a script. |
|---|
| 837 |
==> File also in package provided by package maintainer. |
|---|
| 838 |
What would you like to do about it ? Your options are: |
|---|
| 839 |
Y or I : install the package maintainer's version |
|---|
| 840 |
N or O : keep your currently-installed version |
|---|
| 841 |
D : show the differences between the versions (if diff is installed) |
|---|
| 842 |
The default action is to keep your current version. |
|---|
| 843 |
*** `ipkg_file_part $conffile` (Y/I/N/O/D) [default=N] ? " |
|---|
| 844 |
read response |
|---|
| 845 |
case "$response" in |
|---|
| 846 |
[YyIi] | [Yy][Ee][Ss]) |
|---|
| 847 |
use_maintainers_conffile=t |
|---|
| 848 |
break |
|---|
| 849 |
;; |
|---|
| 850 |
[Dd]) |
|---|
| 851 |
echo " |
|---|
| 852 |
diff -u $dest/$conffile $IPKG_TMP/$pkg/data/$conffile" |
|---|
| 853 |
diff -u $dest/$conffile $IPKG_TMP/$pkg/data/$conffile || true |
|---|
| 854 |
echo "[Press ENTER to continue]" |
|---|
| 855 |
read junk |
|---|
| 856 |
;; |
|---|
| 857 |
*) |
|---|
| 858 |
break |
|---|
| 859 |
;; |
|---|
| 860 |
esac |
|---|
| 861 |
done |
|---|
| 862 |
fi |
|---|
| 863 |
if [ -n "$use_maintainers_conffile" ]; then |
|---|
| 864 |
local md5sum="`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`" |
|---|
| 865 |
new_conffiles="$new_conffiles $conffile $md5sum" |
|---|
| 866 |
else |
|---|
| 867 |
new_conffiles="$new_conffiles $conffile <custom>" |
|---|
| 868 |
rm $IPKG_TMP/$pkg/data/$conffile |
|---|
| 869 |
fi |
|---|
| 870 |
else |
|---|
| 871 |
md5sum="`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`" |
|---|
| 872 |
new_conffiles="$new_conffiles $conffile $md5sum" |
|---|
| 873 |
fi |
|---|
| 874 |
done |
|---|
| 875 |
fi |
|---|
| 876 |
|
|---|
| 877 |
local owd="`pwd`" |
|---|
| 878 |
(cd $IPKG_TMP/$pkg/data/; tar cf - . | (cd $owd; cd $dest; tar xf -)) |
|---|
| 879 |
rm -rf $IPKG_TMP/$pkg/data |
|---|
| 880 |
rmdir $IPKG_TMP/$pkg |
|---|
| 881 |
rm -f $info_dir/$pkg.list |
|---|
| 882 |
$pkg_extract_stdout $filename ./data.tar.gz | tar tzf - | sed -e 's/^\.//' > $info_dir/$pkg.list |
|---|
| 883 |
|
|---|
| 884 |
if [ -x "$info_dir/$pkg.postinst" ]; then |
|---|
| 885 |
IPKG_INSTROOT="$IPKG_INSTROOT" $info_dir/$pkg.postinst configure |
|---|
| 886 |
fi |
|---|
| 887 |
|
|---|
| 888 |
if [ -n "$new_conffiles" ]; then |
|---|
| 889 |
new_conffiles='Conffiles: '`echo $new_conffiles | ipkg_protect_slashes` |
|---|
| 890 |
fi |
|---|
| 891 |
local sed_safe_offline_root="`echo ${IPKG_OFFLINE_ROOT} | ipkg_protect_slashes`" |
|---|
| 892 |
local sed_safe_root="`echo $dest | sed -e "s/^${sed_safe_offline_root}//" | ipkg_protect_slashes`" |
|---|
| 893 |
sed -e "s/\(Package:.*\)/\1\\ |
|---|
| 894 |
Status: install ok installed\\ |
|---|
| 895 |
Root: ${sed_safe_root}\\ |
|---|
| 896 |
${new_conffiles}/" $info_dir/$pkg.control | ipkg_status_update_sd $sd $pkg |
|---|
| 897 |
|
|---|
| 898 |
rm -f $info_dir/$pkg.control |
|---|
| 899 |
rm -f $info_dir/$pkg.conffiles |
|---|
| 900 |
rm -f $info_dir/$pkg.preinst |
|---|
| 901 |
rm -f $info_dir/$pkg.postinst |
|---|
| 902 |
|
|---|
| 903 |
echo "Done." |
|---|
| 904 |
} |
|---|
| 905 |
|
|---|
| 906 |
ipkg_install_file() { |
|---|
| 907 |
ipkg_install_file_dest $IPKG_ROOT $* |
|---|
| 908 |
} |
|---|
| 909 |
|
|---|
| 910 |
ipkg_install() { |
|---|
| 911 |
|
|---|
| 912 |
while [ $# -gt 0 ]; do |
|---|
| 913 |
local pkg="$1" |
|---|
| 914 |
shift |
|---|
| 915 |
|
|---|
| 916 |
case "$pkg" in |
|---|
| 917 |
http://* | ftp://*) |
|---|
| 918 |
local tmp_pkg_file="$IPKG_TMP/"`ipkg_file_part $pkg` |
|---|
| 919 |
if ipkg_download $pkg $tmp_pkg_file; then |
|---|
| 920 |
ipkg_install_file $tmp_pkg_file |
|---|
| 921 |
rm $tmp_pkg_file |
|---|
| 922 |
fi |
|---|
| 923 |
;; |
|---|
| 924 |
file:/*.ipk | file://*.deb) |
|---|
| 925 |
local ipkg_filename="`echo $pkg|sed 's/^file://'`" |
|---|
| 926 |
ipkg_install_file $ipkg_filename |
|---|
| 927 |
;; |
|---|
| 928 |
*.ipk | *.deb) |
|---|
| 929 |
if [ -f "$pkg" ]; then |
|---|
| 930 |
ipkg_install_file $pkg |
|---|
| 931 |
else |
|---|
| 932 |
echo "File not found $pkg" >&2 |
|---|
| 933 |
fi |
|---|
| 934 |
;; |
|---|
| 935 |
*) |
|---|
| 936 |
ipkg_get_install $pkg || true |
|---|
| 937 |
;; |
|---|
| 938 |
esac |
|---|
| 939 |
done |
|---|
| 940 |
} |
|---|
| 941 |
|
|---|
| 942 |
ipkg_install_pending() { |
|---|
| 943 |
[ -n "$IPKG_OFFLINE_ROOT" ] && return 0 ||: |
|---|
| 944 |
|
|---|
| 945 |
if [ -d "$IPKG_PENDING_DIR" ]; then |
|---|
| 946 |
set +o noglob |
|---|
| 947 |
local pending="`ls -1d $IPKG_PENDING_DIR/*.ipk 2> /dev/null`" || true |
|---|
| 948 |
set -o noglob |
|---|
| 949 |
if [ -n "$pending" ]; then |
|---|
| 950 |
echo "The following packages in $IPKG_PENDING_DIR will now be installed:" |
|---|
| 951 |
echo $pending |
|---|
| 952 |
for filename in $pending; do |
|---|
| 953 |
if ipkg_install_file $filename; then |
|---|
| 954 |
rm $filename |
|---|
| 955 |
fi |
|---|
| 956 |
done |
|---|
| 957 |
fi |
|---|
| 958 |
fi |
|---|
| 959 |
return 0 |
|---|
| 960 |
} |
|---|
| 961 |
|
|---|
| 962 |
ipkg_install_wanted() { |
|---|
| 963 |
local wanted="`ipkg_status_matching 'Status:[[:space:]]*install.*not-installed'`" |
|---|
| 964 |
|
|---|
| 965 |
if [ -n "$wanted" ]; then |
|---|
| 966 |
echo "The following package were previously requested but have not been installed:" |
|---|
| 967 |
echo $wanted |
|---|
| 968 |
|
|---|
| 969 |
if [ -n "$FORCE_DEFAULTS" ]; then |
|---|
| 970 |
echo "Installing them now." |
|---|
| 971 |
else |
|---|
| 972 |
echo -n "Install them now [Y/n] ? " |
|---|
| 973 |
read response |
|---|
| 974 |
case "$response" in |
|---|
| 975 |
[Nn] | [Nn][Oo]) |
|---|
| 976 |
return 0 |
|---|
| 977 |
;; |
|---|
| 978 |
esac |
|---|
| 979 |
fi |
|---|
| 980 |
|
|---|
| 981 |
ipkg_install $wanted |
|---|
| 982 |
fi |
|---|
| 983 |
|
|---|
| 984 |
return 0 |
|---|
| 985 |
} |
|---|
| 986 |
|
|---|
| 987 |
ipkg_upgrade_pkg() { |
|---|
| 988 |
local pkg="$1" |
|---|
| 989 |
local avail_ver="`ipkg_info $pkg Version | ipkg_extract_value | head -n 1`" |
|---|
| 990 |
|
|---|
| 991 |
is_installed= |
|---|
| 992 |
for dest_name in `ipkg_dest_names`; do |
|---|
| 993 |
local dest="`ipkg_dest_byname $dest_name`" |
|---|
| 994 |
local sd=$dest/$IPKG_DIR_PREFIX |
|---|
| 995 |
local inst_ver="`ipkg_status_sd $sd $pkg Version | ipkg_extract_value`" |
|---|
| 996 |
if [ -n "$inst_ver" ]; then |
|---|
| 997 |
is_installed=t |
|---|
| 998 |
|
|---|
| 999 |
if [ -z "$avail_ver" ]; then |
|---|
| 1000 |
echo "Assuming locally installed package $pkg ($inst_ver) is up to date" |
|---|
| 1001 |
return 0 |
|---|
| 1002 |
fi |
|---|
| 1003 |
|
|---|
| 1004 |
if [ "$avail_ver" = "$inst_ver" ]; then |
|---|
| 1005 |
echo "Package $pkg ($inst_ver) installed in $dest_name is up to date" |
|---|
| 1006 |
elif ipkg_is_upgrade "$avail_ver" "$inst_ver"; then |
|---|
| 1007 |
&n |
|---|