slitaz-modular rev 0 0.1-alpha
first release
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Thu Nov 25 03:30:16 2010 +0000 (2010-11-25) |
parents | |
children | 393f2374d675 |
files | .hgignore config initramfs/init initramfs/liblinuxlive initramfs/linuxrc list/a.000.base.list list/a.001.justx.list list/a.002.core-basic.list list/a.003.mesa.list list/a.004.xorg-xf86-video.list list/a.005.firefox.list list/a.006.libs.list list/a.006.libs.removelist list/a.007.apps.list list/a.008.mercurial.list list/a.009.pentest.list list/initramfs.list mkiso.sh overlay/etc/fstab overlay/usr/bin/tazpkg tazwok.conf |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/.hgignore Thu Nov 25 03:30:16 2010 +0000 1.3 @@ -0,0 +1,2 @@ 1.4 +syntax: glob 1.5 +working/** 1.6 \ No newline at end of file
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/config Thu Nov 25 03:30:16 2010 +0000 2.3 @@ -0,0 +1,2 @@ 2.4 +MODULES="a.000.base a.001.justx a.002.core-basic a.003.mesa a.004.xorg-xf86-video a.005.firefox a.006.libs a.007.apps a.008.mercurial a.009.pentest" 2.5 +COPY_HG="yes" 2.6 \ No newline at end of file
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/initramfs/init Thu Nov 25 03:30:16 2010 +0000 3.3 @@ -0,0 +1,151 @@ 3.4 +#!/bin/sh 3.5 + 3.6 +launch_init() 3.7 +{ 3.8 + echo -e "\\033[70G[ \\033[1;33mOK\\033[0;39m ]" 3.9 + exec /sbin/switch_root mnt /sbin/init 3.10 +} 3.11 + 3.12 +launch_init_modular() 3.13 +{ 3.14 + echo -e "\\033[70G[ \\033[1;33mOK\\033[0;39m ]" 3.15 + exec /sbin/switch_root mnt /linuxrc 3.16 +} 3.17 + 3.18 +failed() 3.19 +{ 3.20 + echo -e "\\033[70G[ \\033[1;31mFailed\\033[0;39m ]" 3.21 +} 3.22 + 3.23 +try_init() 3.24 +{ 3.25 + if [ ! -d /mnt/etc ] && grep -q cryptoroot= /proc/cmdline; then 3.26 + modprobe dm-mod 3.27 + modprobe dm-crypt 3.28 + modprobe aes-i586 3.29 + root="$(sed 's/.*cryptoroot=\([^ ]*\).*/\1/' < /proc/cmdline)" 3.30 + dev=${root#/dev/} 3.31 + dmlabel=crypto-$dev 3.32 + if cryptsetup isLuks $root 2> /dev/null; then 3.33 + cryptsetup luksOpen $root $dmlabel 3.34 + else 3.35 + read -s -t 60 -p "Pass phrase : " passphrase 3.36 + key=$(echo $passphrase | hashalot -x -n 32 sha512) 3.37 + blocks=$(cat $(find /sys/block | grep /$dev/size)) 3.38 + echo 0 $blocks crypt aes-plain $key 0 $root 0 | \ 3.39 + dmsetup create $dmlabel 3.40 + fi 3.41 + mount /dev/mapper/$dmlabel /mnt 3.42 + fi 3.43 + if [ -d /mnt/etc ]; then 3.44 + umount /sys 3.45 + [ -n "$1" ] && for i in $@ ; do 3.46 + cp -a $i /mnt$(dirname $i) 3.47 + done 3.48 + umount /proc 3.49 + launch_init 3.50 + fi 3.51 + failed 3.52 +} 3.53 + 3.54 +mount_mapper() 3.55 +{ 3.56 + mount $root /mnt 3.57 + try_init /dev/mapper $@ 3.58 +} 3.59 + 3.60 +lvmsetup() 3.61 +{ 3.62 +if grep -q lvmroot= /proc/cmdline; then 3.63 + modprobe dm-mod 3.64 + vgscan --ignorelockingfailure 3.65 + vgchange -ay --ignorelockingfailure 3.66 + root="/dev/mapper/$(sed 's/.*lvmroot=\([^ ]*\).*/\1/' < /proc/cmdline)" 3.67 + return 0 3.68 +fi 3.69 +return 1 3.70 +} 3.71 + 3.72 +load_raid() 3.73 +{ 3.74 +while read line; do 3.75 + case "$line" in 3.76 + *raid10*) modprobe raid10 ;; 3.77 + *raid0*) modprobe raid0 ;; 3.78 + *raid1*) modprobe raid1 ;; 3.79 + *raid[456]*) modprobe raid456 ;; 3.80 + esac 3.81 +done 3.82 +} 3.83 + 3.84 +mount -t proc proc /proc 3.85 +mount -t sysfs sysfs /sys 3.86 +if grep -q dmraid= /proc/cmdline; then 3.87 + root="$(sed 's/.*dmraid=\([^ ]*\).*/\1/' < /proc/cmdline)" 3.88 + echo -n "Switching / to dmraid $root..." 3.89 + dmraid -s | grep ^type | awk '{ print $3 }' | load_raid 3.90 + case "$root" in 3.91 + /dev/*);; 3.92 + *) root=/dev/mapper/$(dmraid -s|grep ^name|awk '{print $3}')p${root#p};; 3.93 + esac 3.94 + dmraid -ay 3.95 + lvmsetup 3.96 + mount_mapper 3.97 +fi 3.98 +if grep -q softraid= /proc/cmdline; then 3.99 + root="$(sed 's/.*softraid=\([^ ]*\).*/\1/' < /proc/cmdline)" 3.100 + echo -n "Switching / to softraid $root..." 3.101 + mdadm --examine --scan --config=partitions > /etc/mdadm.conf 3.102 + grep level=raid /etc/mdadm.conf | load_raid 3.103 + mdadm --assemble --scan 3.104 + lvmsetup 3.105 + mount_mapper /etc/mdadm.conf 3.106 +fi 3.107 +if lvmsetup; then 3.108 + echo -n "Switching / to lvm $root..." 3.109 + mount_mapper 3.110 +fi 3.111 +if grep -q loopfs= /proc/cmdline; then 3.112 + loopfs="$(sed 's/.*loopfs=\([^ ]*\).*/\1/' < /proc/cmdline)" 3.113 + dev=${loopfs%,*} 3.114 + loopfs=${loopfs#*,} 3.115 + echo -n "Switching / to loop $loopfs on $dev..." 3.116 + if ! mount $dev /mnt; then 3.117 + if echo $dev | grep -q "/dev/sd"; then 3.118 + delay=`cat /sys/module/usb_storage/parameters/delay_use` 3.119 + delay=$((1+$delay)) 3.120 + echo -n "sleep for $delay seconds..." 3.121 + sleep $delay 3.122 + fi 3.123 + mount $dev /mnt || loopfs="" 3.124 + fi 3.125 + if [ -n "$loopfs" ]; then 3.126 + losetup /dev/loop0 /mnt/$loopfs 3.127 + mount /dev/loop0 /mnt 2> /dev/null 3.128 + fi 3.129 + try_init 3.130 +fi 3.131 +grep -q cryptoroot= /proc/cmdline && try_init 3.132 +umount /sys 3.133 +echo -n "Switching / to tmpfs..." 3.134 +size="$(grep rootfssize= < /proc/cmdline | \ 3.135 + sed 's/.*rootfssize=\([0-9]*[kmg%]\).*/-o size=\1/')" 3.136 +free=$(busybox free | busybox awk '/Mem:/ { print int(($4*100)/$3) }') 3.137 +umount /proc 3.138 +[ -n "$size" ] || size="-o size=90%" 3.139 +if [ $free -lt 100 ] || ! mount -t tmpfs $size tmpfs /mnt; then 3.140 + echo -e "\\033[70G[ \\033[1;33mSkipped\\033[0;39m]" 3.141 + exec /sbin/init 3.142 +fi 3.143 +for i in $(ls -a /); do 3.144 + case "$i" in 3.145 + .|..) ;; 3.146 + mnt) mkdir /mnt/mnt;; 3.147 + *) if ! cp -a /$i /mnt 2> /dev/null; then 3.148 + failed 3.149 + umount /mnt 3.150 + exec /sbin/init 3.151 + fi;; 3.152 + esac 3.153 +done 3.154 +launch_init_modular
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/initramfs/liblinuxlive Thu Nov 25 03:30:16 2010 +0000 4.3 @@ -0,0 +1,1128 @@ 4.4 +#!/bin/bash 4.5 + 4.6 +# Functions library :: for Linux Live scripts 6 4.7 +# Author: Tomas M. <http://www.linux-live.org> 4.8 +# 4.9 + 4.10 +# =========================================================== 4.11 +# GLOBAL variables 4.12 +# =========================================================== 4.13 + 4.14 +# linux live flag to fstab, if fstab line doesn't contain it, 4.15 +# never remove it from fstab automatically (user added it) 4.16 +FSTABLLFLAG="# AutoUpdate" 4.17 + 4.18 +# We have to set these variables very carefully 4.19 +UNION=union 4.20 +MEMORY=memory 4.21 +MOUNTDIR=mnt 4.22 +CHANGES=$MEMORY/changes 4.23 +XINO=$MEMORY/xino 4.24 +COPY2RAM=$MEMORY/copy2ram 4.25 +IMAGES=$MEMORY/images 4.26 +INITRAMDISK=$MOUNTDIR/live 4.27 +LOOPMOUNT=$MOUNTDIR/tmp 4.28 +FINDISOMNT=$MOUNTDIR/findiso 4.29 + 4.30 +# this will be replaced by build script, so never change the following line! 4.31 +LIVECDNAME="slitaz" 4.32 + 4.33 +# ================================================================= 4.34 +# debug and output functions 4.35 +# ================================================================= 4.36 + 4.37 +# global variable 4.38 +DEBUG_IS_ENABLED=$(cat /proc/cmdline 2>/dev/null | grep debug) 4.39 + 4.40 +debug_log() 4.41 +{ 4.42 + if [ "$DEBUG_IS_ENABLED" ]; then 4.43 + echo "- debug: $*" >&2 4.44 + log "- debug: $*" 4.45 + fi 4.46 +} 4.47 + 4.48 +# echogreen will echo $@ in green color 4.49 +# $1 = text 4.50 +# 4.51 +echogreen() 4.52 +{ 4.53 + echo -ne " [1;34m""$@""[0;39m" 4.54 +} 4.55 + 4.56 +# echolog 4.57 +# $1 = text to show and to write to /var/log/messages 4.58 +# 4.59 +echolog() 4.60 +{ 4.61 + if [ "$1" != "" ]; then 4.62 + echogreen "* " 4.63 + log "LIVECD:" "$@" 4.64 + echo "$@" 4.65 + fi 4.66 +} 4.67 + 4.68 +# log 4.69 +# store given text in /var/log/livedbg 4.70 +log() 4.71 +{ 4.72 + echo "$@" 2>/dev/null >>/var/log/livedbg 4.73 +} 4.74 + 4.75 +# show information about the debug shell 4.76 +show_debug_banner() 4.77 +{ 4.78 + echo 4.79 + echo "=====" 4.80 + echo ": Debugging started. Here is the root shell for you." 4.81 + echo ": Type your desired commands or hit Ctrl+D to continue booting." 4.82 + echo 4.83 +} 4.84 + 4.85 +# debug_shell 4.86 +# executed when debug boot parameter is present 4.87 +# 4.88 +debug_shell() 4.89 +{ 4.90 + if [ "$DEBUG_IS_ENABLED" ]; then 4.91 + show_debug_banner 4.92 + ash < /dev/console 4.93 + echo 4.94 + fi 4.95 +} 4.96 + 4.97 +# header 4.98 +# $1 = text to show 4.99 +# 4.100 +header() 4.101 +{ 4.102 + echo "[0;1m""$@""[0;0m" 4.103 +} 4.104 + 4.105 +fatal() 4.106 +{ 4.107 + echolog 4.108 + header "Fatal error occured - $1" 4.109 + echolog "Something went wrong and we can't continue. This should never happen." 4.110 + echolog "Please reboot your computer with Ctrl+Alt+Delete ..." 4.111 + echolog 4.112 + ash < /dev/console 4.113 +} 4.114 + 4.115 +allow_only_root() 4.116 +{ 4.117 + # test if the script is started by root user. If not, exit 4.118 + if [ "0$UID" -ne 0 ]; then 4.119 + echo "Only root can run $(basename $0)"; exit 1 4.120 + fi 4.121 +} 4.122 + 4.123 +# =========================================================== 4.124 +# text processing functions 4.125 +# =========================================================== 4.126 + 4.127 +# look into cmdline and echo $1 back if $1 is set 4.128 +# $1 = value name, case sensitive, for example 'debug' 4.129 +# 4.130 +cmdline_parameter() 4.131 +{ 4.132 + debug_log "cmdline_parameter" "$*" 4.133 + log "searching for bootparam: $1" 4.134 + egrep -o "(^|[[:space:]])$1([[:space:]]|\$)" /proc/cmdline | tr -d " " | tail -n 1 4.135 +} 4.136 + 4.137 +# look into cmdline and echo value of $1 option 4.138 +# $1 = value name, case sensitive, for example 'changes' 4.139 +# 4.140 +cmdline_value() 4.141 +{ 4.142 + debug_log "cmdline_value" "$*" 4.143 + log "searching for bootparam value: $1" 4.144 + egrep -o "(^|[[:space:]])$1=[^[:space:]]+" /proc/cmdline | cut -d "=" -f 2- | tail -n 1 4.145 +} 4.146 + 4.147 +# Make sure the part of a script after 'mutex_lock' call is atomic, 4.148 +# that means the 'locked' part of the script can never be execuetd 4.149 +# from several processes at the same time, in parallel. 4.150 +# Every script waits until it gathers the lock. 4.151 +# The lock directory is saved in /dev instead of /tmp, because /tmp may be 4.152 +# readonly at the time when the lock is needed (eg. when udev is starting) 4.153 +# $1 = name of the lock 4.154 +# 4.155 +mutex_lock() 4.156 +{ 4.157 + debug_log "mutex_lock" "$*" 4.158 + while ! mkdir "/dev/ll-mutex-lock-$1" 2>/dev/null; do 4.159 + usleep 100000; 4.160 + done 4.161 +} 4.162 + 4.163 +# Unlock the lock so another waiting process can reusse it and continue 4.164 +# $1 = name of the lock 4.165 +# 4.166 +mutex_unlock() 4.167 +{ 4.168 + debug_log "mutex_unlock" "$*" 4.169 + rmdir "/dev/ll-mutex-lock-$1" 2>/dev/null 4.170 +} 4.171 + 4.172 +# =========================================================== 4.173 +# system functions 4.174 +# =========================================================== 4.175 + 4.176 +# setup /usr from /usr.lzm inside initrd 4.177 +mount_initrd_loops() 4.178 +{ 4.179 + debug_log "mount_initrd_loops" "$*" 4.180 + if [ -e /usr.lzm ]; then 4.181 + mount_device /usr.lzm /usr loop,ro squashfs 4.182 + fi 4.183 + if [ -e /drivers.lzm ]; then 4.184 + mount_device /drivers.lzm /lib/modules/*/kernel/drivers loop,ro squashfs 4.185 + fi 4.186 +} 4.187 + 4.188 +# modprobe module $1, including all dependencies, suppress all messages 4.189 +# This was own function, because modprobe in busybox didn't support 4.190 +# neither gzipped modules nor dependencies. Seems to be fixed now, though. 4.191 +# $1 = module name, eg. ehci-hcd 4.192 +# $* = optional arguments 4.193 +# 4.194 +modprobe_module() 4.195 +{ 4.196 + debug_log "modprobe_module" "$*" 4.197 + local MODULE 4.198 + 4.199 + MODULE="$1" 4.200 + shift 4.201 + 4.202 + if [ ! "$MODULE" ]; then return 1; fi 4.203 + modprobe "$MODULE" $* 2>/dev/null 4.204 +} 4.205 + 4.206 +cdname() 4.207 +{ 4.208 + if [ "$(cmdline_value cdname)" != "" ]; then 4.209 + LIVECDNAME="$(cmdline_value cdname)" 4.210 + else 4.211 + LIVECDNAME="${LIVECDNAME}" 4.212 + fi 4.213 +} 4.214 + 4.215 +cdname 4.216 + 4.217 +# mknod next loop device 4.218 +# - find biggest loop device in /dev/loop/, assume it to be used 4.219 +# - preallocate (mknod) 20 more loop devices in one round 4.220 +mknod_next_loop_dev() 4.221 +{ 4.222 + debug_log "mknod_next_loop_dev" "$*" 4.223 + local i NR END PFX 4.224 + 4.225 + mutex_lock mknod_next_loop_dev 4.226 + 4.227 + if [ -d /dev/loop ]; then 4.228 + NR=$(find /dev/loop/ -maxdepth 1 | sed -r 's/[^0-9]+//' | sort -n | tail -n 1) 4.229 + PFX="/" 4.230 + else 4.231 + NR=$(find /dev/ -maxdepth 1 | grep loop | sed -r 's/[^0-9]+//' | sort -n | tail -n 1) 4.232 + PFX="" 4.233 + fi 4.234 + NR=$(expr 0$NR + 1) 4.235 + END=$(expr 0$NR + 20) 4.236 + for i in $(seq $NR $END); do 4.237 + mknod /dev/loop$PFX$i b 7 $i 2>/dev/null 4.238 + done 4.239 + echo /dev/loop$PFX$NR 4.240 + 4.241 + mutex_unlock mknod_next_loop_dev 4.242 +} 4.243 + 4.244 +# =========================================================== 4.245 +# Filesystem functions 4.246 +# =========================================================== 4.247 + 4.248 +# Find out what locale is requested 4.249 +# If no locale is given, use the firts one available (if any) 4.250 +# $1 = locale (optional argument, if exists, no autodetection is made) 4.251 +locale_id() 4.252 +{ 4.253 + debug_log "locale_id" "$*" 4.254 + local LOCALE i 4.255 + 4.256 + # first try to find out locale from boot parameters 4.257 + LOCALE="$1" 4.258 + if [ "$LOCALE" = "" ]; then LOCALE=$(cmdline_value locale); fi 4.259 + if [ "$LOCALE" = "" ]; then LOCALE=$(cmdline_value language); fi 4.260 + if [ "$LOCALE" = "" ]; then LOCALE=$(cmdline_value lang); fi 4.261 + 4.262 + # if not found, set it to locale from usr/lib/locale, 4.263 + # but only if there is just ONE directory, nothing more 4.264 + # (so we are sure which one to use) 4.265 + if [ "$LOCALE" = "" ]; then 4.266 + for LOCALE in $(ls -A1p /usr/lib/locale 2>/dev/null | grep / | sed -r "s:[/]|[.].*::"); do 4.267 + i="1$i" 4.268 + done 4.269 + if [ "$i" != "1" ]; then LOCALE=""; fi 4.270 + fi 4.271 + 4.272 + if [ "$LOCALE" != "" -a -e /usr/share ]; then 4.273 + cat /usr/share/locale/locale.alias | sed -r "s/#.*//" | egrep "$LOCALE|$LOCALE""_" | tail -n 1 | tr -s "[[:space:]]" " " | cut -d " " -f 2- | tr -d " " 4.274 + fi 4.275 +} 4.276 + 4.277 +# Find out what iocharset to use 4.278 +iocharset() 4.279 +{ 4.280 + debug_log "iocharset" "$*" 4.281 + local CHARSET IOCHARSET 4.282 + 4.283 + # if iocharset is explicitly set at the boot prompt, 4.284 + # return it regardless the locale settings 4.285 + IOCHARSET=$(cmdline_value iocharset) 4.286 + if [ "$IOCHARSET" != "" ]; then 4.287 + echo $IOCHARSET 4.288 + return 0; 4.289 + fi 4.290 + 4.291 + # else find out the iocharset from locale_id output, it should match 4.292 + # some kernel module (after stripping out few of the dashes) 4.293 + IOCHARSET=$(locale_id | cut -d . -f 2- | tr "[[:upper:]]" "[[:lower:]]" | tr -d -) 4.294 + if [ "$IOCHARSET" = "" ]; then return 0; fi 4.295 + 4.296 + find /lib/modules -name "nls_*" | sed -r 's:^.*/|[.]ko$::g' | cut -b 5- | while read CHARSET; do 4.297 + if [ "$(echo $CHARSET | tr "[[:upper:]]" "[[:lower:]]" | tr -d -)" = "$IOCHARSET" ]; then 4.298 + echo "$CHARSET" 4.299 + return 0 4.300 + fi 4.301 + done 4.302 + return 1 4.303 +} 4.304 + 4.305 +# Get filesystem options 4.306 +# $1 = filesystem 4.307 +# $2 = 'fstab' or 'mount' ... 'auto'/'noauto' string is enabled (fstab) or disabled (mount) 4.308 +# 4.309 + 4.310 +fs_options() 4.311 +{ 4.312 + debug_log "fs_options" "$*" 4.313 + local NOAUTO IOCHARSET 4.314 + 4.315 + NOAUTO=$(cmdline_parameter noauto) 4.316 + if [ "$NOAUTO" = "" ]; then NOAUTO="auto"; fi 4.317 + if [ "$2" = "fstab" ]; then echo -n "$NOAUTO," ; fi 4.318 + if [ "$1" = "swap" ]; then echo "defaults,pri=1"; return 0; fi 4.319 + echo -n "noatime,users,suid,dev,exec" 4.320 + 4.321 + IOCHARSET=$(iocharset) 4.322 + 4.323 + if [ "$1" = "vfat" ]; then 4.324 + echo -n ",quiet,umask=0,check=s,shortname=mixed" 4.325 + if [ "$IOCHARSET" ]; then 4.326 + echo ",iocharset=$IOCHARSET" 4.327 + fi 4.328 + fi 4.329 + 4.330 + if [ "$1" = "iso9660" -o "$1" = "iso9660,udf" ]; then 4.331 + echo -n ",ro" 4.332 + if [ "$IOCHARSET" ]; then 4.333 + echo ",iocharset=$IOCHARSET" 4.334 + fi 4.335 + fi 4.336 + 4.337 + if [ "$1" = "ntfs" ]; then 4.338 + echo -n ",ro" 4.339 + if [ "$IOCHARSET" ]; then 4.340 + echo ",nls=$IOCHARSET" 4.341 + fi 4.342 + fi 4.343 + 4.344 + if [ "$1" = "ntfs-3g" ]; then 4.345 + echo ",locale=$(locale_id)" 4.346 + fi 4.347 + 4.348 + if [ "$1" = "ext3" -o "$1" = "ext4" ]; then 4.349 + echo ",barrier=1,data=ordered" 4.350 + fi 4.351 + 4.352 +} 4.353 + 4.354 +# discover filesystem used on the given device 4.355 +# Use vfat for msdos filesystem. Use ntfs-3g for ntfs if ntfs-3g exists. 4.356 +# $1 = device, eg. /dev/hda1 4.357 +# 4.358 +device_filesystem() 4.359 +{ 4.360 + debug_log "device_filesystem" "$*" 4.361 + local NTFS 4.362 + 4.363 + if [ -e /bin/ntfs-3g ]; then NTFS="ntfs-3g"; else NTFS="ntfs"; fi 4.364 + blkid -s TYPE "$1" -o value | sed "s/msdos/vfat/" | sed "s/ntfs/$NTFS/" 4.365 +} 4.366 + 4.367 +# tell us if the given filesystem is supported 4.368 +# (eg. it's in /proc/filesystems or we know it) 4.369 +# $1 = filesystem name 4.370 +# 4.371 +is_supported_filesystem() 4.372 +{ 4.373 + debug_log "is_supported_filesystem" "$*" 4.374 + 4.375 + if [ -e /bin/ntfs-3g -a "$1" = "ntfs-3g" ]; then 4.376 + return 0 4.377 + fi 4.378 + 4.379 + # the following command will set the return value 4.380 + egrep -q "[[:space:]]$1\$" /proc/filesystems 4.381 +} 4.382 + 4.383 +# Mount device $1 to $2 4.384 +# If the device is using vfat or ntfs filesystem, use iocharset as a mount option 4.385 +# $1 = /dev device to mount, eg. /dev/hda1, or loop file, or directory 4.386 +# $2 = mountpoint, eg. /mnt/hda1 4.387 +# $3 = optional mount options, for example "ro", or "remount,rw" 4.388 +# $4 = optional filesystem name, in order to skip autodetection 4.389 +# 4.390 +mount_device() 4.391 +{ 4.392 + debug_log "mount_device" "$*" 4.393 + local FS DEV LOOPDEV OPTIONS FILESYSTEM ERR 4.394 + 4.395 + # make sure we have enough arguments 4.396 + if [ "$2" = "" ]; then return 1; fi 4.397 + if [ "$1" = "" ]; then rmdir "$2" 2>/dev/null; return 1; fi 4.398 + mkdir -p "$2" 4.399 + 4.400 + DEV="$1" 4.401 + if [ "$4" != "" ]; then FS="$4"; else FS=$(device_filesystem "$1"); fi 4.402 + if [ "$FS" ]; then OPTIONS=$(fs_options $FS mount); FS="-t $FS"; fi 4.403 + if [ "$OPTIONS" ]; then OPTIONS="$OPTIONS"; else OPTIONS=""; fi 4.404 + if [ -f "$DEV" ]; then OPTIONS="$OPTIONS,loop"; fi 4.405 + if [ -d "$DEV" ]; then OPTIONS="$OPTIONS,rbind"; fi 4.406 + if [ "$3" ]; then OPTIONS="$OPTIONS,$3"; fi 4.407 + OPTIONS=$(echo "$OPTIONS" | sed -r "s/^,+//") 4.408 + 4.409 + if [ "$FS" = "-t ntfs-3g" ]; then 4.410 + ntfs-3g "$DEV" "$2" -o $OPTIONS >/dev/null 2>&1 4.411 + ERR=$? 4.412 + else 4.413 + mount -n -o $OPTIONS $FS "$DEV" "$2" >/dev/null 2>&1 4.414 + ERR=$? 4.415 + fi 4.416 + 4.417 + # not enough loop devices? try to create one. 4.418 + if [ $ERR -eq 2 ]; then 4.419 + LOOPDEV=$(mknod_next_loop_dev) 4.420 + OPTIONS=$(echo "$OPTIONS" | sed -r "s/,loop//g") 4.421 + losetup "$LOOPDEV" "$DEV" 2>/dev/null # busybox's losetup doesn't support -r 4.422 + if [ $? -ne 0 ]; then 4.423 + losetup -r "$LOOPDEV" "$DEV" 2>/dev/null # force read-only in case of error 4.424 + fi 4.425 + mount -n -o $OPTIONS $FS "$LOOPDEV" "$2" >/dev/null 2>&1 4.426 + ERR=$? 4.427 + fi 4.428 + 4.429 + # if nothing works, try to force read-only mount 4.430 + if [ $ERR -ne 0 ]; then 4.431 + mount -n -r -o $OPTIONS $FS "$DEV" "$2" >/dev/null 2>&1 4.432 + ERR=$? 4.433 + fi 4.434 + 4.435 + if [ $ERR -ne 0 ]; then rmdir $2 2>/dev/null; fi 4.436 + return $ERR 4.437 +} 4.438 + 4.439 +# unmount all parameters. If the parameter is not mountpoint but 4.440 +# it's a file or directory, umount the device where the file/dir is stored. 4.441 +# 4.442 +# First try normal umount, if that fails then remount read-only 4.443 +# If -l parameter is specified, do lazy-umount when normal umount fails 4.444 +# $1..$n = files/directories/devices to be unmounted 4.445 +# 4.446 +fumount() 4.447 +{ 4.448 + debug_log "fumount" "$*" 4.449 + local TARGET LAZY 4.450 + 4.451 + while [ "$1" ]; do 4.452 + if [ "$1" = "-l" ]; then LAZY="yes"; shift; fi 4.453 + TARGET=$(readlink -f "$1") 4.454 + if ! ismountpoint "$TARGET"; then 4.455 + if [ -f "$TARGET" -o -d "$TARGET" ]; then 4.456 + TARGET=$(df "$TARGET" | tail -n 1 | tr -s " " | cut -d " " -f 6) 4.457 + fi 4.458 + fi 4.459 + 4.460 + if [ "$TARGET" != "" ]; then 4.461 + umount -n "$TARGET" >/dev/null 2>&1 4.462 + if [ $? -ne 0 ]; then 4.463 + mount -n -o remount,ro -t ignored ignored "$TARGET" >/dev/null 2>&1 4.464 + if [ "$LAZY" ]; then umount -n -l "$TARGET" >/dev/null 2>&1; fi 4.465 + fi 4.466 + fi 4.467 + shift 4.468 + done 4.469 +} 4.470 + 4.471 +# =========================================================== 4.472 +# live module functions 4.473 +# =========================================================== 4.474 + 4.475 +# Create module 4.476 +# call mksquashfs with apropriate arguments 4.477 +# $1 = directory which will be compressed to squashfs module 4.478 +# $2 = output filesystem module file 4.479 +# $3..$9 = optional arguments like -keep-as-directory or -b 123456789 4.480 +# 4.481 +create_module() 4.482 +{ 4.483 + debug_log "create_module" "$*" 4.484 + rm -f "$2" # overwrite, never append to existing file 4.485 + mksquashfs "$1" "$2" -b 256K $3 $4 $5 $6 $7 $8 $9>/dev/null 4.486 + if [ $? -ne 0 ]; then return 1; fi 4.487 + chmod a-wx "$2" # remove execute and write attrib 4.488 + chmod a+r "$2" # add read for everyone 4.489 +} 4.490 + 4.491 +# ismountpoint exits with 0 if $1 is mountpoint, else exits with 1 4.492 +# $1 = directory or loop_file 4.493 +# 4.494 +ismountpoint() 4.495 +{ 4.496 + debug_log "ismountpoint" "$*" 4.497 + local MDIR 4.498 + 4.499 + MDIR=$(readlink -f "$1") 4.500 + cat /proc/mounts | cut -d " " -f 2 | egrep "^$MDIR\$" >/dev/null 2>&1 4.501 +} 4.502 + 4.503 +# Mount filesystem module to destination directory 4.504 +# $1 = path to the compressed module 4.505 +# $2 = destination folder 4.506 +# 4.507 +mount_module() 4.508 +{ 4.509 + debug_log "mount_module" "$*" 4.510 + mount_device "$1" "$2" loop,ro squashfs 4.511 +} 4.512 + 4.513 +# Insert a directory tree $2 to an union specified by $1 4.514 +# Top-level read-write branch is specified by it's index 0 4.515 +# Using =rr enables aufs to optimize real readonly branches 4.516 +# $1 = union absolute path (starting with /) 4.517 +# $2 = path to data directory 4.518 +# 4.519 +union_insert_dir() 4.520 +{ 4.521 + debug_log "union_insert_dir" "$*" 4.522 + mount -n -o remount,add:1:$2=rr aufs $1 4.523 +} 4.524 + 4.525 +# Find LZM modules in given dir 4.526 +# $1 = root directory of mounted DATAdir 4.527 +# 4.528 +find_modules() 4.529 +{ 4.530 + debug_log "find_modules" "$*" 4.531 + if [ "$(cmdline_parameter baseonly)" ]; then 4.532 + find "$1/base" "$1/optional" -name "*.sqfs" 2>/dev/null | sort 4.533 + find "$1/base" "$1/optional" -name "*.lzm" 2>/dev/null | sort 4.534 + else 4.535 + find "$1/base" "$1/modules" "$1/optional" "$1/tmp" -name "*.sqfs" 2>/dev/null | sort 4.536 + find "$1/base" "$1/modules" "$1/optional" "$1/tmp" -name "*.lzm" 2>/dev/null | sort 4.537 + fi 4.538 +} 4.539 + 4.540 +# List all modules in all directories (base, modules, optional) 4.541 +# and filter out unneeded optional modules (not specified by load= kernel parameter) 4.542 +# separator for load and noload arguments is "," or ";" 4.543 +# $1 = root directory of mounted DATAdir 4.544 +# 4.545 +list_modules() 4.546 +{ 4.547 + debug_log "list_modules" "$*" 4.548 + local LOAD NOLOAD 4.549 + 4.550 + LOAD=$(cmdline_value load | sed -r 's/\*/.\*/g' | sed -r 's/,|;/|/g') 4.551 + NOLOAD=$(cmdline_value noload | sed -r 's/\*/.\*/g' | sed -r 's/,|;/|/g') 4.552 + find_modules "$1" | while read LINE; do 4.553 + MODNAME=$(echo $LINE | cut -b ${#1}- | cut -b 2-) 4.554 + if [ "$(echo $LINE | grep /optional/)" ]; then 4.555 + if [ ! "$LOAD" -o ! "$(echo $MODNAME | egrep -i "$LOAD")" ]; then continue; fi 4.556 + fi 4.557 + if [ "$NOLOAD" -a "$(echo $MODNAME | egrep -i "$NOLOAD")" ]; then continue; fi 4.558 + echo $LINE 4.559 + done 4.560 +} 4.561 + 4.562 +# Insert one single filesystem module to the union 4.563 +# $1 = union absolute path 4.564 +# $2 = module full path 4.565 +# $3 = destination folder, where images will be mounted to 4.566 +# $4 = preffix length strip (number of characters) 4.567 +# 4.568 +union_insert_module() 4.569 +{ 4.570 + debug_log "union_insert_module" "$*" 4.571 + local TARGET 4.572 + 4.573 + TARGET="$3/$(basename $2)" 4.574 + if ismountpoint $TARGET; then return 1; fi # skip already used modules 4.575 + mkdir -p $TARGET 4.576 + mount_module $2 $TARGET 4.577 + if [ $? -ne 0 ]; then echo "Cannot read module data. corrupted download?" >&2; return 1; fi 4.578 + union_insert_dir $1 $TARGET 4.579 + if [ $? -ne 0 ]; then echo "can't insert module to union" >&2; return 2; fi 4.580 + echo "$2" | cut -b $(($4+1))- 4.581 + echolog "$2" >/dev/null 4.582 + return 0 4.583 +} 4.584 + 4.585 +# Insert all filesystem modules from $2 directory and subdirectories, to the union 4.586 +# $1 = union absolute path (starting with /) 4.587 +# $2 = LiveCD data dir (with directories /base, /modules, etc.) 4.588 +# $3 = destination folder, where images will be mounted to 4.589 +# 4.590 +union_insert_modules() 4.591 +{ 4.592 + debug_log "union_insert_modules" "$*" 4.593 + local INSERTED 4.594 + 4.595 + list_modules $2 | while read MODULE; do 4.596 + INSERTED=$(union_insert_module $1 $MODULE $3 ${#2}) 4.597 + if [ "$INSERTED" != "" ]; then echolog " -> $(echo $INSERTED | sed -r s:^/::)"; fi 4.598 + done 4.599 +} 4.600 + 4.601 +# Copy LiveCD modules to RAM directory 4.602 +# will copy only /boot, and module files from $1 4.603 +# $1 = data directory 4.604 +# $2 = target directory in RAM 4.605 +# 4.606 +copy_to_ram() 4.607 +{ 4.608 + debug_log "copy_to_ram" "$*" 4.609 + cp -a "$1/rootcopy" "$2" 2>/dev/null # could be empty 4.610 + list_modules "$1" | while read MODULE; do 4.611 + TARGET=$(dirname "$MODULE" | cut -b ${#1}- | cut -b 2-) 4.612 + mkdir -p "$2/$TARGET" 4.613 + cp "$MODULE" "$2/$TARGET" 4.614 + if [ $? -ne 0 ]; then fatal "Not enough memory. Using ramsize=$RAMSIZE"; fi 4.615 + done 4.616 +} 4.617 + 4.618 +# =========================================================== 4.619 +# discovery functions 4.620 +# =========================================================== 4.621 + 4.622 +# List all supported network drivers 4.623 +# 4.624 +list_network_drivers() 4.625 +{ 4.626 + debug_log "list_network_drivers" "$*" 4.627 + 4.628 + # these drivers are probed in Slackware's initrd 4.629 + # (see initrd.img/scripts/network.sh). 4.630 + # I don't have personal experiences with most of these drivers 4.631 + # so I'll be happy if you report any particular one to be not working 4.632 + # (eg. causing hangups) in order to remove it from this list. 4.633 + 4.634 + echo 3c59x acenic atl1 de4x5 dgrs eepro100 e1000 epic100 hp100 ne2k-pci \ 4.635 + olympic pcnet32 r8169 rcpci 8139too 8139cp sktr skge sky2 tulip via-rhine \ 4.636 + yellowfin tg3 dl2k ns83820 depca ibmtr 3c501 3c503 3c505 3c507 3c509 3c515 \ 4.637 + ac3200 acenic at1700 cosa cs89x0 de4x5 de600 de620 e2100 eepro eexpress \ 4.638 + es3210 eth16i ewrk3 fmv18x forcedeth hostess_sv11 hp-plus hp lne390 ne3210 \ 4.639 + ni5010 ni52 ni65 sb1000 sealevel smc-ultra sis900 smc-ultra32 smc9194 wd \ 4.640 + | tr " " "\n" 4.641 +} 4.642 + 4.643 +# List all CD-ROMs 4.644 +# by using /proc entries 4.645 +# 4.646 +list_cdrom_devices() 4.647 +{ 4.648 + debug_log "list_cdrom_devices" "$*" 4.649 + local CDDEVICE 4.650 + 4.651 + for CDDEVICE in $(cat /proc/sys/dev/cdrom/info 2>/dev/null | head -n 3 | tail -n 1 | cut -d ":" -f 2); do 4.652 + echo "/dev/$CDDEVICE" 4.653 + done 4.654 +} 4.655 + 4.656 +# List all mounted directories 4.657 +# 4.658 +list_mounted_directories() 4.659 +{ 4.660 + debug_log "list_mounted_directories" "$*" 4.661 + if [ "$MOUNTDIR" ]; then 4.662 + ls -1 $MOUNTDIR | while read DIR; do 4.663 + if ismountpoint $MOUNTDIR/$DIR; then echo $DIR; fi 4.664 + done 4.665 + fi 4.666 +} 4.667 + 4.668 +# List all devices with filesystems 4.669 +# Return empty result when nohd parameter was given. 4.670 +# 4.671 +list_partition_devices() 4.672 +{ 4.673 + debug_log "list_partition_devices" "$*" 4.674 + if [ "$(cmdline_parameter nohd)" != "" ]; then return 1; fi 4.675 + cat /proc/partitions | grep -v loop | grep -v major | grep -v '^$' | sed -r "s:^[0-9 ]+:/dev/:" 4.676 + if [ -e /dev/mapper/control ]; then # list LVM partitions if available 4.677 + ls -1 /dev/mapper/ | grep -v "^control\$" | sed -r "s:^:/dev/mapper/:" 4.678 + fi 4.679 +} 4.680 + 4.681 +# List all disk devices 4.682 +# 4.683 +list_disk_devices() 4.684 +{ 4.685 + debug_log "list_disk_devices" "$*" 4.686 + list_partition_devices | egrep -v "[0-9]" 4.687 +} 4.688 + 4.689 +# List all partitions marked as Linux Swap 4.690 +# 4.691 +list_swap_devices() 4.692 +{ 4.693 + debug_log "list_swap_devices" "$*" 4.694 + if [ "$(cmdline_parameter nohd)" != "" -o "$(cmdline_parameter noswap)" != "" ]; then return 1; fi 4.695 + blkid -t TYPE="swap" -o device 4.696 +} 4.697 + 4.698 +# List all block devices 4.699 +# 4.700 +list_block_devices() 4.701 +{ 4.702 + debug_log "list_block_devices" "$*" 4.703 + if [ "$(cmdline_parameter nocd)" = "" ]; then 4.704 + list_cdrom_devices 4.705 + fi 4.706 + list_partition_devices 4.707 +} 4.708 + 4.709 +# Format mountdir for device. This function used to append _cdrom or _removable 4.710 +# suffix to the directory name so KDE was able to assign a nice icon for evey 4.711 +# device, but this should be done using HAL in KDE nowadays, so we do not 4.712 +# support these stupid suffixes anymore. Many people will be happy :) 4.713 +# $1 = device full path, eg. /dev/hda1 4.714 +# 4.715 +device_mountdir() 4.716 +{ 4.717 + debug_log "device_mountdir" "$*" 4.718 + echo "/$MOUNTDIR/$(basename "$1")" | tr -s / 4.719 +} 4.720 + 4.721 +# Find file-path on given device 4.722 +# First it mounts the device read-only. If then the 'path' is found, 4.723 +# then remount without RO flag (causes it to be mounted read-write if possible) 4.724 +# and return the path, else unmount and exit. 4.725 +# If the device/dev_directory is already mounted, preserve it mounted 4.726 +# $1 = device 4.727 +# $2 = path/filename 4.728 +# 4.729 +find_filepath() 4.730 +{ 4.731 + debug_log "find_filepath" "$*" 4.732 + local DIR FOUND PRESERVE 4.733 + 4.734 + DIR=$(device_mountdir $1) 4.735 + ismountpoint $DIR 4.736 + if [ $? -eq 0 ]; then 4.737 + PRESERVE="true" 4.738 + else 4.739 + mount_device $1 $DIR ro 4.740 + if [ $? -ne 0 ]; then rmdir $DIR 2>/dev/null; return 1; fi 4.741 + PRESERVE="" 4.742 + fi 4.743 + 4.744 + FOUND=$(ls -A1d $DIR/$2 2>/dev/null | head -n 1 | tr -s '/') 4.745 + 4.746 + if [ "$FOUND" = "" ]; then 4.747 + if [ "$PRESERVE" != "true" ]; then 4.748 + fumount $DIR 4.749 + rmdir $DIR 2>/dev/null 4.750 + fi 4.751 + return 1 4.752 + else 4.753 + # remount without the 'ro' option now, so use rw or defaults 4.754 + # Only in the case it was not mounted already before. 4.755 + if [ "$PRESERVE" != "true" ]; then 4.756 + fumount $DIR 4.757 + mount_device $1 $DIR 4.758 + if [ $? -ne 0 ]; then 4.759 + rmdir $DIR 2>/dev/null 4.760 + return 2 4.761 + fi 4.762 + fi 4.763 + echo "$FOUND" 4.764 + return 0 4.765 + fi 4.766 +} 4.767 + 4.768 +# Find file in computer by mounting disks or other storage devices 4.769 +# and searching for $1 in the mounted directory 4.770 +# $1 = filename or device-path or devicepath/filename 4.771 +# 4.772 +find_file() 4.773 +{ 4.774 + debug_log "find_file" "$*" 4.775 + local FIND DEVICE DEVPART PATHPART 4.776 + 4.777 + # allow using /mnt/... as well as /dev/... 4.778 + FIND=$(echo "$1" | sed -r "s:^/mnt/:/dev/:") 4.779 + 4.780 + # if parameter is just a device, echo it and exit 4.781 + if [ -b "$FIND" -o -c "$FIND" -o "$FIND" = "" ]; then echo "$FIND"; return; fi 4.782 + 4.783 + # If path doesn't start with /dev/, try to find the exact path on all devices 4.784 + # First, split DEV/PATH parts 4.785 + DEVPART=$(echo "$FIND" | egrep -o "^/dev/[^/]+") 4.786 + 4.787 + if [ "$DEVPART" = "" ]; then 4.788 + # no device is specified. Search all devices for filename $FIND 4.789 + PATHPART="$FIND"; 4.790 + for DEVICE in $(list_mounted_directories) $(list_block_devices); do 4.791 + if ! grep -q ":$DEVICE@$PATHPART:" /tmp/_findfile 2>/dev/null; then 4.792 + find_filepath "$DEVICE" "$PATHPART" 4.793 + if [ $? -eq 0 ]; then return 0; fi 4.794 + echo ":$DEVICE@$PATHPART:" >>/tmp/_findfile 4.795 + fi 4.796 + done 4.797 + else 4.798 + # try to find PATHPART only on the given device 4.799 + PATHPART=$(echo "$FIND" | sed -r 's:^/dev/[^/]+(.*):\1:') 4.800 + find_filepath $DEVPART $PATHPART 4.801 + fi 4.802 +} 4.803 + 4.804 +# Find In Computer 4.805 +# use 'find_file' function to find the given file/dir 4.806 +# if nothing found, sleep for a while to allow devices to settle and try again. 4.807 +# (is there any way to find out if there are devices queued through /sys?) 4.808 +# $1 = file or directory to find 4.809 +# 4.810 +find_in_computer() 4.811 +{ 4.812 + debug_log "find_in_computer" "$*" 4.813 + local TIMEOUT RESULT 4.814 + 4.815 + TIMEOUT=$(cmdline_value scantimeout | sed -r 's/[^0-9]*([0-9]+).*/\1/') 4.816 + if [ "$TIMEOUT" = "" ]; then TIMEOUT=10; fi 4.817 + 4.818 + RESULT=$(find_file "$1") 4.819 + 4.820 + while [ $TIMEOUT -gt 0 -a "$RESULT" = "" ]; do 4.821 + echo -ne "- wait a while\r" >&2 4.822 + sleep 1 4.823 + TIMEOUT=$((TIMEOUT-1)) 4.824 + RESULT=$(find_file "$1") 4.825 + done 4.826 + 4.827 + echo $RESULT 4.828 +} 4.829 + 4.830 +# Find and run all scripts from the given module 4.831 +# This function is used by the activate and deactivate script when the distro 4.832 +# is already started, not during live setup 4.833 +# $1 = mounted module full path 4.834 +# $2..$n = optional arguments for the scripts, eg. 'start' 4.835 +# 4.836 +find_n_run_scripts() 4.837 +{ 4.838 + debug_log "find_n_run_scripts" "$*" 4.839 + local MOD 4.840 + 4.841 + MOD="$1" 4.842 + shift 4.843 + 4.844 + if [ -d $MOD/etc/rc.d -o -d $MOD/etc/rc.d/init.d -o -d $MOD/etc/init.d ]; then 4.845 + ( find $MOD/etc/rc.d -type f -maxdepth 1 2>/dev/null ; \ 4.846 + find $MOD/etc/init.d -type f -maxdepth 1 2>/dev/null ; \ 4.847 + find $MOD/etc/rc.d/init.d -type f -maxdepth 1 2>/dev/null \ 4.848 + ) | cut -b ${#MOD}- | cut -b 2- | xargs -n 1 -r readlink -f | sort -u | while read SCRIPT; do 4.849 + if [ "$SCRIPT" != "" -a -x "$SCRIPT" -a ! -d "$SCRIPT" ]; then 4.850 + # call the script by real path, not from the module 4.851 + log "starting '$SCRIPT $@'" 4.852 + ${SCRIPT} "$@" 4.853 + fi 4.854 + done 4.855 + fi 4.856 +} 4.857 + 4.858 +# =========================================================== 4.859 +# hardware preparation functions 4.860 +# =========================================================== 4.861 + 4.862 +# Create block devices to /dev described by /sys entries 4.863 +# 4.864 +mdev_start_hotplug() 4.865 +{ 4.866 + debug_log "mdev_start_hotplug" "$*" 4.867 + echolog "Creating /dev entries for block devices" 4.868 + mdev -s 4.869 + #rm /dev/pty??* /dev/tty??* # remove unneeded pty and tty devices 4.870 + echo /bin/mdev > /proc/sys/kernel/hotplug # use mdev as a hotplug handler 4.871 +} 4.872 + 4.873 +# Modprobe kernel modules needed for the LiveCD 4.874 +# 4.875 +modprobe_essential_modules() 4.876 +{ 4.877 + debug_log "modprobe_essential_modules" "$*" 4.878 + 4.879 + echolog "Loading filesystems modules ..." 4.880 + modprobe_module loop 4.881 + modprobe_module isofs 4.882 + #modprobe_module sqlzma 4.883 + modprobe_module squashfs 4.884 + #modprobe_module unlzma 4.885 + modprobe_module aufs brs=1 4.886 + modprobe_module ext2 4.887 + modprobe_module ext3 4.888 + modprobe_module ext4 4.889 + modprobe_module btrfs 4.890 + modprobe_module reiserfs 4.891 + modprobe_module xfs 4.892 + modprobe_module vfat 4.893 + modprobe_module fuse # for ntfs-3g 4.894 + modprobe_module ntfs # for ro driver 4.895 +} 4.896 + 4.897 +# Modprobe kernel modules needed for USB masstorage devices 4.898 +# 4.899 +modprobe_usb_modules() 4.900 +{ 4.901 + debug_log "modprobe_usb_modules" "$*" 4.902 + local LSPCI 4.903 + 4.904 + # skip module loading if nohotplug bootparam is present 4.905 + if [ "$(cmdline_parameter nohotplug)" ]; then return 0; fi 4.906 + 4.907 + LSPCI=$(lspci -v | grep -i prog-if) 4.908 + if [ "$(echo $LSPCI | egrep -i [eou]hci)" = "" ]; then 4.909 + return 0 4.910 + fi 4.911 + 4.912 + echolog "Loading USB modules ..." 4.913 + if [ "$(echo $LSPCI | grep -i ehci)" != "" ]; then 4.914 + modprobe_module ehci-hcd 4.915 + fi 4.916 + if [ "$(echo $LSPCI | grep -i ohci)" != "" ]; then 4.917 + modprobe_module ohci-hcd 4.918 + fi 4.919 + if [ "$(echo $LSPCI | grep -i uhci)" != "" ]; then 4.920 + modprobe_module uhci-hcd 4.921 + fi 4.922 + modprobe_module usb-storage 4.923 +} 4.924 + 4.925 +# Load drivers for PCMCIA CardBus devices 4.926 +# 4.927 +modprobe_pcmcia_modules() 4.928 +{ 4.929 + debug_log "modprobe_pcmcia_modules" "$*" 4.930 + 4.931 + # skip module loading if nohotplug bootparam is present 4.932 + if [ "$(cmdline_parameter nohotplug)" ]; then return 0; fi 4.933 + 4.934 + echolog "Loading PCMCIA CardBus modules ..." 4.935 + modprobe_module pcmcia_core 4.936 + modprobe_module pcmcia 4.937 + modprobe_module rsrc_nonstatic 4.938 + modprobe_module yenta_socket 4.939 +} 4.940 + 4.941 +# Load network drivers unless eth[0-9] is found 4.942 +# 4.943 +modprobe_network_modules() 4.944 +{ 4.945 + debug_log "modprobe_network_modules" "$*" 4.946 + local ETH 4.947 + 4.948 + # skip module loading if nohotplug bootparam is present 4.949 + if [ "$(cmdline_parameter nohotplug)" ]; then return 0; fi 4.950 + 4.951 + # probe all drivers. Start by the ones mentioned in pcimodules' output 4.952 + for module in $(list_network_drivers | egrep "$(pcimodules | tr "\n" "|")!") $(list_network_drivers); do 4.953 + modprobe_module $module 4.954 + ETH=$(cat /proc/net/dev | grep : | grep -v lo: | cut -d : -f 1 | tr -d " ") 4.955 + if [ "$ETH" != "" ]; then 4.956 + echo $ETH 4.957 + return 0 4.958 + fi 4.959 + rmmod $module 2>/dev/null 4.960 + done 4.961 +} 4.962 + 4.963 +# Start udhcpc to get IP address from DHCP server 4.964 +# $1 = interface to use (optional) 4.965 +# 4.966 +init_dhcp() 4.967 +{ 4.968 + debug_log "start_dhcp_client" "$*" 4.969 + 4.970 + if [ "$1" != "" ]; then 4.971 + ifconfig $1 up 4.972 + udhcpc -i $1 -q 4.973 + else 4.974 + ifconfig eth0 up 4.975 + udhcpc -q 4.976 + fi 4.977 +} 4.978 + 4.979 +# Mount http filesystem from the given server 4.980 +# $1 = server 4.981 +# $2 = mountdir 4.982 +# 4.983 +mount_httpfs() 4.984 +{ 4.985 + debug_log "mount_httpfs" "$*" 4.986 + 4.987 + mkdir -p $2 4.988 + httpfs $1 $2 4.989 +} 4.990 + 4.991 + 4.992 +# Unload modules loaded to kernel which are not used 4.993 +# This function used to unload more modules, but it may cause 4.994 +# problems to auto-remove some of them (eg. a network module 4.995 +# can seem unneeded even if network is to be used very soon. 4.996 +# 4.997 +rmmod_unused_modules() 4.998 +{ 4.999 + debug_log "rmmod_unused_modules" "$*" 4.1000 + rmmod usb-storage uhci-hcd ohci-hcd ehci-hcd 2>/dev/null 4.1001 + rmmod yenta_socket rsrc_nonstatic pcmcia pcmcia_core 2>/dev/null 4.1002 +} 4.1003 + 4.1004 +# kill all unneeded processes, which have bigger PID then the PID of 4.1005 +# current shell. We can't use killall5, as it would kill some processes 4.1006 +# which may be currently needed, for example ntfs-3g. 4.1007 +# $1 = maximum pid (kill all lower) 4.1008 +# 4.1009 +killall_unneeded() 4.1010 +{ 4.1011 + debug_log "killall_unneeded" "$*" 4.1012 + local LIST PID 4.1013 + 4.1014 + PID=$1 4.1015 + for pid in $(ps | grep -v "PID" | egrep -v "\[.*\]" | fgrep -v mount | fgrep -v posixovl | fgrep -v ntfs | sed -r "s/^[[:space:]]*([0-9]+).*/\\1/"); do 4.1016 + if [ $pid -lt $PID ]; then 4.1017 + LIST="$LIST $pid" 4.1018 + fi 4.1019 + done 4.1020 + 4.1021 + kill -SIGTERM $LIST 2>/dev/null # SIGTERM 4.1022 + sleep 2 4.1023 + kill -SIGKILL $LIST 2>/dev/null # SIGKILL 4.1024 +} 4.1025 + 4.1026 +# enable/disable CD autoejecting when unmounted 4.1027 +# $1 = 1|0 ... enable|disable 4.1028 +# 4.1029 +cd_autoeject() 4.1030 +{ 4.1031 + debug_log "cd_autoeject" "$*" 4.1032 + echo $1 >/proc/sys/dev/cdrom/autoeject 4.1033 +} 4.1034 + 4.1035 +# =========================================================== 4.1036 +# FSTAB functions 4.1037 +# =========================================================== 4.1038 + 4.1039 +# $1 = fstab file 4.1040 +# $2 = device name 4.1041 +dev_is_in_fstab() 4.1042 +{ 4.1043 + debug_log "dev_is_in_fstab" "$*" 4.1044 + cat "$1" | sed -r "s/#.*//" | egrep -q "^[[:space:]]*$2[[:space:]]" 4.1045 +} 4.1046 + 4.1047 +# update given line in fstab, add new values only if the device is not found 4.1048 +# $1 = fstab file to parse 4.1049 +# $2 = device name 4.1050 +# $3 = mountpoint 4.1051 +# $4 = filesystem 4.1052 +# $5 = mount options 4.1053 +# 4.1054 +fstab_add_line() 4.1055 +{ 4.1056 + debug_log "fstab_add_line" "$*" 4.1057 + local DIR 4.1058 + 4.1059 + if [ "$4" != "swap" ]; then DIR="$3"; else DIR="none"; fi 4.1060 + if ! dev_is_in_fstab "$1" "$2"; then 4.1061 + echo "$2" "$DIR" "$4" "$5" 0 0 "$FSTABLLFLAG" >>$1 4.1062 + fi 4.1063 +} 4.1064 + 4.1065 +# create correct fstab file in $1/etc/fstab and create apropriate 4.1066 +# mount directories in $1/mnt. This function is only calld once, 4.1067 +# during liveCD startup (even before init from the distro is started). 4.1068 +# $1 = root directory (union) 4.1069 +# 4.1070 +fstab_update() 4.1071 +{ 4.1072 + debug_log "fstab_update" "$*" 4.1073 + local FSTAB FSTABTMP 4.1074 + 4.1075 + FSTAB="$1/etc/fstab" 4.1076 + FSTABTMP=$FSTAB$$ 4.1077 + mkdir -p $1/etc $1/mnt 4.1078 + cat $FSTAB 2>/dev/null | grep -v "$FSTABLLFLAG" >$FSTABTMP 4.1079 + 4.1080 + fstab_add_line $FSTABTMP none / unionfs defaults 4.1081 + fstab_add_line $FSTABTMP none /proc proc defaults 4.1082 + fstab_add_line $FSTABTMP none /sys sysfs defaults 4.1083 + fstab_add_line $FSTABTMP none /dev/pts devpts gid=5,mode=620 4.1084 + fstab_add_line $FSTABTMP tmpfs /dev/shm tmpfs defaults 4.1085 + 4.1086 + list_cdrom_devices | while read DEVICE; do 4.1087 + MNT=$(device_mountdir $DEVICE) 4.1088 + FS=$(device_filesystem $DEVICE) 4.1089 + if [ "$FS" = "" ]; then FS=iso9660,udf; fi 4.1090 + mkdir -p "$1/$MNT" 4.1091 + fstab_add_line $FSTABTMP $DEVICE $MNT $FS $(fs_options $FS fstab) 4.1092 + done 4.1093 + list_partition_devices | while read DEVICE; do 4.1094 + MNT=$(device_mountdir $DEVICE) 4.1095 + FS=$(device_filesystem $DEVICE) 4.1096 + OPT=$(fs_options $FS fstab) 4.1097 + 4.1098 + if [ "$FS" = "swap" ]; then 4.1099 + fstab_add_line $FSTABTMP $DEVICE $MNT $FS $OPT 4.1100 + fi 4.1101 + 4.1102 + # If the partition has a valid filesystem, add it to fstab 4.1103 + if is_supported_filesystem "$FS"; then 4.1104 + fstab_add_line $FSTABTMP $DEVICE $MNT $FS $OPT 4.1105 + mkdir -p "$1/$MNT" 4.1106 + fi 4.1107 + done 4.1108 + 4.1109 + mv -f $FSTABTMP $FSTAB 4.1110 +} 4.1111 + 4.1112 +# create correct fstab file in $1/etc/fstab only with aufs,proc,sysfs and devpts 4.1113 +# No partition will be mounted and mount point created 4.1114 +# HAL is going to manage mount points and medias 4.1115 +fstab_clean() 4.1116 +{ 4.1117 + debug_log "fstab_update" "$*" 4.1118 + local FSTAB FSTABTMP 4.1119 + 4.1120 + FSTAB="$1/etc/fstab" 4.1121 + FSTABTMP=$FSTAB$$ 4.1122 + mkdir -p $1/etc $1/mnt 4.1123 + cat $FSTAB 2>/dev/null | grep -v "$FSTABLLFLAG" >$FSTABTMP 4.1124 + 4.1125 + fstab_add_line $FSTABTMP aufs / aufs defaults 4.1126 + fstab_add_line $FSTABTMP proc /proc proc defaults 4.1127 + fstab_add_line $FSTABTMP sysfs /sys sysfs defaults 4.1128 + fstab_add_line $FSTABTMP devpts /dev/pts devpts gid=5,mode=620 4.1129 + fstab_add_line $FSTABTMP tmpfs /dev/shm tmpfs defaults 4.1130 + mv -f $FSTABTMP $FSTAB 4.1131 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/initramfs/linuxrc Thu Nov 25 03:30:16 2010 +0000 5.3 @@ -0,0 +1,351 @@ 5.4 +#!/bin/ash 5.5 +# Initial script for Linux Live operating system 5.6 +# Author: Tomas M <http://www.linux-live.org/> 5.7 + 5.8 +export PATH=.:/:/usr/sbin:/usr/bin:/sbin:/bin 5.9 + 5.10 +mount -n -t proc proc /proc 5.11 +mount -n -t sysfs sysfs /sys 5.12 +#mount -n -o remount,rw / # for the case we forgot rw boot option 5.13 +ln -sf /proc/mounts /etc/mtab # this allows us to use umount -a 5.14 + 5.15 +. /liblinuxlive # it requires proc to be mounted 5.16 + 5.17 +# Don't print kernel messages to konsole now. 5.18 +# Syslog will reset printk settings, no need to remember it here anymore. 5.19 +echo "0" >/proc/sys/kernel/printk 5.20 + 5.21 +# Load essential drivers, like CDROM drivers, aufs/squashfs etc, 5.22 +# use mdev to create /dev/ devices and setup it as a hotplug-handler 5.23 +modprobe_essential_modules 5.24 + 5.25 +# /usr and some drivers are compressed in initrd 5.26 +# so it must be mounted from .lzm files 5.27 +#mount_initrd_loops 5.28 + 5.29 +# start hotplugging before hw drivers load 5.30 +#mdev_start_hotplug 5.31 + 5.32 +# Then load drivers for data storage and input devices 5.33 +modprobe_usb_modules 5.34 +modprobe_pcmcia_modules 5.35 + 5.36 +debug_shell 5.37 + 5.38 +# make sure ext3 partitions are not mounted using ext2 driver, 5.39 +# and vfat partitions are not mounted using msdos driver 5.40 +echo -e "ext4\next3\next2\nvfat\n*" >/etc/filesystems 5.41 + 5.42 +mkdir -p $UNION 5.43 +mkdir -p $MEMORY 5.44 + 5.45 +debug_shell 5.46 + 5.47 +# Find livecd data directory by searching for livecd.sgn file 5.48 +SGN=$(cmdline_value sgnfile) 5.49 +if [ "$SGN" = "" ]; then SGN=livecd.sgn; fi 5.50 +echolog "looking for '$LIVECDNAME' data directory (searching for $SGN file)" 5.51 + 5.52 +# First, try from= boot argument, if given 5.53 +DATAFROM=$(cmdline_value from) 5.54 + 5.55 +# Boot directly from iso 5.56 +FINDISOVAR=$(cmdline_value findiso) 5.57 + 5.58 +# If ip= parameter is present, assume we're booted over PXE 5.59 +# In that case, we have to initialize network very soon (now) 5.60 +# ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask> 5.61 +# Nevertheless, from= parameter won't be overwritten by this 5.62 +IP=$(cmdline_value ip) 5.63 +if [ "$IP" != "" -a "$DATAFROM" = "" ]; then 5.64 + DATAFROM="http://"$(echo $IP | cut -d : -f 2) 5.65 +fi 5.66 + 5.67 +if [ "$FINDISOVAR" != "" -a "$DATAFROM" = "" ]; then 5.68 + FINDISO=$(find_in_computer $FINDISOVAR) 5.69 + DATAFROM="$FINDISO" 5.70 + echolog "$FINDISO found." 5.71 +fi 5.72 + 5.73 +if [ "$DATAFROM" ]; then 5.74 + if [ "$(echo $DATAFROM | cut -b 1-7 | tr "[:upper:]" "[:lower:]")" = "http://" ]; then 5.75 + init_dhcp $(modprobe_network_modules) 5.76 + mount_httpfs $DATAFROM $MOUNTDIR/httpfs 5.77 + # if mountdir/httpfs/livecdname is found, set DATA=, else umount httpfs 5.78 + # - currently this part works even without the above mentioned, but livecd.sgn is required now untill it's uncommented 5.79 + elif [ "$FINDISO" ]; then 5.80 + mount_device $DATAFROM $FINDISOMNT 5.81 + echolog "$FINDISO mounted." 5.82 + else 5.83 + DATAFROM=$(find_in_computer $DATAFROM) 5.84 + if [ "$DATAFROM" ]; then 5.85 + mount_device $DATAFROM $LOOPMOUNT # mount again, it may be loop device 5.86 + if [ $? -eq 0 -a "$(find_modules $LOOPMOUNT/$LIVECDNAME)" != "" ]; then 5.87 + echolog "found in $DATAFROM" 5.88 + DATA=$LOOPMOUNT/$LIVECDNAME 5.89 + else 5.90 + fumount $LOOPMOUNT 5.91 + fumount $MOUNTDIR/* 5.92 + fi 5.93 + fi 5.94 + fi 5.95 +fi 5.96 + 5.97 +if [ "$DATA" = "" ]; then 5.98 + # from= is not used or it didn't contain valid data 5.99 + DATA=$(find_in_computer $LIVECDNAME/$SGN) 5.100 + DATA=$(dirname $DATA 2>/dev/null) 5.101 +fi 5.102 + 5.103 +if [ "$DATA" = "" ]; then fatal \ 5.104 +"$LIVECDNAME data not found. 5.105 +You are maybe using an unsupported boot device (eg. SCSI or old PCMCIA). 5.106 +Workaround: Copy the directory $LIVECDNAME from your boot device to an IDE/SATA 5.107 +disk, eg. to /mnt/hda1/$LIVECDNAME or C:\\$LIVECDNAME. Then try to boot again." 5.108 +fi 5.109 + 5.110 +echolog "Using $LIVECDNAME data from $DATA" 5.111 + 5.112 +debug_shell 5.113 + 5.114 +echolog "Setting up directory for changes ..." 5.115 +CHANGESVAL=$(cmdline_value changes) 5.116 + 5.117 +if [ "$CHANGESVAL" ]; then 5.118 + CHANGESMNT=$(find_in_computer $CHANGESVAL) 5.119 + echolog $CHANGESMNT 5.120 +fi 5.121 + 5.122 +debug_shell 5.123 + 5.124 +mount_device "$CHANGESMNT" $MEMORY # removes $MEMORY if CHANGESMNT is wrong 5.125 + 5.126 +# test if the filesystem is writable so changes can be stored to it 5.127 +touch $MEMORY/empty 2>/dev/null && \ 5.128 +rm -f $MEMORY/empty 2>/dev/null 5.129 + 5.130 +# if changes can't be mounted or the filesystem is not writable, 5.131 +# fallback to the default: tmpfs 5.132 +if [ $? -ne 0 ]; then 5.133 + echolog "Changes not used or not writable, using memory only" 5.134 + fumount $MEMORY 5.135 + mkdir -p $MEMORY # mount_device might removed it 5.136 + 5.137 + RAMSIZE=$(cmdline_value ramsize) 5.138 + if [ "$RAMSIZE" = "" ]; then RAMSIZE="60%"; fi 5.139 + mount -t tmpfs -o "size=$RAMSIZE" tmpfs $MEMORY 5.140 + XINO=$MEMORY 5.141 +else 5.142 + # So it is writable, we will keep the filesystem mounted. 5.143 + # Check if it supports links and chmod. 5.144 + # If not, overmount CHANGES using posixovl 5.145 + echolog "Testing the filesystem for posix compatibility ..." 5.146 + touch $MEMORY/.empty1 && \ 5.147 + ln -sf $MEMORY/.empty1 $MEMORY/.empty2 2>/dev/null && \ 5.148 + chmod +x $MEMORY/.empty1 2>/dev/null && \ 5.149 + test -x $MEMORY/.empty1 && \ 5.150 + chmod -x $MEMORY/.empty1 2>/dev/null && \ 5.151 + test ! -x $MEMORY/.empty1 && \ 5.152 + rm $MEMORY/.empty1 $MEMORY/.empty2 2>/dev/null 5.153 + 5.154 + if [ $? -ne 0 ]; then 5.155 + echolog "Not compatible - starting posixovl" 5.156 + rm $MEMORY/.empty1 $MEMORY/.empty2 2>/dev/null 5.157 + mkdir -p $CHANGES 5.158 + posixovl -F $CHANGES -- -o attr_timeout=300,entry_timeout=300,negative_timeout=300,kernel_cache,allow_other 5.159 + find $CHANGES >/dev/null 2>&1 # cache everything now 5.160 + fi 5.161 +fi 5.162 + 5.163 +# $UNION will be used as a root directory, livecd modules will be added soon 5.164 +echolog "Setup union directory (using aufs)" 5.165 + 5.166 +mkdir -p $CHANGES 5.167 +mkdir -p $IMAGES 5.168 +mount -n -t tmpfs tmpfs $IMAGES 5.169 + 5.170 +debug_shell 5.171 + 5.172 +# store the xino file in memory in all cases, it's faster and safer 5.173 +if [ "$XINO" != "$MEMORY" ]; then 5.174 + mkdir -p $XINO 5.175 + mount -n -t tmpfs tmpfs $XINO 5.176 +fi 5.177 + 5.178 +# mount aufs using the writable branch as the first one (leftmost/topmost) 5.179 +mount -t aufs -o nowarn_perm,xino=$XINO/.aufs.xino,br:$CHANGES=rw aufs $UNION 5.180 +if [ $? -ne 0 ]; then dmesg | tail -n 1; fatal "can't setup union (aufs)"; fi 5.181 + 5.182 +debug_shell 5.183 + 5.184 +# If toram or copy2ram boot parameter is present, copy all fs modules to RAM. 5.185 +# (skip modules from /optional/ which are not listed in load= boot option) 5.186 +# Finaly modify DATA variable so it will point to correct directory 5.187 +if [ "$(cmdline_parameter toram)" != "" -o "$(cmdline_parameter copy2ram)" != "" ]; then 5.188 + echolog "copying $LIVECDNAME data to RAM, this may take some time..." 5.189 + mkdir -p $COPY2RAM 5.190 + 5.191 + # make sure it's in RAM even with changes= parameter 5.192 + if [ "$CHANGESMNT" ]; then mount -t tmpfs -o "size=$RAMSIZE" tmpfs $COPY2RAM; fi 5.193 + copy_to_ram $DATA $COPY2RAM 5.194 + 5.195 + cd_autoeject 1 5.196 + fumount $DATA 5.197 + fumount $MOUNTDIR/* 5.198 + rmdir $MOUNTDIR/* 2>/dev/null # mounted device names are empty, remove them 5.199 + DATA=$COPY2RAM 5.200 + cd_autoeject 0 5.201 +fi 5.202 + 5.203 +debug_shell 5.204 + 5.205 +MODPATH=$(cmdline_value modpath) 5.206 +if [ "$MODPATH" != "" ]; then 5.207 + MODPATH=$(find_in_computer $MODPATH) 5.208 + if [ $FINDISOVAR ]; then 5.209 + mount_device $MODPATH $FINDISOMNT/$LIVECDNAME/tmp rbind 5.210 + else 5.211 + mount_device $MODPATH $DATA/tmp rbind 5.212 + fi 5.213 +fi 5.214 + 5.215 +debug_shell 5.216 + 5.217 +#if [ $(cmdline_parameter copy) ]; then 5.218 +# echolog "Copying initramfs to union. Please wait..." 5.219 +# # copy busybox to union 5.220 +# for i in $(ls -a /); do 5.221 +# case "$i" in 5.222 +# .|..) ;; 5.223 +# memory|union) ;; 5.224 +# mnt) mkdir -p $UNION/mnt ;; 5.225 +# sys) mkdir -p $UNION/sys ;; 5.226 +# proc) mkdir -p $UNION/proc ;; 5.227 +# dev) ;; 5.228 +# *) if ! cp -af /$i $UNION 2> /dev/null; then 5.229 +# debug_shell 5.230 +# fi ;; 5.231 +# esac 5.232 +# done 5.233 +#fi 5.234 + 5.235 +#debug_shell 5.236 + 5.237 +# DATA contains path to the base directory of all fs modules which need 5.238 +# to be mounted and inserted into live filesystem. Do it now. 5.239 +echolog "Loading modules:" 5.240 +union_insert_modules $UNION $DATA $IMAGES 5.241 + 5.242 +# the $MEMORY directory can contain $MEMORY/modules too 5.243 +# in the case if changes= boot argument is used. If not, it doesn't hurt 5.244 +union_insert_modules $UNION $MEMORY $IMAGES 5.245 + 5.246 +debug_shell 5.247 + 5.248 +ROOTCOPY=$(cmdline_value rootcopy) 5.249 +if [ $(cmdline_parameter norootcopy) ]; then 5.250 + echolog "Not using rootcopy" 5.251 +elif [ "$ROOTCOPY" ]; then 5.252 + echolog "Mounting content of rootcopy directory" 5.253 + ROOTCOPY=$(find_in_computer $ROOTCOPY) 5.254 + mount_device $ROOTCOPY $DATA/rootcopy rbind 5.255 + echolog "Copying content of rootcopy directory" 5.256 + cp -af $DATA/rootcopy/* $UNION 2>/dev/null # may be empty 5.257 +else 5.258 + echolog "Copying content of rootcopy directory" 5.259 + cp -af $DATA/rootcopy/* $UNION 2>/dev/null # may be empty 5.260 +fi 5.261 + 5.262 +# TODO: if copy2ram is used, there is no need to preserve the original in memory anymore 5.263 +#if [ "$DATA" = "$COPY2RAM" ]; then 5.264 +# rm from memory once ?? 5.265 +#fi 5.266 + 5.267 +echolog "Copying liblinuxlive library to union" 5.268 +cp -af /liblinuxlive $UNION/usr/lib/ 5.269 + 5.270 +debug_shell 5.271 + 5.272 +echolog "Recreating /etc/fstab and /mnt directories" 5.273 +touch $UNION/etc/fstab 5.274 +rmdir $UNION/mnt/* 2>/dev/null 5.275 +fstab_update $UNION 5.276 +#fstab_clean $UNION 5.277 + 5.278 +# everything is ready now, so we may unload unused kernel modules 5.279 +# and do some cleanup, unmount few things which are no longer needed. 5.280 +#rmmod_unused_modules 5.281 +#fumount /usr 5.282 +#fumount /sys 5.283 + 5.284 +# More likely these directories aren't there. 5.285 +# Even if they are, this won't hurt. 5.286 +mkdir -p $UNION/boot 5.287 +mkdir -p $UNION/proc 5.288 +mkdir -p $UNION/sys 5.289 +mkdir -p $UNION/dev 5.290 +mkdir -p $UNION/tmp 5.291 +chmod 1777 $UNION/tmp 5.292 + 5.293 +# Boot will contain whatever was in ./boot directory in the bootable media 5.294 +# Error output goes to null, as nothing is mounted with copy2ram 5.295 +#mount -n -o rbind $(dirname $DATA)/boot $UNION/boot 2>/dev/null 5.296 + 5.297 +# Union contains all the files and directories unioned from all modules. 5.298 +# Change root directory to it, and move initrd's root to /mnt/live/initramdisk 5.299 +# Finaly execute /sbin/init to start the distribution. 5.300 +echolog "changing root directory..." 5.301 + 5.302 +cd $UNION 5.303 +mkdir -p $INITRAMDISK 5.304 + 5.305 +# Copy all dev files (found by mdev) to unioned dev directory 5.306 +# so at least disk devices exist (your Linux may need them). 5.307 +# Two exceptions, do not copy pty* and tty* devs. 5.308 +if [ "$(cmdline_parameter nohotplug)" ]; then 5.309 + cp -fdR /dev . 2>/dev/null 5.310 +#else 5.311 + #mount -n -o move /dev dev 5.312 +fi 5.313 + 5.314 +#mount -n -o move /proc proc 5.315 +#mount -n -o move /sys sys 5.316 +fumount /sys 5.317 + 5.318 +if [ ! -e /dev/console ]; then mknod /dev/console c 5 1; fi 5.319 + 5.320 +# find chroot and init 5.321 +if [ -x bin/chroot ]; then CHROOT=bin/chroot; fi 5.322 +if [ -x sbin/chroot ]; then CHROOT=sbin/chroot; fi 5.323 +if [ -x usr/bin/chroot ]; then CHROOT=usr/bin/chroot; fi 5.324 +if [ -x usr/sbin/chroot ]; then CHROOT=usr/sbin/chroot; fi 5.325 +if [ "$CHROOT" = "" ]; then fatal "Can't find executable chroot command"; fi 5.326 + 5.327 +if [ -x bin/init ]; then INIT=bin/init; fi 5.328 +if [ -x sbin/init ]; then INIT=sbin/init; fi 5.329 +if [ "$INIT" = "" ]; then fatal "Can't find executable init command"; fi 5.330 + 5.331 +# time to end Linux Live scripts and start the distribution itself, 5.332 +# using /sbin/init or whatever was found. 5.333 + 5.334 +debug_shell 5.335 + 5.336 +fumount /proc 5.337 + 5.338 +mount -n -o remount,ro aufs . 5.339 + 5.340 +# We will copy init from the distro to initrd (there should be 2MB free) 5.341 +# This allows us to use the cleanup script during reboot, as init will be 5.342 +# started from memory and not from the union and /union will not be busy. 5.343 + 5.344 +cp -af $INIT /bin >/dev/null 2>&1 5.345 +if [ $? -eq 0 ]; then 5.346 + pivot_root . $INITRAMDISK 5.347 + exec $CHROOT . $INITRAMDISK/bin/init <dev/console >dev/console 2>&1 5.348 +else # If copying fails, start init directly. 5.349 + pivot_root . $INITRAMDISK 5.350 + exec $CHROOT . $INIT <dev/console >dev/console 2>&1 5.351 +fi 5.352 + 5.353 +header "!!ERROR!!" 5.354 +fatal "You are not supposed to be here, something went wrong!"
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/list/a.000.base.list Thu Nov 25 03:30:16 2010 +0000 6.3 @@ -0,0 +1,36 @@ 6.4 +busybox 6.5 +bzlib 6.6 +dialog 6.7 +dropbear 6.8 +e2fsprogs 6.9 +gcc-lib-base 6.10 +glibc-base 6.11 +gpxe 6.12 +grub4dos-linux 6.13 +isapnptools 6.14 +kbd-busybox 6.15 +libcap 6.16 +linux 6.17 +linux-drm 6.18 +linux-firmware 6.19 +lzlib 6.20 +lzma 6.21 +pcmciautils 6.22 +ppp 6.23 +rp-pppoe 6.24 +slitaz-base-files 6.25 +slitaz-boot-scripts 6.26 +slitaz-tools 6.27 +sysfsutils 6.28 +syslinux 6.29 +syslinux-extra 6.30 +tazlito 6.31 +tazpkg 6.32 +tazusb 6.33 +tazwok 6.34 +udev 6.35 +zlib 6.36 +ncurses-common 6.37 +aufs-utils 6.38 +squashfs 6.39 +htop 6.40 \ No newline at end of file
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/list/a.001.justx.list Thu Nov 25 03:30:16 2010 +0000 7.3 @@ -0,0 +1,96 @@ 7.4 +busybox 7.5 +bzlib 7.6 +cairo 7.7 +cdrkit 7.8 +dbus 7.9 +dbus-glib 7.10 +dialog 7.11 +dropbear 7.12 +e2fsprogs 7.13 +expat 7.14 +fontconfig 7.15 +freetype 7.16 +gcc-lib-base 7.17 +glib 7.18 +glibc-base 7.19 +gpxe 7.20 +grub4dos-linux 7.21 +hal 7.22 +isapnptools 7.23 +jpeg 7.24 +kbd-busybox 7.25 +libcap 7.26 +libcomerr 7.27 +libcrypto 7.28 +libgcrypt 7.29 +libgio 7.30 +libpng 7.31 +libxml2 7.32 +linux 7.33 +locale-de 7.34 +locale-es 7.35 +locale-fr 7.36 +locale-pt 7.37 +lzlib 7.38 +lzma 7.39 +nano 7.40 +ncurses 7.41 +openbox 7.42 +pango 7.43 +pciutils 7.44 +pcmciautils 7.45 +pcre 7.46 +pixman 7.47 +popt 7.48 +ppp 7.49 +rp-pppoe 7.50 +slim 7.51 +slitaz-base-files 7.52 +slitaz-boot-scripts 7.53 +slitaz-doc 7.54 +slitaz-polar-cursors 7.55 +slitaz-tools 7.56 +sqlite 7.57 +startup-notification 7.58 +sysfsutils 7.59 +syslinux 7.60 +syslinux-extra 7.61 +tazlito 7.62 +tazpkg 7.63 +tazusb 7.64 +tazwok 7.65 +tiff 7.66 +ttf-dejavu 7.67 +udev 7.68 +xorg-base-fonts 7.69 +xorg-libfontenc 7.70 +xorg-libICE 7.71 +xorg-libSM 7.72 +xorg-libX11 7.73 +xorg-libXau 7.74 +xorg-libXaw 7.75 +xorg-libXcomposite 7.76 +xorg-libXcursor 7.77 +xorg-libXdamage 7.78 +xorg-libXdmcp 7.79 +xorg-libXext 7.80 +xorg-libXfixes 7.81 +xorg-libXfont 7.82 +xorg-libXft 7.83 +xorg-libXi 7.84 +xorg-libXinerama 7.85 +xorg-libXmu 7.86 +xorg-libXpm 7.87 +xorg-libXrandr 7.88 +xorg-libXrender 7.89 +xorg-libXt 7.90 +xorg-libXtst 7.91 +xorg-rgb 7.92 +xorg-server 7.93 +xorg-setxkbmap 7.94 +xorg-xauth 7.95 +xorg-xf86-input-evdev 7.96 +xorg-xf86-video-vesa 7.97 +xorg-xsetroot 7.98 +xterm 7.99 +zlib
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/list/a.002.core-basic.list Thu Nov 25 03:30:16 2010 +0000 8.3 @@ -0,0 +1,151 @@ 8.4 +atk 8.5 +busybox 8.6 +bzlib 8.7 +cairo 8.8 +cdrkit 8.9 +clearlooks 8.10 +dbus 8.11 +dbus-glib 8.12 +dialog 8.13 +dropbear 8.14 +e2fsprogs 8.15 +expat 8.16 +fontconfig 8.17 +freetype 8.18 +gamin 8.19 +gcc-lib-base 8.20 +get-wifi-firmware 8.21 +glib 8.22 +glibc-base 8.23 +gpxe 8.24 +grub4dos-linux 8.25 +gtk+ 8.26 +gtkdialog 8.27 +hal 8.28 +hardinfo 8.29 +hicolor-icon-theme 8.30 +isapnptools 8.31 +jpeg 8.32 +kbd-busybox 8.33 +leafpad 8.34 +libcap 8.35 +libcomerr 8.36 +libgio 8.37 +libglade 8.38 +libpng 8.39 +libxml2 8.40 +linux 8.41 +linux-wireless 8.42 +linux-sound 8.43 +locale-de 8.44 +locale-es 8.45 +locale-fr 8.46 +locale-pt 8.47 +lxappearance 8.48 +lxpanel 8.49 +lxtask 8.50 +lzlib 8.51 +lzma 8.52 +nano 8.53 +nanochess 8.54 +ncurses 8.55 +ncursesw 8.56 +obconf 8.57 +openbox 8.58 +pango 8.59 +pciutils 8.60 +pcmanfm 8.61 +pcmciautils 8.62 +pcre 8.63 +pixman 8.64 +popt 8.65 +ppp 8.66 +rp-pppoe 8.67 +shared-mime-info 8.68 +slim 8.69 +slitaz-base-files 8.70 +slitaz-boot-scripts 8.71 +slitaz-configs 8.72 +slitaz-doc 8.73 +slitaz-icon 8.74 +slitaz-menus 8.75 +slitaz-polar-cursors 8.76 +slitaz-tools 8.77 +slitaz-tools-boxes 8.78 +sqlite 8.79 +startup-notification 8.80 +sysfsutils 8.81 +syslinux 8.82 +syslinux-extra 8.83 +tazlito 8.84 +tazpkg 8.85 +tazusb 8.86 +tazwikiss 8.87 +tazwok 8.88 +tiff 8.89 +transset-df 8.90 +ttf-dejavu 8.91 +udev 8.92 +xorg 8.93 +xorg-base-fonts 8.94 +xorg-libfontenc 8.95 +xorg-libICE 8.96 +xorg-libSM 8.97 +xorg-libX11 8.98 +xorg-libXau 8.99 +xorg-libXaw 8.100 +xorg-libXcomposite 8.101 +xorg-libXcursor 8.102 +xorg-libXdamage 8.103 +xorg-libXdmcp 8.104 +xorg-libXext 8.105 +xorg-libXfixes 8.106 +xorg-libXfont 8.107 +xorg-libXft 8.108 +xorg-libXi 8.109 +xorg-libXinerama 8.110 +xorg-libXmu 8.111 +xorg-libXpm 8.112 +xorg-libXrandr 8.113 +xorg-libXrender 8.114 +xorg-libXt 8.115 +xorg-libXtst 8.116 +xorg-rgb 8.117 +xorg-xauth 8.118 +xorg-xcompmgr 8.119 +xterm 8.120 +zlib 8.121 +libcrypto 8.122 +wireless_tools 8.123 +wpa_supplicant 8.124 +mtpaint 8.125 +libnotify 8.126 +transmission 8.127 +alsa-lib 8.128 +alsaplayer 8.129 +alsa-utils 8.130 +asunder 8.131 +galculator 8.132 +ntfs-3g 8.133 +ntfsprogs 8.134 +web-applications 8.135 +viewnior 8.136 +sudoku-savant 8.137 +desktop-file-utils 8.138 +xorg-server 8.139 +xorg-xf86-input-evdev 8.140 +xorg-xf86-video-vesa 8.141 +xorg-setxkbmap 8.142 +mhwaveedit 8.143 +isomaster 8.144 +gcolor2 8.145 +lostirc 8.146 +gparted 8.147 +beaver 8.148 +lua 8.149 +epdfview 8.150 +915resolution 8.151 +libunique 8.152 +libwebkit 8.153 +midori 8.154 +gettext-base
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/list/a.003.mesa.list Thu Nov 25 03:30:16 2010 +0000 9.3 @@ -0,0 +1,3 @@ 9.4 +mesa 9.5 +mesa-dri 9.6 +#mesa-demos 9.7 \ No newline at end of file
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/list/a.004.xorg-xf86-video.list Thu Nov 25 03:30:16 2010 +0000 10.3 @@ -0,0 +1,13 @@ 10.4 +xorg-xf86-video-ati 10.5 +xorg-xf86-video-i740 10.6 +xorg-xf86-video-intel 10.7 +#xorg-xf86-video-mga 10.8 +xorg-xf86-video-neomagic 10.9 +xorg-xf86-video-nv 10.10 +xorg-xf86-video-openchrome 10.11 +xorg-xf86-video-s3 10.12 +xorg-xf86-video-savage 10.13 +xorg-xf86-video-sis 10.14 +xorg-xf86-video-trident 10.15 +xorg-xf86-video-v4l 10.16 +xorg-xf86-video-vmware 10.17 \ No newline at end of file
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/list/a.005.firefox.list Thu Nov 25 03:30:16 2010 +0000 11.3 @@ -0,0 +1,1 @@ 11.4 +firefox 11.5 \ No newline at end of file
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/list/a.006.libs.list Thu Nov 25 03:30:16 2010 +0000 12.3 @@ -0,0 +1,37 @@ 12.4 +abiword 12.5 +gnumeric 12.6 +mplayer 12.7 +devede 12.8 +gtkpod 12.9 +pidgin 12.10 +uget 12.11 +geany 12.12 +deluge 12.13 +mixxx 12.14 +lmms 12.15 +hydrogen 12.16 +gimp 12.17 +gimp-plug-ins 12.18 +gimp-console 12.19 +inkscape 12.20 +xarchiver 12.21 +comix 12.22 +zsnes 12.23 +stella 12.24 +pcsxr-svn 12.25 +visualboyadvance-gtk 12.26 +virtualbox-ose 12.27 +vlc 12.28 +#libs-only 12.29 +python 12.30 +patch 12.31 +openssl 12.32 +openssh 12.33 +zip 12.34 +unzip 12.35 +bzip2 12.36 +xz 12.37 +libarchive 12.38 +get-rar 12.39 +perl 12.40 +get-flash-plugin 12.41 \ No newline at end of file
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/list/a.006.libs.removelist Thu Nov 25 03:30:16 2010 +0000 13.3 @@ -0,0 +1,24 @@ 13.4 +abiword 13.5 +gnumeric 13.6 +mplayer 13.7 +devede 13.8 +gtkpod 13.9 +pidgin 13.10 +uget 13.11 +geany 13.12 +deluge 13.13 +mixxx 13.14 +lmms 13.15 +hydrogen 13.16 +gimp 13.17 +gimp-plug-ins 13.18 +gimp-console 13.19 +inkscape 13.20 +xarchiver 13.21 +comix 13.22 +zsnes 13.23 +stella 13.24 +pcsxr-svn 13.25 +visualboyadvance-gtk 13.26 +virtualbox-ose 13.27 +vlc 13.28 \ No newline at end of file
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/list/a.007.apps.list Thu Nov 25 03:30:16 2010 +0000 14.3 @@ -0,0 +1,24 @@ 14.4 +abiword 14.5 +gnumeric 14.6 +mplayer 14.7 +devede 14.8 +gtkpod 14.9 +pidgin 14.10 +uget 14.11 +geany 14.12 +deluge 14.13 +mixxx 14.14 +lmms 14.15 +hydrogen 14.16 +gimp 14.17 +gimp-plug-ins 14.18 +gimp-console 14.19 +inkscape 14.20 +xarchiver 14.21 +comix 14.22 +zsnes 14.23 +stella 14.24 +pcsxr-svn 14.25 +visualboyadvance-gtk 14.26 +virtualbox-ose 14.27 +vlc 14.28 \ No newline at end of file
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/list/a.008.mercurial.list Thu Nov 25 03:30:16 2010 +0000 15.3 @@ -0,0 +1,1 @@ 15.4 +mercurial 15.5 \ No newline at end of file
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/list/a.009.pentest.list Thu Nov 25 03:30:16 2010 +0000 16.3 @@ -0,0 +1,16 @@ 16.4 +aircrack-ng 16.5 +airpwn 16.6 +airsnort 16.7 +aaphoto 16.8 +nmap 16.9 +snort 16.10 +nfs-utils 16.11 +wipe 16.12 +tor 16.13 +tinyproxy 16.14 +testdisk 16.15 +scanssh 16.16 +sshfs 16.17 +dd_rescue 16.18 +sleuthkit 16.19 +secure-delete 16.20 \ No newline at end of file
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/list/initramfs.list Thu Nov 25 03:30:16 2010 +0000 17.3 @@ -0,0 +1,31 @@ 17.4 +busybox 17.5 +bzlib 17.6 +dialog 17.7 +e2fsprogs 17.8 +gcc-lib-base 17.9 +glibc-base 17.10 +gpxe 17.11 +grub 17.12 +isapnptools 17.13 +kbd-busybox 17.14 +libcap 17.15 +libcomerr 17.16 +linux 17.17 +lzlib 17.18 +lzma 17.19 +ncurses 17.20 +pciutils 17.21 +pcmciautils 17.22 +slitaz-base-files 17.23 +slitaz-boot-scripts 17.24 +sysfsutils 17.25 +syslinux 17.26 +syslinux-extra 17.27 +udev 17.28 +zlib 17.29 +linux-squashfs 17.30 +aufs 17.31 +aufs-utils 17.32 +squashfs 17.33 +module-init-tools 17.34 +util-linux-ng-blkid 17.35 \ No newline at end of file
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/mkiso.sh Thu Nov 25 03:30:16 2010 +0000 18.3 @@ -0,0 +1,355 @@ 18.4 +#!/bin/sh 18.5 + 18.6 +if [ -f "./tazwok.conf" ]; then 18.7 + . ./tazwok.conf 18.8 +elif [ -f "/etc/tazwok.conf" ]; then 18.9 + . /etc/tazwok.conf 18.10 +else 18.11 + echo -e "\nUnable to find tazwok configuration file : /etc/tazwok.conf" 18.12 + exit 1 18.13 +fi 18.14 + 18.15 +QUIET="y" 18.16 +FORCE="y" 18.17 +export LABEL="slitaz_$(date +%Y%m)" 18.18 +PUBLISHER="Slitaz" 18.19 +APPLICATION="Slitaz" 18.20 +CREATE_DEFAULT="n" 18.21 +PROFILE="$(pwd)" 18.22 +ver="" 18.23 +CDNAME="slitaz" 18.24 +RMSTUFF=n 18.25 +MVSTUFF=n 18.26 +UNGZIP=n 18.27 +EXT="sqfs" 18.28 +COMPRESSION="gzip" 18.29 +MKOPTION="-b 256k" 18.30 +MODULES="" 18.31 +WORKING="$PROFILE/working" 18.32 +INITRAMFS="$WORKING/initramfs" 18.33 +UNION="$WORKING/union" 18.34 +LOG="$WORKING/log" 18.35 +ISODIR="$WORKING/iso" 18.36 +IMGNAME="$PROFILE/$CDNAME-$(date +%F).iso" 18.37 +IMGMD5NAME="$IMGNAME.md5" 18.38 +LASTBR="$WORKING/empty" 18.39 +SGNFILE="$ISODIR/$CDNAME/livecd.sgn" 18.40 +MODULES_DIR="$WORKING/modules" 18.41 +HG_DIR="$WORKING/hg" 18.42 +COPY_HG="no" 18.43 +UPDATE_HG="no" 18.44 +BACKUP_SOURCES="no" 18.45 +BACKUP_PACKAGES="no" 18.46 +CLEAN_MODULES_DIR="no" 18.47 +HG_LIST="flavors flavors-stable slitaz-base-files slitaz-boot-scripts slitaz-configs slitaz-doc slitaz-pizza slitaz-tools tank tazlito tazpkg tazusb tazwok website wok" 18.48 + 18.49 +error () { echo -e "\033[1;31;40m!!! \033[1;37;40m$@\033[1;0m"; } 18.50 +warn () { echo -e "\033[1;33;40m*** \033[1;37;40m$@\033[1;0m"; } 18.51 +info () { echo -e "\033[1;32;40m>>> \033[1;37;40m$@\033[1;0m"; } 18.52 + 18.53 +# do UID checking here so someone can at least get usage instructions 18.54 +#if [ "$EUID" != "0" ]; then 18.55 +# error "error: This script must be run as root." 18.56 +# exit 1 18.57 +#fi 18.58 + 18.59 +if [ -f ${PROFILE}/config ]; then 18.60 + source ${PROFILE}/config 18.61 +fi 18.62 + 18.63 +_overlay() 18.64 +{ 18.65 + if [ -d ${MODULES_DIR}/overlay ]; then 18.66 + rm -rf ${MODULES_DIR}/overlay 18.67 + cp -rf ${PROFILE}/overlay ${MODULES_DIR} 18.68 + else 18.69 + cp -rf ${PROFILE}/overlay ${MODULES_DIR} 18.70 + fi 18.71 + 18.72 + if [ "${QUIET}" = "y" ]; then 18.73 + mksquashfs "${MODULES_DIR}/overlay" "${ISODIR}/${CDNAME}/modules/zzz.overlay.${EXT}" -comp ${COMPRESSION} -noappend ${MKOPTION} >/dev/null 18.74 + else 18.75 + mksquashfs "${MODULES_DIR}/overlay" "${ISODIR}/${CDNAME}/modules/zzz.overlay.${EXT}" -comp ${COMPRESSION} -noappend ${MKOPTION} 18.76 + fi 18.77 +} 18.78 + 18.79 +lzma_switches() 18.80 +{ 18.81 + echo "-d$(echo 24) -mt$(grep ^processor < /proc/cpuinfo | wc -l)" 18.82 +} 18.83 + 18.84 +# Pack rootfs 18.85 +pack_rootfs() 18.86 +{ 18.87 + ( cd $1 ; find . -print | cpio -o -H newc ) | \ 18.88 + if [ -x /usr/bin/lzma ]; then 18.89 + info "Generating lzma'ed initramfs... " 18.90 + lzma e -si -so $(lzma_switches $1) > $2 18.91 + else 18.92 + info "Generating gziped initramfs... " 18.93 + gzip -9 > $2 18.94 + fi 18.95 + echo 1 > /tmp/rootfs 18.96 +} 18.97 + 18.98 +initramfs () { 18.99 + 18.100 + if [ ! -e "$PROFILE/list/initramfs.list" ]; then 18.101 + error "error: $PROFILE/list/initramfs.list doesn't exist, aborting." 18.102 + exit 1 18.103 + fi 18.104 + 18.105 + info "Making bootable image" 18.106 + cat "$PROFILE/list/initramfs.list" | grep -v "^#" | while read pkgname; do 18.107 + if [ ! -d ${INITRAMFS}/var/lib/tazpkg/installed/${pkgname} ]; then 18.108 + tazpkg get-install $pkgname --root=$INITRAMFS | tee -a $LOG/initramfs.log 18.109 + sleep 1 18.110 + else 18.111 + info "${pkgname} installed" 18.112 + fi 18.113 + done 18.114 + 18.115 + if [ ! -d $ISODIR/boot ]; then 18.116 + mkdir -p $ISODIR/boot 18.117 + fi 18.118 + 18.119 + if [ ! -f $ISODIR/boot/bzImage ]; then 18.120 + cp -f $INITRAMFS/boot/vmlinuz* $ISODIR/boot/bzImage 18.121 + rm -f $INITRAMFS/boot/vmlinuz* 18.122 + fi 18.123 + 18.124 + info "Copying isolinux files..." 18.125 + if [ -d $INITRAMFS/boot/isolinux ]; then 18.126 + cp -a $INITRAMFS/boot/isolinux $ISODIR/boot 18.127 + fi 18.128 + 18.129 + if [ -d $PROFILE/initramfs ]; then 18.130 + cp -af $PROFILE/initramfs/* $INITRAMFS 18.131 + fi 18.132 + 18.133 + info "Creating rootfs.gz" 18.134 + pack_rootfs $INITRAMFS $ISODIR/boot/rootfs.gz 18.135 +} 18.136 + 18.137 +copy_hg() { 18.138 + if [ ! -d ${HG_DIR}/hg-${1}/home/slitaz/hg/$1 ]; then 18.139 + info "Cloning $1 repo ..." 18.140 + hg clone http://hg.slitaz.org/$1 ${HG_DIR}/hg-${1}/home/slitaz/hg/$1 18.141 + elif [ -d ${HG_DIR}/hg-${1}/home/slitaz/hg/$1 -a ${UPDATE_HG} = "yes" ]; then 18.142 + info "Updating $1 repo ..." 18.143 + cd ${HG_DIR}/hg-${1}/home/slitaz/hg/$1 && 18.144 + hg pull && hg update 18.145 + cd $PROFILE 18.146 + fi 18.147 +} 18.148 + 18.149 +squashfs_hg() { 18.150 + if [ ! -d "$ISODIR/$CDNAME/modules/hg" ]; then 18.151 + mkdir -p "$ISODIR/$CDNAME/modules/hg" 18.152 + fi 18.153 + if [ -d ${HG_DIR}/hg-${1}/home/slitaz/hg/$1 ]; then 18.154 + _mksquash ${HG_DIR}/hg-${1} "$ISODIR/$CDNAME/modules/hg" /home/slitaz/hg/$1 18.155 + fi 18.156 +} 18.157 + 18.158 +slitaz_union () { 18.159 + 18.160 + if [ -d ${MODULES_DIR}/${mod}/var/lib/tazpkg/installed ]; then 18.161 + echo "${mod} module exist. Moving on." 18.162 + elif [ ! -d ${MODULES_DIR}/${mod}/var/lib/tazpkg/installed ]; then 18.163 + if [ -f "$PROFILE/list/${mod}.list" ]; then 18.164 + cat "$PROFILE/list/${mod}.list" | grep -v "^#" | while read pkgname; do 18.165 + if [ ! -d ${UNION}/var/lib/tazpkg/installed/${pkgname} ]; then 18.166 + tazpkg get-install $pkgname --root=${UNION} | tee -a ${LOG}/${mod}-current.log 18.167 + sleep 1 18.168 + else 18.169 + info "${pkgname} installed" 18.170 + fi 18.171 + done 18.172 + fi 18.173 + 18.174 + if [ -f $PROFILE/list/${mod}.removelist ]; then 18.175 + cat "$PROFILE/list/${mod}.removelist" | grep -v "^#" | while read pkgname; do 18.176 + if [ -d ${UNION}/var/lib/tazpkg/installed/${pkgname} ]; then 18.177 + echo "y" | tazpkg remove ${pkgname} --root=${UNION} | tee -a ${LOG}/${mod}-current.log 18.178 + sleep 1 18.179 + else 18.180 + info "${pkgname} removed" 18.181 + fi 18.182 + done 18.183 + fi 18.184 + fi 18.185 +} 18.186 + 18.187 +union () { 18.188 + mkdir -p $WORKING 18.189 + mkdir -p $UNION 18.190 + mkdir -p $LOG 18.191 + mkdir -p $INITRAMFS 18.192 + mkdir -p $ISODIR/${CDNAME}/base 18.193 + mkdir -p $ISODIR/${CDNAME}/modules 18.194 + mkdir -p $ISODIR/${CDNAME}/optional 18.195 + mkdir -p $ISODIR/${CDNAME}/rootcopy 18.196 + mkdir -p $ISODIR/${CDNAME}/tmp 18.197 + mkdir -p $LASTBR 18.198 + touch $SGNFILE 18.199 + 18.200 + modprobe aufs 18.201 + if [ $? -ne 0 ]; then 18.202 + error "Error loading Union filesystem module. (aufs)" 18.203 + exit 1 18.204 + fi 18.205 + 18.206 + mount -t aufs -o br:${LASTBR}=rw aufs ${UNION} 18.207 + if [ $? -ne 0 ]; then 18.208 + error "Error mounting $union." 18.209 + exit 1 18.210 + fi 18.211 + 18.212 + info "====> Installing packages to '$UNION'" 18.213 + for mod in $MODULES; do 18.214 + 18.215 + if [ "$CLEAN_MODULES_DIR" = "yes" ]; then 18.216 + if [ -d $MODULES_DIR/$mod ]; then 18.217 + rm -Rf $MODULES_DIR/$mod 18.218 + fi 18.219 + fi 18.220 + 18.221 + if [ ! -d $MODULES_DIR/$mod ]; then 18.222 + mkdir -p $MODULES_DIR/$mod 18.223 + fi 18.224 + info "Adding $MODULES_DIR/$mod as top branch of union." 18.225 + mount -t aufs -o remount,add:0:${MODULES_DIR}/${mod}=rw aufs $UNION 18.226 + info "Adding $LASTBR as lower branch of union." 18.227 + mount -t aufs -o remount,mod:${LASTBR}=rr+wh aufs $UNION 18.228 + LASTBR="$MODULES_DIR/${mod}" 18.229 + 18.230 + slitaz_union 18.231 + done 18.232 + 18.233 + info "Unmounting union" 18.234 + umount -l "${UNION}" 18.235 + 18.236 + info "Removing unionfs .wh. files." 18.237 + find ${MODULES_DIR} -type f -name ".wh.*" -exec rm {} \; 18.238 + find ${MODULES_DIR} -type d -name ".wh.*" -exec rm -rf {} \; 18.239 +} 18.240 + 18.241 + 18.242 +# _mksquash dirname 18.243 +_mksquash () { 18.244 + if [ ! -d "$1" ]; then 18.245 + error "Error: '$1' is not a directory" 18.246 + return 1 18.247 + fi 18.248 + 18.249 + if [ ! -d "$2" ]; then 18.250 + error "Error: '$2' is not a directory" 18.251 + return 1 18.252 + fi 18.253 + 18.254 + if [ ! -d "${1}${3}" ]; then 18.255 + error "Error: '${1}${3}' is not a directory" 18.256 + return 1 18.257 + fi 18.258 + 18.259 + time_dir="${3}" 18.260 + sqimg="${2}/$(basename ${1}).${EXT}" 18.261 + info "====> Generating SquashFS image for '${1}'" 18.262 + if [ -e "${sqimg}" ]; then 18.263 + dirhaschanged=$(find ${1}${time_dir} -newer ${sqimg}) 18.264 + if [ "${dirhaschanged}" != "" ]; then 18.265 + info "SquashFS image '${sqimg}' is not up to date, rebuilding..." 18.266 + rm "${sqimg}" 18.267 + else 18.268 + info "SquashFS image '${sqimg}' is up to date, skipping." 18.269 + return 18.270 + fi 18.271 + fi 18.272 + 18.273 + info "Creating SquashFS image. This may take some time..." 18.274 + start=$(date +%s) 18.275 + if [ "${QUIET}" = "y" ]; then 18.276 + mksquashfs "${1}" "${sqimg}" -noappend ${MKOPTION} -comp ${COMPRESSION} >/dev/null 18.277 + else 18.278 + mksquashfs "${1}" "${sqimg}" -noappend ${MKOPTION} -comp ${COMPRESSION} 18.279 + fi 18.280 + minutes=$(echo $start $(date +%s) | awk '{ printf "%0.2f",($2-$1)/60 }') 18.281 + info "Image creation done in $minutes minutes." 18.282 +} 18.283 + 18.284 +imgcommon () { 18.285 + if [ "${MODULES}" != "" ]; then 18.286 + for MOD in ${MODULES}; do 18.287 + if [ -d "${MODULES_DIR}/${MOD}" ]; then 18.288 + _mksquash "${MODULES_DIR}/${MOD}" "$ISODIR/$CDNAME/base" /var/lib/tazpkg/installed 18.289 + fi 18.290 + done 18.291 + fi 18.292 + 18.293 + if [ "$HG_LIST" != "" ]; then 18.294 + if [ "$COPY_HG" = "yes" ]; then 18.295 + for hg in $HG_LIST; do 18.296 + copy_hg $hg 18.297 + squashfs_hg $hg 18.298 + done 18.299 + fi 18.300 + fi 18.301 + 18.302 + if [ "${HG_LIST}" != "" ]; then 18.303 + for hg in ${HG_LIST}; do 18.304 + if [ -d "${MODULES_DIR}/hg-${hg}" ]; then 18.305 + squashfs_hg $hg 18.306 + fi 18.307 + done 18.308 + fi 18.309 + 18.310 + info "====> Making bootable image" 18.311 + 18.312 + # Sanity checks 18.313 + if [ ! -d "${ISODIR}" ]; then 18.314 + error "Error: '${ISODIR}' doesn't exist. What did you do?!" 18.315 + exit 1 18.316 + fi 18.317 + 18.318 + if [ ! -f "${SGNFILE}" ]; then 18.319 + error "Error: the ${SGNFILE} file doesn't exist. This image won't do anything" 18.320 + error " Protecting you from yourself and erroring out here..." 18.321 + exit 1 18.322 + fi 18.323 + 18.324 + 18.325 + if [ -e "${IMGNAME}" ]; then 18.326 + if [ "${FORCE}" = "y" ]; then 18.327 + info "Removing existing bootable image..." 18.328 + rm -rf "${IMGNAME}" 18.329 + else 18.330 + error "Error: Image '${IMGNAME}' already exists, aborting." 18.331 + exit 1 18.332 + fi 18.333 + fi 18.334 + 18.335 +} 18.336 + 18.337 +make_iso () { 18.338 + imgcommon 18.339 + initramfs 18.340 + 18.341 + if [ -d ${PROFILE}/overlay ]; then 18.342 + _overlay 18.343 + fi 18.344 + 18.345 + info "Creating ISO image..." 18.346 + genisoimage -R -o $IMGNAME -b boot/isolinux/isolinux.bin \ 18.347 + -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \ 18.348 + -V "SliTaz" -input-charset iso8859-1 -boot-info-table $ISODIR 18.349 + if [ -x /usr/bin/isohybrid ]; then 18.350 + info "Creating hybrid ISO..." 18.351 + isohybrid "${IMGNAME}" 18.352 + fi 18.353 + md5sum "${IMGNAME}" > $IMGMD5NAME 18.354 +} 18.355 + 18.356 + 18.357 +union 18.358 +make_iso
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/overlay/etc/fstab Thu Nov 25 03:30:16 2010 +0000 19.3 @@ -0,0 +1,9 @@ 19.4 +# /etc/fstab: Information about static filesystems. 19.5 +# 19.6 +proc /proc proc defaults 0 0 19.7 +sysfs /sys sysfs defaults 0 0 19.8 +devpts /dev/pts devpts defaults 0 0 19.9 +tmpfs /dev/shm tmpfs defaults 0 0 19.10 +tmpfs /tmp tmpfs defaults 0 0 19.11 +#/dev/hda3 /home ext3 defaults 0 2 19.12 +#/dev/hdb1 /mnt/data ext3 defaults 0 2
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 20.2 +++ b/overlay/usr/bin/tazpkg Thu Nov 25 03:30:16 2010 +0000 20.3 @@ -0,0 +1,2787 @@ 20.4 +#!/bin/sh 20.5 +# Tazpkg - Tiny autonomous zone packages manager. 20.6 +# 20.7 +# This is a lightwight packages manager for *.tazpkg files, all written in 20.8 +# SHell script. It works well with Busybox ash shell and bash. Tazpkg lets you 20.9 +# list, install, remove, download or get information about a package. You can 20.10 +# use 'tazpkg usage' to get a list of commands with short descriptions. Tazpkg 20.11 +# also resolves dependencies and can upgrade packages from a mirror. I18n is 20.12 +# done with gettext and eval_gettext, ex: 20.13 +# gettext "displayed text"; echo 20.14 +# eval_gettext "display \$VARIABLE"; echo 20.15 +# echo -e "BOLD `gettext \"i18n message\"`" 20.16 +# 20.17 +# (C) 2007-2010 SliTaz - GNU General Public License v3. 20.18 +# 20.19 +# Authors : Christophe Lincoln <pankso@slitaz.org> 20.20 +# Pascal Bellard <pascal.bellard@slitaz.org> 20.21 +# Eric Joseph-Alexandre <erjo@slitaz.org> 20.22 +# Paul Issott <paul@slitaz.org> 20.23 +# Rohit Joshi <jozee@slitaz.org> 20.24 +# 20.25 +VERSION=4.0 20.26 + 20.27 +#################### 20.28 +# Script variables # 20.29 +#################### 20.30 + 20.31 +. /etc/slitaz/tazpkg.conf 20.32 + 20.33 +# Include gettext helper script. 20.34 +. /usr/bin/gettext.sh 20.35 + 20.36 +# Export package name for gettext. 20.37 +TEXTDOMAIN='tazpkg' 20.38 +export TEXTDOMAIN 20.39 + 20.40 +# Initialize some variables to use words rather than numbers for functions 20.41 +# and actions. 20.42 +COMMAND=$1 20.43 +if [ -f "$2" ]; then 20.44 + # Set pkg basename for install, extract 20.45 + PACKAGE=$(basename ${2%.tazpkg} 2>/dev/null) 20.46 +else 20.47 + # Pkg name for remove, search and all other cmds 20.48 + PACKAGE=${2%.tazpkg} 20.49 +fi 20.50 +PACKAGE_FILE=$2 20.51 +TARGET_DIR=$3 20.52 +TOP_DIR=`pwd` 20.53 +INSTALL_LIST="" 20.54 + 20.55 +# Path to tazpkg used dir and configuration files 20.56 +INSTALLED=$LOCALSTATE/installed 20.57 +MIRROR=$LOCALSTATE/mirror 20.58 +BLOCKED=$LOCALSTATE/blocked-packages.list 20.59 +DEFAULT_MIRROR="http://mirror.slitaz.org/packages/`cat /etc/slitaz-release`/" 20.60 + 20.61 +# Check if the directories and files used by Tazpkg 20.62 +# exist. If not and user is root we create them. 20.63 +if test $(id -u) = 0 ; then 20.64 + if [ ! -d "$CACHE_DIR" ]; then 20.65 + mkdir -p $CACHE_DIR 20.66 + fi 20.67 + if [ ! -d "$INSTALLED" ]; then 20.68 + mkdir -p $INSTALLED 20.69 + fi 20.70 + if [ ! -f "$LOCALSTATE/mirror" ]; then 20.71 + echo "$DEFAULT_MIRROR" > $LOCALSTATE/mirror 20.72 + fi 20.73 +fi 20.74 + 20.75 +#################### 20.76 +# Script functions # 20.77 +#################### 20.78 + 20.79 +# Print the usage. 20.80 +usage () 20.81 +{ 20.82 + echo -e "SliTaz package manager - Version: $VERSION\n 20.83 +\033[1mUsage:\033[0m tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt] 20.84 + tazpkg shell\n 20.85 +\033[1mCommands: \033[0m 20.86 + usage Print this short usage. 20.87 + bugs Show known bugs in packages. 20.88 + list List installed packages on the system by category or all. 20.89 + xhtml-list Create a xHTML list of installed packages. 20.90 + list-mirror List all available packages on the mirror (--diff for new). 20.91 + info Print information about a package. 20.92 + desc Print description of a package (if it exists). 20.93 + list-files List the files installed with a package. 20.94 + list-config List the configuration files. 20.95 + search Search for a package by pattern or name (options: -i|-l|-m). 20.96 + search-pkgname Search on mirror for package having a particular file. 20.97 + search-file Search for file(s) in all installed packages files. 20.98 + install Install a local (*.tazpkg) package (--forced to force). 20.99 + install-list Install all packages from a list of packages. 20.100 + remove Remove the specified package and all installed files. 20.101 + extract Extract a (*.tazpkg) package into a directory. 20.102 + pack Pack an unpacked or prepared package tree. 20.103 + recharge Recharge your packages.list from the mirror. 20.104 + repack Create a package archive from an installed package. 20.105 + repack-config Create a package archive with configuration files. 20.106 + recompress Rebuild a package with the better compression ratio. 20.107 + upgrade Upgrade one or all installed/listed package(s) on the mirror. 20.108 + upgradeable Build upgradeable packages list quickly. 20.109 + block|unblock Block an installed package version or unblock it for upgrade. 20.110 + get Download a package into the current directory. 20.111 + get-install Download and install a package from the mirror. 20.112 + get-install-list Download and install a list of packages from the mirror. 20.113 + check Verify consistency of installed packages. 20.114 + add-flavor Install the flavor list of packages. 20.115 + install-flavor Install the flavor list of packages and remove other ones. 20.116 + set-release Change release and update packages. 20.117 + clean-cache Clean all packages downloaded in cache directory. 20.118 + depends Display dependencies tree. 20.119 + rdepends Display reverse dependencies tree. 20.120 + convert Convert a deb/rpm/tgz/arch package to a slitaz (.tazpkg). 20.121 + link Link a package from another slitaz installation. 20.122 + setup-mirror Change the mirror url configuration. 20.123 + list-undigest List undigest mirrors. 20.124 + remove-undigest Remove an undigest mirror. 20.125 + add-undigest Add an undigest mirror. 20.126 + setup-undigest Update an undigest mirror. 20.127 + reconfigure Replay post install script from package." 20.128 +} 20.129 + 20.130 +# Status function with color (supported by Ash). 20.131 +status() 20.132 +{ 20.133 + local CHECK=$? 20.134 + echo -en "\\033[70G[ " 20.135 + if [ $CHECK = 0 ]; then 20.136 + echo -en "\\033[1;33mOK" 20.137 + else 20.138 + echo -en "\\033[1;31mFailed" 20.139 + fi 20.140 + echo -e "\\033[0;39m ]" 20.141 + return $CHECK 20.142 +} 20.143 + 20.144 +# Check if user is root to install, or remove packages. 20.145 +check_root() 20.146 +{ 20.147 + if test $(id -u) != 0 ; then 20.148 + gettext \ 20.149 +"You must be root to run tazpkg with this option. Please use the command: 20.150 +su followed by the root password to become super-user."; echo 20.151 + echo "" && exit 0 20.152 + fi 20.153 +} 20.154 + 20.155 +# Check for a package name on cmdline. 20.156 +check_for_package_on_cmdline() 20.157 +{ 20.158 + if [ -z "$PACKAGE" ]; then 20.159 + echo "" 20.160 + gettext "Please specify a package name on the command line."; echo 20.161 + echo "" 20.162 + exit 0 20.163 + fi 20.164 +} 20.165 + 20.166 +# Check if the package (*.tazpkg) exist before installing or extracting. 20.167 +check_for_package_file() 20.168 +{ 20.169 + if [ ! -f "$PACKAGE_FILE" ]; then 20.170 + echo "" 20.171 + eval_gettext "Unable to find: \$PACKAGE_FILE"; echo 20.172 + echo "" && exit 0 20.173 + fi 20.174 +} 20.175 + 20.176 +# Check for the receipt of an installed package. 20.177 +check_for_receipt() 20.178 +{ 20.179 + if [ ! -f "$1$INSTALLED/$PACKAGE/receipt" ]; then 20.180 + FS=$1 20.181 + echo "" 20.182 + eval_gettext "Unable to find the receipt: \$FS\$INSTALLED/\$PACKAGE/receipt"; echo 20.183 + echo "" && exit 0 20.184 + fi 20.185 +} 20.186 + 20.187 +# Get package name in a directory 20.188 +package_fullname_in_dir() 20.189 +{ 20.190 + [ -f $2$1/receipt ] || return 20.191 + EXTRAVERSION="" 20.192 + . $2$1/receipt 20.193 + echo $PACKAGE-$VERSION$EXTRAVERSION 20.194 +} 20.195 + 20.196 +# Get package name that is already installed. 20.197 +get_installed_package_pathname() 20.198 +{ 20.199 + for i in $2$INSTALLED/${1%%-*}*; do 20.200 + [ -d $i ] || continue 20.201 + if [ "$1" = "$(package_fullname_in_dir $i $2)" ]; then 20.202 + echo $i 20.203 + return 20.204 + fi 20.205 + done 20.206 +} 20.207 + 20.208 +# Check if a package is already installed. 20.209 +check_for_installed_package() 20.210 +{ 20.211 + if [ -n "$(get_installed_package_pathname $PACKAGE $1)" ]; then 20.212 + echo "" 20.213 + eval_gettext "\$PACKAGE package is already installed. You can 20.214 +use the --forced option to force installation or remove it and reinstall."; echo 20.215 + echo "" && exit 0 20.216 + fi 20.217 +} 20.218 + 20.219 +# Check for packages.list to download and install packages. 20.220 +check_for_packages_list() 20.221 +{ 20.222 + if [ ! -f "$LOCALSTATE/packages.list" ]; then 20.223 + if test $(id -u) = 0 ; then 20.224 + tazpkg recharge 20.225 + else 20.226 + echo "" 20.227 + eval_gettext "Unable to find the list: \$LOCALSTATE/packages.list"; echo 20.228 + gettext \ 20.229 +"You must probably run 'tazpkg recharge' as root to get the latest list of 20.230 +packages available on the mirror."; echo 20.231 + echo "" && exit 0 20.232 + fi 20.233 + fi 20.234 +} 20.235 + 20.236 +# get an already installed package from packages.equiv 20.237 +equivalent_pkg() 20.238 +{ 20.239 + for i in $(grep -hs "^$1=" $LOCALSTATE/packages.equiv \ 20.240 + $LOCALSTATE/undigest/*/packages.equiv | sed "s/^$1=//"); do 20.241 + if echo $i | grep -q : ; then 20.242 + # format 'alternative:newname' 20.243 + # if alternative is installed then substitute newname 20.244 + if [ -f $2$INSTALLED/${i%:*}/receipt ]; then 20.245 + # substitute package dependancy 20.246 + echo ${i#*:} 20.247 + return 20.248 + fi 20.249 + else 20.250 + # if alternative is installed then nothing to install 20.251 + if [ -f $2$INSTALLED/$i/receipt ]; then 20.252 + # substitute installed package 20.253 + echo $i 20.254 + return 20.255 + fi 20.256 + fi 20.257 + done 20.258 + # if not found in packages.equiv then no substitution 20.259 + echo $1 20.260 +} 20.261 + 20.262 +# get a virtual package from packages.equiv 20.263 +virtual_pkg() 20.264 +{ 20.265 + for i in $(grep -hs "^$1=" $LOCALSTATE/packages.equiv \ 20.266 + $LOCALSTATE/undigest/*/packages.equiv | sed "s/^$1=//"); do 20.267 + if echo $i | grep -q : ; then 20.268 + # format 'alternative:newname' 20.269 + # if alternative is installed then substitute newname 20.270 + if [ -f $2$INSTALLED/${i%:*}/receipt ]; then 20.271 + # substitute package dependancy 20.272 + echo ${i#*:} 20.273 + return 20.274 + fi 20.275 + else 20.276 + # unconditional substitution 20.277 + echo $i 20.278 + return 20.279 + fi 20.280 + done 20.281 +} 20.282 + 20.283 +# Get package filename available on the mirror 20.284 +get_package_filename() 20.285 +{ 20.286 + local pkg 20.287 + pkg=$(grep -A 1 -sh "^$1$" $LOCALSTATE/packages.txt \ 20.288 + $LOCALSTATE/undigest/*/packages.txt | tail -1) 20.289 + pkg=$(echo $pkg) 20.290 + [ -n "$pkg" ] && pkg=$(grep -sh "^$1-$pkg" \ 20.291 + $LOCALSTATE/packages.list \ 20.292 + $LOCALSTATE/undigest/*/packages.list | head -1) 20.293 + [ -n "$pkg" ] || pkg=$(grep -sh "^$1-[0-9]" \ 20.294 + $LOCALSTATE/packages.list \ 20.295 + $LOCALSTATE/undigest/*/packages.list | head -1) 20.296 + [ -n "$pkg" ] || pkg=$(grep -sh "^$1-.[\.0-9]" \ 20.297 + $LOCALSTATE/packages.list \ 20.298 + $LOCALSTATE/undigest/*/packages.list | head -1) 20.299 + if [ -z "$pkg" ]; then 20.300 + # Check for vitual package 20.301 + local equiv 20.302 + equiv=$(virtual_pkg $1) 20.303 + if [ "$equiv" != "$1" ]; then 20.304 + PACKAGE=$equiv 20.305 + get_package_filename $PACKAGE 20.306 + return 20.307 + fi 20.308 + fi 20.309 + echo $pkg 20.310 +} 20.311 + 20.312 +# Check for a package in packages.list. Used by get and get-install to grep 20.313 +# package basename. 20.314 +check_for_package_in_list() 20.315 +{ 20.316 + local filename 20.317 + local check_only 20.318 + check_only="$1" 20.319 + filename=$(get_package_filename $PACKAGE) 20.320 + if [ -n "$filename" ]; then 20.321 + PACKAGE=$filename 20.322 + else 20.323 + echo "" 20.324 + eval_gettext "Unable to find: \$PACKAGE in the mirrored packages list."; echo 20.325 + echo "" 20.326 + [ -n "$check_only" ] && return 1 20.327 + exit 0 20.328 + fi 20.329 +} 20.330 + 20.331 +# Log this activity 20.332 +log() 20.333 +{ 20.334 + local extra 20.335 + [ "$1" = "Installed" ] && \ 20.336 + extra=" - $(grep $PACKAGE-$VERSION $LOCALSTATE/installed.md5 | awk '{ print $1 }')" 20.337 + [ -e $LOG ] || touch $LOG 20.338 + DATE=`date +'%F %T'` 20.339 + [ -w $LOG ] && 20.340 + echo "$DATE - $1 - $PACKAGE ($VERSION$EXTRAVERSION)$extra" >> $LOG 20.341 +} 20.342 + 20.343 +# Download a file from this mirror 20.344 +download_from() 20.345 +{ 20.346 + local i 20.347 + local mirrors 20.348 + mirrors="$1" 20.349 + shift 20.350 + for i in $mirrors; do 20.351 + case "$i" in 20.352 + http://*|ftp://*) wget -c $i$@ && break;; 20.353 + *) cp $i/$1 . && break;; 20.354 + esac 20.355 + done 20.356 +} 20.357 + 20.358 +# Download a file trying all mirrors 20.359 +download() 20.360 +{ 20.361 + local i 20.362 + case "$1" in 20.363 + *.tazpkg) 20.364 + for i in $LOCALSTATE $LOCALSTATE/undigest/* ; do 20.365 + grep "^${1%.tazpkg}$" $i/packages.list || continue 20.366 + download_from "$(cat $i/mirror)" "$@" && return 20.367 + done 20.368 + esac 20.369 + for i in $(cat $MIRROR $LOCALSTATE/undigest/*/mirror 2> /dev/null); do 20.370 + download_from "$i" "$@" && break 20.371 + done 20.372 +} 20.373 + 20.374 +# Extract a package with cpio and gzip/lzma. 20.375 +extract_package() 20.376 +{ 20.377 + gettext "Extracting $PACKAGE... " 20.378 + cpio -idm < $PACKAGE.tazpkg && rm -f $PACKAGE.tazpkg 20.379 + if [ -f fs.cpio.lzma ]; then 20.380 + gettext "Extracting the pseudo fs... " 20.381 + echo -n "(lzma) " 20.382 + unlzma -c fs.cpio.lzma | cpio -idm && rm fs.cpio.lzma 20.383 + elif [ -f fs.cpio.gz ]; then 20.384 + gettext "Extracting the pseudo fs... " 20.385 + zcat fs.cpio.gz | cpio -idm && rm fs.cpio.gz 20.386 + fi 20.387 +} 20.388 + 20.389 +remove_with_path() 20.390 +{ 20.391 + local dir 20.392 + rm -f $1 2>/dev/null 20.393 + dir="$1" 20.394 + while [ "$dir" != "/" ]; do 20.395 + dir="$(dirname $dir)" 20.396 + rmdir $dir 2> /dev/null || break 20.397 + done 20.398 +} 20.399 + 20.400 +grepesc() 20.401 +{ 20.402 + sed 's/\[/\\[/g' 20.403 +} 20.404 + 20.405 +# This function installs a package in the rootfs. 20.406 +install_package() 20.407 +{ 20.408 + ROOT=$1 20.409 + if [ -n "$ROOT" ]; then 20.410 + # Get absolute path 20.411 + ROOT=$(cd $ROOT; pwd) 20.412 + fi 20.413 + ( 20.414 + # Create package path early to avoid dependencies loop 20.415 + mkdir -p $TMP_DIR 20.416 + ( cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1) < $PACKAGE_FILE 20.417 + . $TMP_DIR/receipt 20.418 + if grep -q ^pre_depends $TMP_DIR/receipt; then 20.419 + pre_depends $ROOT 20.420 + fi 20.421 + # keep modifers and file list on upgrade 20.422 + cp $ROOT$INSTALLED/$PACKAGE/modifiers \ 20.423 + $ROOT$INSTALLED/$PACKAGE/files.list $TMP_DIR 2> /dev/null 20.424 + rm -rf $ROOT$INSTALLED/$PACKAGE 2> /dev/null 20.425 + # Make the installed package data dir to store 20.426 + # the receipt and the files list. 20.427 + mkdir -p $ROOT$INSTALLED/$PACKAGE 20.428 + cp $TMP_DIR/modifiers $ROOT$INSTALLED/$PACKAGE 2> /dev/null 20.429 + cp $TMP_DIR/files.list $ROOT$INSTALLED/$PACKAGE 2> /dev/null 20.430 + rm -rf $TMP_DIR 2> /dev/null 20.431 + sed -i "/ $(basename $PACKAGE_FILE)$/d" \ 20.432 + $ROOT$LOCALSTATE/installed.md5 2> /dev/null 20.433 + cd $(dirname $PACKAGE_FILE) 20.434 + md5sum $(basename $PACKAGE_FILE) >> $ROOT$LOCALSTATE/installed.md5 20.435 + ) 20.436 + # Resolve package deps. 20.437 + check_for_deps $ROOT 20.438 + if [ ! "$MISSING_PACKAGE" = "" ]; then 20.439 + install_deps $ROOT 20.440 + fi 20.441 + mkdir -p $TMP_DIR 20.442 + [ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> $INSTALL_LIST-processed 20.443 + echo "" 20.444 + echo -e "\033[1m`gettext \"Installation of :\"`\033[0m $PACKAGE" 20.445 + echo "================================================================================" 20.446 + eval_gettext "Copying \$PACKAGE... " 20.447 + cp $PACKAGE_FILE $TMP_DIR 20.448 + status 20.449 + cd $TMP_DIR 20.450 + extract_package 20.451 + SELF_INSTALL=0 20.452 + EXTRAVERSION="" 20.453 + CONFIG_FILES="" 20.454 + # Include temporary receipt to get the right variables. 20.455 + . $PWD/receipt 20.456 + cd $ROOT$INSTALLED 20.457 + if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then 20.458 + gettext "Checking post install dependencies... " 20.459 + [ -f $INSTALLED/$PACKAGE/receipt ] 20.460 + if ! status; then 20.461 + eval_gettext "Please run 'tazpkg install \$PACKAGE_FILE' in / and retry."; echo 20.462 + rm -rf $TMP_DIR 20.463 + exit 1 20.464 + fi 20.465 + fi 20.466 + # Get files to remove if upgrading 20.467 + if [ -f $PACKAGE/files.list ]; then 20.468 + while read file; do 20.469 + grep -q "^$(echo $file | grepesc)$" $TMP_DIR/files.list && continue 20.470 + for i in $(cat $PACKAGE/modifiers 2> /dev/null ; 20.471 + grep -sl $PACKAGE */modifiers | cut -d/ -f1 ); do 20.472 + grep -qs "^$(echo $file | grepesc)$" $i/files.list && continue 2 20.473 + done 20.474 + echo $file 20.475 + done < $PACKAGE/files.list > $TMP_DIR/files2remove.list 20.476 + fi 20.477 + # Remember modified packages 20.478 + { check=false 20.479 + for i in $(grep -v '\[' $TMP_DIR/files.list); do 20.480 + [ -e "$ROOT$i" ] || continue 20.481 + [ -d "$ROOT$i" ] && continue 20.482 + echo "- $i" 20.483 + check=true 20.484 + done ; 20.485 + $check && for i in *; do 20.486 + [ "$i" == "$PACKAGE" ] && continue 20.487 + [ -s $i/files.list ] || continue 20.488 + awk "{ printf \"$i %s\\n\",\$1 }" < $i/files.list 20.489 + done } | awk ' 20.490 +{ 20.491 + if ($1 == "-" || file[$2] != "") { 20.492 + file[$2] = file[$2] " " $1 20.493 + if ($1 != "-") { 20.494 + if (pkg[$1] == "") all = all " " $1 20.495 + pkg[$1] = pkg[$1] " " $2 20.496 + } 20.497 + } 20.498 +} 20.499 +END { 20.500 + for (i = split(all, p, " "); i > 0; i--) 20.501 + for (j = split(pkg[p[i]], f, " "); j > 0; j--) 20.502 + printf "%s %s\n",p[i],f[j]; 20.503 +} 20.504 + ' | while read dir file; do 20.505 + if grep -qs ^$dir$ $PACKAGE/modifiers; then 20.506 + # Do not overload an overloaded file ! 20.507 + rm $TMP_DIR$file 2> /dev/null 20.508 + continue 20.509 + fi 20.510 + grep -qs ^$PACKAGE$ $dir/modifiers && continue 20.511 + if [ -s "$dir/volatile.cpio.gz" ]; then 20.512 + # We can modify backed up files without notice 20.513 + zcat $dir/volatile.cpio.gz | cpio -t 2> /dev/null | \ 20.514 + grep -q "^${file#/}$" && continue 20.515 + fi 20.516 + echo "$PACKAGE" >> $dir/modifiers 20.517 + done 20.518 + 20.519 + cd $TMP_DIR 20.520 + cp receipt files.list $ROOT$INSTALLED/$PACKAGE 20.521 + # Copy the description if found. 20.522 + if [ -f "description.txt" ]; then 20.523 + cp description.txt $ROOT$INSTALLED/$PACKAGE 20.524 + fi 20.525 + # Copy the md5sum if found. 20.526 + if [ -f "md5sum" ]; then 20.527 + cp md5sum $ROOT$INSTALLED/$PACKAGE 20.528 + fi 20.529 + # Pre install commands. 20.530 + if grep -q ^pre_install $ROOT$INSTALLED/$PACKAGE/receipt; then 20.531 + pre_install $ROOT 20.532 + fi 20.533 + if [ -n "$CONFIG_FILES" ]; then 20.534 + # save 'official' configuration files 20.535 + eval_gettext "Saving configuration files for \$PACKAGE... " 20.536 + for i in $CONFIG_FILES; do 20.537 + ( cd fs ; find ${i#/} -type f ) 20.538 + done | ( cd fs ; cpio -o -H newc | gzip -9 ) > \ 20.539 + $ROOT$INSTALLED/$PACKAGE/volatile.cpio.gz 20.540 + # keep user configuration files 20.541 + for i in $CONFIG_FILES; do 20.542 + ( cd fs ; find ${i#/} -type f ) 20.543 + done | while read i; do 20.544 + [ -e $ROOT/$i ] || continue 20.545 + cp -a $ROOT/$i fs/$i 20.546 + done 20.547 + status 20.548 + fi 20.549 + eval_gettext "Installing \$PACKAGE... " 20.550 + cp -a fs/* $ROOT/ 20.551 + status 20.552 + if [ -s files2remove.list ]; then 20.553 + eval_gettext "Removing old \$PACKAGE... " 20.554 + while read file; do 20.555 + remove_with_path $ROOT$file 20.556 + done < files2remove.list 20.557 + true 20.558 + status 20.559 + fi 20.560 + # Remove the temporary random directory. 20.561 + gettext "Removing all tmp files... " 20.562 + cd .. && rm -rf $TMP_DIR 20.563 + status 20.564 + # Post install commands. 20.565 + if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then 20.566 + post_install $ROOT 20.567 + fi 20.568 + # Update-desktop-database if needed. 20.569 + if [ "$(grep .desktop $ROOT$INSTALLED/$PACKAGE/files.list | grep /usr/share/applications/)" ]; then 20.570 + updatedesktopdb=yes 20.571 + fi 20.572 + # Update-mime-database if needed. 20.573 + if [ "$(grep /usr/share/mime $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then 20.574 + updatemimedb=yes 20.575 + fi 20.576 + cd $TOP_DIR 20.577 + echo "================================================================================" 20.578 + eval_gettext "\$PACKAGE (\$VERSION\$EXTRAVERSION) is installed."; echo 20.579 + echo "" 20.580 + # Log this activity 20.581 + [ -n "$ROOT" ] || log Installed 20.582 +} 20.583 + 20.584 +# Check for loop in deps tree. 20.585 +check_for_deps_loop() 20.586 +{ 20.587 + local list 20.588 + local pkg 20.589 + local deps 20.590 + pkg=$1 20.591 + shift 20.592 + [ -n "$1" ] || return 20.593 + list="" 20.594 + # Filter out already processed deps 20.595 + for i in $@; do 20.596 + case " $ALL_DEPS" in 20.597 + *\ $i\ *);; 20.598 + *) list="$list $i";; 20.599 + esac 20.600 + done 20.601 + ALL_DEPS="$ALL_DEPS$list " 20.602 + for i in $list; do 20.603 + [ -f $i/receipt ] || continue 20.604 + deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)" 20.605 + case " $deps " in 20.606 + *\ $pkg\ *) echo -e "$MSG $i"; MSG="";; 20.607 + *) check_for_deps_loop $pkg $deps;; 20.608 + esac 20.609 + done 20.610 +} 20.611 + 20.612 +# Check for missing deps listed in a receipt packages. 20.613 +check_for_deps() 20.614 +{ 20.615 + local saved; 20.616 + saved=$PACKAGE 20.617 + mkdir -p $TMP_DIR 20.618 + ( cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1) < $PACKAGE_FILE 20.619 + . $TMP_DIR/receipt 20.620 + PACKAGE=$saved 20.621 + rm -rf $TMP_DIR 20.622 + for pkgorg in $DEPENDS 20.623 + do 20.624 + i=$(equivalent_pkg $pkgorg $1) 20.625 + if [ ! -d "$1$INSTALLED/$i" ]; then 20.626 + MISSING_PACKAGE=$i 20.627 + deps=$(($deps+1)) 20.628 + elif [ ! -f "$1$INSTALLED/$i/receipt" ]; then 20.629 + eval_gettext "WARNING Dependency loop between \$PACKAGE and \$i."; echo 20.630 + fi 20.631 + done 20.632 + if [ ! "$MISSING_PACKAGE" = "" ]; then 20.633 + echo -e "\033[1m`gettext \"Tracking dependencies for :\"`\033[0m $PACKAGE" 20.634 + echo "================================================================================" 20.635 + for pkgorg in $DEPENDS 20.636 + do 20.637 + i=$(equivalent_pkg $pkgorg $1) 20.638 + if [ ! -d "$1$INSTALLED/$i" ]; then 20.639 + MISSING_PACKAGE=$i 20.640 + eval_gettext "Missing: \$MISSING_PACKAGE"; echo 20.641 + fi 20.642 + done 20.643 + echo "================================================================================" 20.644 + eval_gettext "\$deps missing package(s) to install."; echo 20.645 + fi 20.646 +} 20.647 + 20.648 +# Install all missing deps. Auto install or ask user then install all missing 20.649 +# deps from local dir, cdrom, media or from the mirror. In case we want to 20.650 +# install packages from local, we need a packages.list to find the version. 20.651 +install_deps() 20.652 +{ 20.653 + local root 20.654 + root="" 20.655 + [ -n "$1" ] && root="--root=$1" 20.656 + if [ "$AUTO_INSTALL_DEPS" == "yes" ]; then 20.657 + anser="y" 20.658 + else 20.659 + echo "" 20.660 + gettext "Install all missing dependencies (y/N) ? "; read anser 20.661 + echo "" 20.662 + fi 20.663 + if [ "$anser" == "y" ]; then 20.664 + for pkgorg in $DEPENDS 20.665 + do 20.666 + pkg=$(equivalent_pkg $pkgorg $1) 20.667 + if [ ! -d "$1$INSTALLED/$pkg" ]; then 20.668 + local list 20.669 + list="$INSTALL_LIST" 20.670 + [ -n "$list" ] || list="$TOP_DIR/packages.list" 20.671 + # We can install packages from a local dir by greping 20.672 + # the TAZPKG_BASENAME in the local packages.list. 20.673 + found=0 20.674 + if [ -f "$list" ]; then 20.675 + eval_gettext "Checking if \$pkg exists in local list... "; echo 20.676 + mkdir $TMP_DIR 20.677 + for i in $pkg-*.tazpkg; do 20.678 + [ -f $i ] || continue 20.679 + ( cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1) < $i 20.680 + [ "$(. $TMP_DIR/receipt; echo $PACKAGE)" = "$pkg" ] || continue 20.681 + if grep -q ^$(package_fullname_in_dir $TMP_DIR).tazpkg$ $list 20.682 + then 20.683 + found=1 20.684 + tazpkg install $i $root --list=$list 20.685 + break 20.686 + fi 20.687 + done 20.688 + rm -rf $TMP_DIR 20.689 + fi 20.690 + # Install deps from the mirror. 20.691 + if [ $found -eq 0 ]; then 20.692 + if [ ! -f "$LOCALSTATE/packages.list" ]; then 20.693 + tazpkg recharge 20.694 + fi 20.695 + tazpkg get-install $pkg $root 20.696 + fi 20.697 + fi 20.698 + done 20.699 + else 20.700 + echo "" 20.701 + eval_gettext \ 20.702 +"Leaving dependencies for \$PACKAGE unsolved. The package is installed but 20.703 +will probably not work."; echo 20.704 + echo "" 20.705 + fi 20.706 +} 20.707 + 20.708 +# xHTML packages list header. 20.709 +xhtml_header() 20.710 +{ 20.711 + cat > $XHTML_LIST << _EOT_ 20.712 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 20.713 + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 20.714 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 20.715 +<head> 20.716 + <title>Installed packages list</title> 20.717 + <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> 20.718 + <meta name="modified" content="$DATE" /> 20.719 + <meta name="generator" content="Tazpkg" /> 20.720 + <style type="text/css"><!-- 20.721 + body { font: 12px sans-serif, vernada, arial; margin: 0; } 20.722 + #header { background: #f0ba08; color: black; height: 50px; 20.723 + border-top: 1px solid black; border-bottom: 1px solid black; } 20.724 + #content { margin: 0px 50px 26px 50px; } 20.725 + #footer { border-top: 1px solid black; padding-top: 10px;} 20.726 + h1 { margin: 14px 0px 0px 16px; } 20.727 + pre { padding-left: 5px; } 20.728 + hr { color: white; background: white; height: 1px; border: 0; } 20.729 + --></style> 20.730 +</head> 20.731 +<body bgcolor="#ffffff"> 20.732 +<div id="header"> 20.733 +<h1><font color="#3e1220">Installed packages list</font></h1> 20.734 +</div> 20.735 +<hr /> 20.736 +<!-- Start content --> 20.737 +<div id="content"> 20.738 + 20.739 +<p> 20.740 +_packages_ packages installed - List generated on : $DATE 20.741 +<p> 20.742 + 20.743 +_EOT_ 20.744 +} 20.745 + 20.746 +# xHTML content with packages info. 20.747 +xhtml_pkg_info() 20.748 +{ 20.749 + cat >> $XHTML_LIST << _EOT_ 20.750 +<h3>$PACKAGE</h3> 20.751 +<pre> 20.752 +Version : $VERSION$EXTRAVERSION 20.753 +Short desc : $SHORT_DESC 20.754 +Web site : <a href="$WEB_SITE">$WEB_SITE</a> 20.755 +</pre> 20.756 + 20.757 +_EOT_ 20.758 +} 20.759 + 20.760 +# xHTML packages list footer. 20.761 +xhtml_footer() 20.762 +{ 20.763 + cat >> $XHTML_LIST << _EOT_ 20.764 +<hr /> 20.765 +<p id="footer"> 20.766 +$packages packages installed - List generated on : $DATE 20.767 +</p> 20.768 + 20.769 +<!-- End content --> 20.770 +</div> 20.771 +</body> 20.772 +</html> 20.773 +_EOT_ 20.774 +} 20.775 + 20.776 +# Search pattern in installed packages. 20.777 +search_in_installed_packages() 20.778 +{ 20.779 + gettext "Installed packages"; echo 20.780 + echo "================================================================================" 20.781 + list=`ls -1 $INSTALLED | grep -i "$PATTERN"` 20.782 + for pkg in $list 20.783 + do 20.784 + EXTRAVERSION="" 20.785 + [ -f $INSTALLED/$pkg/receipt ] || continue 20.786 + . $INSTALLED/$pkg/receipt 20.787 + echo -n "$PACKAGE " 20.788 + echo -en "\033[24G $VERSION$EXTRAVERSION" 20.789 + echo -e "\033[42G $CATEGORY" 20.790 + packages=$(($packages+1)) 20.791 + done 20.792 + # Set correct ending messages. 20.793 + if [ "$packages" = "" ]; then 20.794 + eval_gettext "0 installed packages found for : \$PATTERN"; echo 20.795 + echo "" 20.796 + else 20.797 + echo "================================================================================" 20.798 + eval_gettext "\$packages installed package(s) found for : \$PATTERN"; echo 20.799 + echo "" 20.800 + fi 20.801 +} 20.802 + 20.803 +# Search in packages.list for available pkgs. 20.804 +search_in_packages_list() 20.805 +{ 20.806 + gettext "Available packages name-version"; echo 20.807 + echo "================================================================================" 20.808 + packages=0 20.809 + for i in $LOCALSTATE/packages.list $LOCALSTATE/undigest/*/packages.list; do 20.810 + grep -is "$PATTERN" $i 20.811 + packages=$(($packages + `grep -is "$PATTERN" $i | wc -l`)) 20.812 + done 20.813 + if [ ! -f "$LOCALSTATE/packages.list" ]; then 20.814 + echo "" 20.815 + gettext \ 20.816 +"No 'packages.list' found to check for mirrored packages. For more results, 20.817 +please run 'tazpkg recharge' once as root before searching."; echo 20.818 + echo "" 20.819 + fi 20.820 + if [ "$packages" = "0" ]; then 20.821 + eval_gettext "0 available packages found for : \$PATTERN"; echo 20.822 + echo "" 20.823 + else 20.824 + echo "================================================================================" 20.825 + eval_gettext "\$packages available package(s) found for : \$PATTERN"; echo 20.826 + echo "" 20.827 + fi 20.828 +} 20.829 + 20.830 +# search --mirror: Search in packages.txt for available pkgs and give more 20.831 +# info than --list or default. 20.832 +search_in_packages_txt() 20.833 +{ 20.834 + gettext "Matching packages name with version and desc"; echo 20.835 + echo "================================================================================" 20.836 + packages=0 20.837 + for i in $LOCALSTATE/packages.txt $LOCALSTATE/undigest/*/packages.txt; do 20.838 + grep -is -A 2 "^$PATTERN" $i 20.839 + packages=$(($packages + `grep -is "^$PATTERN" $i | wc -l`)) 20.840 + done 20.841 + if [ ! -f "$LOCALSTATE/packages.txt" ]; then 20.842 + echo "" 20.843 + gettext \ 20.844 +"No 'packages.txt' found to check for mirrored packages. For more results, 20.845 +please run 'tazpkg recharge' once as root before searching."; echo 20.846 + echo "" 20.847 + fi 20.848 + if [ "$packages" = "0" ]; then 20.849 + eval_gettext "0 available packages found for : \$PATTERN"; echo 20.850 + echo "" 20.851 + else 20.852 + echo "================================================================================" 20.853 + eval_gettext "\$packages available package(s) found for : \$PATTERN"; echo 20.854 + echo "" 20.855 + fi 20.856 +} 20.857 + 20.858 +# Install package-list from a flavor 20.859 +install_flavor() 20.860 +{ 20.861 + check_root 20.862 + FLAVOR=$1 20.863 + ARG=$2 20.864 + mkdir -p $TMP_DIR 20.865 + [ -f $FLAVOR.flavor ] && cp $FLAVOR.flavor $TMP_DIR 20.866 + cd $TMP_DIR 20.867 + if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then 20.868 + zcat $FLAVOR.flavor | cpio -i >/dev/null 20.869 + while read file; do 20.870 + for pkg in $(ls -d $INSTALLED/${file%%-*}*); do 20.871 + [ -f $pkg/receipt ] || continue 20.872 + EXTRAVERSION="" 20.873 + . $pkg/receipt 20.874 + [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && break 20.875 + done 20.876 + [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && continue 20.877 + cd $CACHE_DIR 20.878 + download $file.tazpkg 20.879 + cd $TMP_DIR 20.880 + tazpkg install $CACHE_DIR/$file.tazpkg --forced 20.881 + done < $FLAVOR.pkglist 20.882 + [ -f $FLAVOR.nonfree ] && while read pkg; do 20.883 + [ -d $INSTALLED/$pkg ] || continue 20.884 + [ -d $INSTALLED/get-$pkg ] && tazpkg get-install get-$pkg 20.885 + get-$pkg 20.886 + done < $FLAVOR.nonfree 20.887 + [ "$ARG" == "--purge" ] && for pkg in $(ls $INSTALLED); do 20.888 + [ -f $INSTALLED/$pkg/receipt ] || continue 20.889 + EXTRAVERSION="" 20.890 + . $INSTALLED/$pkg/receipt 20.891 + grep -q ^$PACKAGE-$VERSION$EXTRAVERSION$ $FLAVOR.pkglist && continue 20.892 + grep -qs ^$PACKAGE$ $FLAVOR.nonfree && continue 20.893 + tazpkg remove $PACKAGE 20.894 + done 20.895 + else 20.896 + eval_gettext "Can't find flavor \$FLAVOR. Aborting."; echo 20.897 + fi 20.898 + cd $TOP_DIR 20.899 + rm -rf $TMP_DIR 20.900 +} 20.901 + 20.902 +# Update mirror urls 20.903 +setup_mirror() 20.904 +{ 20.905 + # Backup old list. 20.906 + if [ -f "$1/mirror" ]; then 20.907 + cp -f $1/mirror $1/mirror.bak 20.908 + fi 20.909 + echo "" 20.910 + echo -e "\033[1m`gettext \"Current mirror(s)\"`\033[0m" 20.911 + echo "================================================================================" 20.912 + echo " `cat $1/mirror 2> /dev/null`" 20.913 + gettext \ 20.914 +"Please enter URL of the new mirror (http, ftp or local path). You must specify 20.915 +the complete address to the directory of the packages and packages.list file."; echo 20.916 + echo "" 20.917 + gettext "New mirror(s) URL : " 20.918 + NEW_MIRROR_URL=$2 20.919 + if [ -n "$NEW_MIRROR_URL" ]; then 20.920 + echo $NEW_MIRROR_URL 20.921 + else 20.922 + read NEW_MIRROR_URL 20.923 + fi 20.924 + if [ "$NEW_MIRROR_URL" = "" ]; then 20.925 + gettext "Nothing has been changed."; echo 20.926 + else 20.927 + eval_gettext "Setting mirror(s) to : $NEW_MIRROR_URL"; echo 20.928 + rm -f $1/mirror 20.929 + for i in $NEW_MIRROR_URL; do 20.930 + echo "$i" >> $1/mirror 20.931 + done 20.932 + fi 20.933 + echo "" 20.934 +} 20.935 + 20.936 +# recursive dependencies scan 20.937 +dep_scan() 20.938 +{ 20.939 +for i in $1; do 20.940 + case " $ALL_DEPS " in 20.941 + *\ $i\ *) continue;; 20.942 + esac 20.943 + ALL_DEPS="$ALL_DEPS $i" 20.944 + [ -n "$2" ] && echo "$2$i ($(grep -A 3 $i $LOCALSTATE/packages.txt \ 20.945 + | tail -1 | sed 's/.*(\([^ ]*\).*/\1/'))" 20.946 + [ -f $i/receipt ] || continue 20.947 + DEPENDS="" 20.948 + . $i/receipt 20.949 + [ -n "$DEPENDS" ] && dep_scan "$DEPENDS" "$2 " 20.950 +done 20.951 +} 20.952 + 20.953 +# recursive reverse dependencies scan 20.954 +rdep_scan() 20.955 +{ 20.956 +SEARCH=$1 20.957 + 20.958 +for i in * ; do 20.959 + DEPENDS="" 20.960 + . $i/receipt 20.961 + echo "$i $(echo $DEPENDS)" 20.962 +done | awk -v search=$SEARCH ' 20.963 +function show_deps(deps, all_deps, pkg, space) 20.964 +{ 20.965 + if (all_deps[pkg] == 1) return 20.966 + all_deps[pkg] = 1 20.967 + if (space != "") printf "%s %s\n",space,pkg 20.968 + for (i = 1, n = split(deps[pkg], mydeps, " "); i <= n; i++) { 20.969 + show_deps(deps, all_deps, mydeps[i],"==" space) 20.970 + } 20.971 +} 20.972 + 20.973 +{ 20.974 + all_deps[$1] = 0 20.975 + for (i = 2; i <= NF; i++) 20.976 + deps[$i] = deps[$i] " " $1 20.977 +} 20.978 + 20.979 +END { 20.980 + show_deps(deps, all_deps, search, "") 20.981 +} 20.982 +' | while read spc pkg; do 20.983 + echo -n $spc | sed 's/=/ /g' 20.984 + echo -n $pkg 20.985 + echo -n ' (' 20.986 + grep -A 3 $pkg $LOCALSTATE/packages.txt | tail -1 | \ 20.987 + sed 's/.*(\([^ ]*\).*/\1)/' 20.988 +done 20.989 +} 20.990 + 20.991 +# Check for ELF file 20.992 +is_elf() 20.993 +{ 20.994 + [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ] 20.995 +} 20.996 + 20.997 +# Print shared library dependencies 20.998 +ldd() 20.999 +{ 20.1000 + LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null 20.1001 +} 20.1002 + 20.1003 +# search dependencies for files in $TMP_DIR/$file/fs 20.1004 +find_depends() 20.1005 +{ 20.1006 + DEFAULT_DEPENDS="glibc-base gcc-lib-base" 20.1007 + 20.1008 + [ -f /var/lib/tazpkg/files.list.lzma ] || tazpkg recharge > /dev/null 20.1009 + for i in /var/lib/tazpkg/files.list.lzma \ 20.1010 + /var/lib/tazpkg/undigest/*/files.list.lzma ; do 20.1011 + [ -f $i ] && lzma d $i -so >> $TMP_DIR/files.list 20.1012 + done 20.1013 + find $TMP_DIR/$file/fs -type f | while read chkfile ; do 20.1014 + is_elf $chkfile || continue 20.1015 + case "$chkfile" in 20.1016 + *.o|*.ko|*.ko.gz) continue;; 20.1017 + esac 20.1018 + ldd $chkfile | while read lib rem; do 20.1019 + case "$lib" in 20.1020 + statically|linux-gate.so*|ld-*.so|*/ld-*.so) 20.1021 + continue;; 20.1022 + esac 20.1023 + find $TMP_DIR/$file/fs | grep -q /$lib$ && continue 20.1024 + for dep in $(grep $lib files.list | cut -d: -f1); do 20.1025 + case " $DEFAULT_DEPENDS " in 20.1026 + *\ $dep\ *) continue 2;; 20.1027 + esac 20.1028 + grep -qs "^$dep$" $TMP_DIR/depends && continue 2 20.1029 + done 20.1030 + if [ -n "$dep" ]; then 20.1031 + echo "$dep" >> $TMP_DIR/depends 20.1032 + else 20.1033 + grep -qs ^$lib$ $TMP_DIR/unresolved || 20.1034 + echo "$lib" >> $TMP_DIR/unresolved 20.1035 + fi 20.1036 + done 20.1037 + done 20.1038 + spc="" 20.1039 + cat $TMP_DIR/depends | sort | uniq | while read file; do 20.1040 + echo -n "$spc$file" 20.1041 + spc=" " 20.1042 + done 20.1043 +} 20.1044 + 20.1045 +show_unresolved_lib() 20.1046 +{ 20.1047 + if [ -s $TMP_DIR/unresolved ]; then 20.1048 + echo "BUGS=\"No dependency for" >> $1 20.1049 + cat $TMP_DIR/unresolved | sort | uniq | while read file; do 20.1050 + echo -e "$WARNING: unknown dependency for $lib" 20.1051 + echo -n " $file" >> $1 20.1052 + done 20.1053 + echo "\"" >> $1 20.1054 + fi 20.1055 +} 20.1056 + 20.1057 +# convert a .ipk package to .tazpkg 20.1058 +convert_ipk() 20.1059 +{ 20.1060 + mkdir -p $TMP_DIR 20.1061 + tar xOzf $PACKAGE_FILE ./control.tar.gz | tar xzf - -C $TMP_DIR 20.1062 + package="$(grep ^Package $TMP_DIR/control | sed 's/.*: //')" 20.1063 + version="$(grep ^Version $TMP_DIR/control | sed 's/.*: //')" 20.1064 + maintainer="$(grep ^Maintainer $TMP_DIR/control | sed 's/.*: //')" 20.1065 + target="$(grep ^Architecture $TMP_DIR/control | sed 's/.*: //')" 20.1066 + descrip="$(grep ^Description $TMP_DIR/control | sed 's/.*: //')" 20.1067 + url="http://openwrt.org/" 20.1068 + case "$target" in 20.1069 + i386|all) 20.1070 + file=$package-$version 20.1071 + mkdir -p $TMP_DIR/$file/fs 20.1072 + tar xOzf $PACKAGE_FILE ./data.tar.gz | \ 20.1073 + tar xzf - -C $TMP_DIR/$file/fs 20.1074 + cd $TMP_DIR 20.1075 + cat > $file/receipt <<EOT 20.1076 +# SliTaz package receipt. 20.1077 +# generated by tazpkg from package $(basename $PACKAGE_FILE) 20.1078 +PACKAGE="$package" 20.1079 +VERSION="$version" 20.1080 +CATEGORY="misc" 20.1081 +SHORT_DESC="$descrip" 20.1082 +WEB_SITE="$url" 20.1083 +MAINTAINER="$maintainer" 20.1084 +DEPENDS="$(find_depends)" 20.1085 +EOT 20.1086 + [ -s conffiles ] && cat >> $file/receipt <<EOT 20.1087 +CONFIG_FILES="$(cat conffiles)" 20.1088 +EOT 20.1089 + show_unresolved_lib $file/receipt 20.1090 + while read script func; do 20.1091 + [ -s $script ] && cat >> $file/receipt <<EOT 20.1092 + 20.1093 +$func() 20.1094 +{ 20.1095 +$(cat $script) 20.1096 +} 20.1097 +EOT 20.1098 + done <<EOT 20.1099 +preinst pre_install 20.1100 +postinst post_install 20.1101 +prerm pre_remove 20.1102 +postrm post_remove 20.1103 +EOT 20.1104 + awk ' 20.1105 +{ 20.1106 + if (/^ / && show) print substr($0,2); 20.1107 + else show=0; 20.1108 + if (/^Description/) show=1; 20.1109 +}' < $TMP_DIR/control > $file/description.txt 20.1110 + sed -i 's/^\.$//' $file/description.txt 20.1111 + [ -s $file/description.txt ] || rm -f $file/description.txt 20.1112 + tazpkg pack $file 20.1113 + cd $TOP_DIR 20.1114 + mv $TMP_DIR/$file.tazpkg . 20.1115 + ;; 20.1116 + *) 20.1117 + gettext "Invalid target: $target (expected i386)"; echo 20.1118 + ;; 20.1119 + esac 20.1120 + rm -rf $TMP_DIR 20.1121 +} 20.1122 + 20.1123 +# convert a .pkg.tar.gz package to .tazpkg 20.1124 +convert_arch() 20.1125 +{ 20.1126 + mkdir -p $TMP_DIR/fs 20.1127 + tar xzf $PACKAGE_FILE -C $TMP_DIR/fs 20.1128 + if [ -f $TMP_DIR/fs/.PKGINFO ]; then 20.1129 + cd $TMP_DIR 20.1130 + package="$(grep ^pkgname fs/.PKGINFO | sed 's/.*= //')" 20.1131 + version="$(grep ^pkgver fs/.PKGINFO | sed 's/.*= //')" 20.1132 + descrip="$(grep ^pkgdesc fs/.PKGINFO | sed 's/.*= //')" 20.1133 + url="$(grep ^url fs/.PKGINFO | sed 's/.*= //')" 20.1134 + maintainer="$(grep ^packager fs/.PKGINFO | sed 's/.*= //')" 20.1135 + file=$package-$version 20.1136 + mkdir $file 20.1137 + mv fs $file 20.1138 + cat > $file/receipt <<EOT 20.1139 +# SliTaz package receipt. 20.1140 +# generated by tazpkg from Archlinux package $(basename $PACKAGE_FILE) 20.1141 +PACKAGE="$package" 20.1142 +VERSION="$version" 20.1143 +CATEGORY="misc" 20.1144 +SHORT_DESC="$descrip" 20.1145 +WEB_SITE="$url" 20.1146 +MAINTAINER="$maintainer" 20.1147 +DEPENDS="$(find_depends)" 20.1148 +EOT 20.1149 + show_unresolved_lib $file/receipt 20.1150 + rm -f $file/fs/.[A-Z]* 20.1151 + tazpkg pack $file 20.1152 + mv $file.tazpkg $TOP_DIR 20.1153 + else 20.1154 + eval_gettext "\$PACKAGE_FILE does not look like a Archlinux package !"; echo 20.1155 + fi 20.1156 + cd $TOP_DIR 20.1157 + rm -rf $TMP_DIR 20.1158 +} 20.1159 + 20.1160 +# convert a .tgz package to .tazpkg 20.1161 +convert_tgz() 20.1162 +{ 20.1163 + package=$(basename $PACKAGE_FILE) 20.1164 + IFS='-' 20.1165 + set -- $package 20.1166 + unset IFS 20.1167 + package=$1 20.1168 + version=$2 20.1169 + file="$package-$version" 20.1170 + mkdir -p $TMP_DIR/$file/fs 20.1171 + tar xzf $PACKAGE_FILE -C $TMP_DIR/$file/fs 20.1172 + cd $TMP_DIR 20.1173 + if [ -d $file/fs/install ]; then 20.1174 + descrip=$(grep ^$package $file/fs/install/slack-desc | \ 20.1175 + head -1 | sed 's/.*(\(.*\)).*/\1/') 20.1176 + cat > $file/receipt <<EOT 20.1177 +# SliTaz package receipt. 20.1178 +# generated by tazpkg from slackware package $(basename $PACKAGE_FILE) 20.1179 +PACKAGE="$package" 20.1180 +VERSION="$version" 20.1181 +CATEGORY="misc" 20.1182 +SHORT_DESC="$descrip" 20.1183 +WEB_SITE="http://www.slackware.com/packages/" 20.1184 +MAINTAINER="nobody@slitaz.org" 20.1185 +DEPENDS="$(find_depends)" 20.1186 +EOT 20.1187 + show_unresolved_lib $file/receipt 20.1188 + [ -f $file/fs/install/doinst.sh ] && cat >> $file/receipt <<EOM 20.1189 + 20.1190 +post_install() 20.1191 +{ 20.1192 +chroot \$1/ sh - << EOT 20.1193 +cd / 20.1194 +$(cat $file/fs/install/doinst.sh | sed -e 's/\\/\\\\/g' | sed -e 's/\$/\\$/g') 20.1195 +EOT 20.1196 +} 20.1197 +EOM 20.1198 + grep ^$package $file/fs/install/slack-desc | \ 20.1199 + sed "s/^$package://" > $file/description.txt 20.1200 + [ -s $file/description.txt ] || rm -f $file/description.txt 20.1201 + rm -rf $file/fs/install 20.1202 + tazpkg pack $file 20.1203 + mv $file.tazpkg $TOP_DIR 20.1204 + else 20.1205 + eval_gettext "\$PACKAGE_FILE does not look like a Slackware package !"; echo 20.1206 + fi 20.1207 + cd $TOP_DIR 20.1208 + rm -rf $TMP_DIR 20.1209 +} 20.1210 + 20.1211 +# convert a .deb package to .tazpkg 20.1212 +convert_deb() 20.1213 +{ 20.1214 + mkdir -p $TMP_DIR 20.1215 + dpkg-deb -e $PACKAGE_FILE $TMP_DIR 20.1216 + package=$(grep '^ *Package' $TMP_DIR/control) 20.1217 + package=$(echo ${package##*:}) 20.1218 + version=$(grep '^ *Version' $TMP_DIR/control) 20.1219 + version=$(echo ${version##*:}) 20.1220 + descrip=$(grep '^ *Description' $TMP_DIR/control) 20.1221 + descrip=$(echo ${descrip##*:}) 20.1222 + target="$(grep ^Architecture $TMP_DIR/control | sed 's/.*: //')" 20.1223 + case "$target" in 20.1224 + i386|all) 20.1225 + file="$package-$version" 20.1226 + mkdir -p $TMP_DIR/$file/fs/ 20.1227 + dpkg-deb -x $PACKAGE_FILE $TMP_DIR/$file/fs 20.1228 + cd $TMP_DIR 20.1229 + cat > $file/receipt <<EOT 20.1230 +# SliTaz package receipt. 20.1231 +# generated by tazpkg from debian package $(basename $PACKAGE_FILE) 20.1232 +PACKAGE="$package" 20.1233 +VERSION="$version" 20.1234 +CATEGORY="misc" 20.1235 +SHORT_DESC="$descrip" 20.1236 +WEB_SITE="http://packages.debian.org/search?keywords=$package" 20.1237 +MAINTAINER="nobody@slitaz.org" 20.1238 +DEPENDS="$(find_depends)" 20.1239 +EOT 20.1240 + [ -s conffiles ] && cat >> $file/receipt <<EOT 20.1241 +CONFIG_FILES="$(cat conffiles)" 20.1242 +EOT 20.1243 + show_unresolved_lib $file/receipt 20.1244 + awk ' 20.1245 +{ 20.1246 + if (/^ / && show) print substr($0,2); 20.1247 + else show=0; 20.1248 + if (/^Description/) show=1; 20.1249 +}' < $TMP_DIR/control > $file/description.txt 20.1250 + sed -i 's/^\.$//' $file/description.txt 20.1251 + [ -s $file/description.txt ] || rm -f $file/description.txt 20.1252 + tazpkg pack $file 20.1253 + mv $file.tazpkg $TOP_DIR 20.1254 + ;; 20.1255 + *) 20.1256 + gettext "Invalid target: $target (expected i386)"; echo 20.1257 + ;; 20.1258 + esac 20.1259 + cd $TOP_DIR 20.1260 + rm -rf $TMP_DIR 20.1261 +} 20.1262 + 20.1263 +# convert a .rpm package to .tazpkg 20.1264 +convert_rpm() 20.1265 +{ 20.1266 + mkdir -p $TMP_DIR 20.1267 + cp $PACKAGE_FILE $TMP_DIR 20.1268 + PACKAGE_FILE=$TMP_DIR/$(basename $PACKAGE_FILE) 20.1269 + rpm -qip $PACKAGE_FILE | awk -v pkg=$(basename $PACKAGE_FILE) ' 20.1270 +BEGIN { 20.1271 + goturl=0; 20.1272 + printf "# Taz package receipt.\n"; 20.1273 + printf "# generated by tazpkg from rpm package %s\n",pkg; 20.1274 +} 20.1275 +{ 20.1276 + if (/^Name/) { name=$3; printf "PACKAGE=\"%s\"\n",$3; } 20.1277 + if (/^Version/) printf "VERSION=\"%s-",$3; 20.1278 + if (/^Release/) printf "%s\"\n",$3; 20.1279 + if (/^Summary/) printf "SHORT_DESC=\"%s\"\n",substr($0,15); 20.1280 + if (/^URL/) { goturl=1; printf "WEB_SITE=\"%s\"\n",$3; } 20.1281 +} 20.1282 +END { 20.1283 + if (goturl == 0) 20.1284 + printf "WEB_SITE=\"http://rpmfind.net/linux/rpm2html/search.php?query=%s\"\n",name; 20.1285 + printf "CATEGORY=\"misc\"\n"; 20.1286 + printf "MAINTAINER=\"nobody@slitaz.org\"\n"; 20.1287 +} 20.1288 +' > $TMP_DIR/receipt 20.1289 + . $TMP_DIR/receipt 20.1290 + file=$PACKAGE-$VERSION 20.1291 + mkdir -p $TMP_DIR/$file/fs/ 20.1292 + mv $TMP_DIR/receipt $TMP_DIR/$file 20.1293 + rpm -qip $PACKAGE_FILE | awk ' 20.1294 +DEGIN { show=0 } 20.1295 +{ 20.1296 + if (show) print; 20.1297 + if (/^Description/) show=1; 20.1298 +} 20.1299 +' > $TMP_DIR/$file/description.txt 20.1300 + cd $TMP_DIR/$file/fs/ 20.1301 + rpm2cpio $PACKAGE_FILE | cpio -idm 20.1302 + cd ../.. 20.1303 + echo "DEPENDS=\"$(find_depends)\"" >> $TMP_DIR/$file/receipt 20.1304 + show_unresolved_lib $TMP_DIR/$file/receipt 20.1305 + tazpkg pack $file 20.1306 + mv $file.tazpkg $TOP_DIR 20.1307 + cd $TOP_DIR 20.1308 + rm -rf $TMP_DIR 20.1309 +} 20.1310 + 20.1311 +update_desktop_database() 20.1312 +{ 20.1313 + if [ -f /usr/bin/update-desktop-database ] && [ -n "$updatedesktopdb" ]; then 20.1314 + update-desktop-database $1/usr/share/applications 20.1315 + fi 20.1316 +} 20.1317 + 20.1318 +update_mime_database() 20.1319 +{ 20.1320 + if [ -f /usr/bin/update-desktop-database ] && [ -n "$updatemimedb" ]; then 20.1321 + update-mime-database $1/usr/share/mime 20.1322 + fi 20.1323 +} 20.1324 + 20.1325 +################### 20.1326 +# Tazpkg commands # 20.1327 +################### 20.1328 + 20.1329 +case "$COMMAND" in 20.1330 + list) 20.1331 + # List all installed packages or a specific category. 20.1332 + # 20.1333 + if [ "$2" = "blocked" ]; then 20.1334 + echo "" 20.1335 + echo -e "\033[1m`gettext \"Blocked packages\"`\033[0m" 20.1336 + echo "================================================================================" 20.1337 + if [ -s "$BLOCKED" ];then 20.1338 + cat $BLOCKED 20.1339 + else 20.1340 + gettext "No blocked packages found." 20.1341 + fi 20.1342 + echo "" && exit 0 20.1343 + fi 20.1344 + # Display the list of categories. 20.1345 + if [ "$2" = "cat" -o "$2" = "categories" ]; then 20.1346 + echo "" 20.1347 + echo -e "\033[1m`gettext \"Packages categories\"`\033[0m" 20.1348 + echo "================================================================================" 20.1349 + for i in $CATEGORIES 20.1350 + do 20.1351 + echo $i 20.1352 + categories=$(($categories+1)) 20.1353 + done 20.1354 + echo "================================================================================" 20.1355 + echo "$categories categories" 20.1356 + echo "" 20.1357 + exit 0 20.1358 + fi 20.1359 + # Check for an asked category. 20.1360 + if [ -n "$2" ]; then 20.1361 + ASKED_CATEGORY=$2 20.1362 + echo "" 20.1363 + echo -e "\033[1m`gettext \"Installed packages of category:\"`\033[0m $ASKED_CATEGORY" 20.1364 + echo "================================================================================" 20.1365 + for pkg in $INSTALLED/* 20.1366 + do 20.1367 + [ -f $pkg/receipt ] || continue 20.1368 + EXTRAVERSION="" 20.1369 + . $pkg/receipt 20.1370 + if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then 20.1371 + echo -n "$PACKAGE" 20.1372 + echo -e "\033[24G $VERSION$EXTRAVERSION" 20.1373 + packages=$(($packages+1)) 20.1374 + fi 20.1375 + done 20.1376 + echo "================================================================================" 20.1377 + eval_gettext "\$packages packages installed of category \$ASKED_CATEGORY."; echo 20.1378 + echo "" 20.1379 + else 20.1380 + # By default list all packages and versions. 20.1381 + echo "" 20.1382 + echo -e "\033[1m`gettext \"List of all installed packages\"`\033[0m" 20.1383 + echo "================================================================================" 20.1384 + for pkg in $INSTALLED/* 20.1385 + do 20.1386 + [ -f $pkg/receipt ] || continue 20.1387 + EXTRAVERSION="" 20.1388 + . $pkg/receipt 20.1389 + echo -n "$PACKAGE" 20.1390 + echo -en "\033[24G $VERSION$EXTRAVERSION" 20.1391 + echo -e "\033[42G $CATEGORY" 20.1392 + packages=$(($packages+1)) 20.1393 + done 20.1394 + echo "================================================================================" 20.1395 + eval_gettext "\$packages packages installed."; echo 20.1396 + echo "" 20.1397 + fi ;; 20.1398 + xhtml-list) 20.1399 + # Get info in receipts and build list. 20.1400 + DATE=`date +%Y-%m-%d\ \%H:%M:%S` 20.1401 + if [ -n "$2" ]; then 20.1402 + XHTML_LIST=$2 20.1403 + else 20.1404 + XHTML_LIST=installed-packages.html 20.1405 + fi 20.1406 + echo "" 20.1407 + echo -e "\033[1m`gettext \"Creating xHTML list of installed packages\"`\033[0m" 20.1408 + echo "================================================================================" 20.1409 + gettext "Generating xHTML header..." 20.1410 + xhtml_header 20.1411 + status 20.1412 + # Packages 20.1413 + gettext "Creating packages information..." 20.1414 + for pkg in $INSTALLED/* 20.1415 + do 20.1416 + [ -f $pkg/receipt ] || continue 20.1417 + EXTRAVERSION="" 20.1418 + . $pkg/receipt 20.1419 + xhtml_pkg_info 20.1420 + packages=$(($packages+1)) 20.1421 + done 20.1422 + status 20.1423 + gettext "Generating xHTML footer..." 20.1424 + xhtml_footer 20.1425 + status 20.1426 + # sed pkgs nb in header. 20.1427 + sed -i s/'_packages_'/"$packages"/ $XHTML_LIST 20.1428 + echo "================================================================================" 20.1429 + eval_gettext "\$XHTML_LIST created - $packages packages."; echo 20.1430 + echo "" ;; 20.1431 + list-mirror) 20.1432 + # List all available packages on the mirror. Option --diff displays 20.1433 + # last mirrored packages diff (see recharge). 20.1434 + check_for_packages_list 20.1435 + case $2 in 20.1436 + --diff) 20.1437 + if [ -f "$LOCALSTATE/packages.diff" ]; then 20.1438 + echo "" 20.1439 + echo -e "\033[1m`gettext \"Mirrored packages diff\"`\033[0m" 20.1440 + echo "================================================================================" 20.1441 + cat $LOCALSTATE/packages.diff 20.1442 + echo "================================================================================" 20.1443 + pkgs=`cat $LOCALSTATE/packages.diff | wc -l` 20.1444 + eval_gettext "\$pkgs new packages listed on the mirror."; echo 20.1445 + echo "" 20.1446 + else 20.1447 + echo "" 20.1448 + gettext "Unable to list anything, no packages.diff found."; echo 20.1449 + gettext "Recharge your current list to create a first diff."; echo 20.1450 + echo "" 20.1451 + fi && exit 0 ;; 20.1452 + --text|--txt) 20.1453 + echo "" 20.1454 + echo -e "\033[1m`gettext \"List of available packages on the mirror\"`\033[0m" 20.1455 + echo "================================================================================" 20.1456 + cat $LOCALSTATE/packages.txt ;; 20.1457 + --raw|*) 20.1458 + echo "" 20.1459 + echo -e "\033[1m`gettext \"List of available packages on the mirror\"`\033[0m" 20.1460 + echo "================================================================================" 20.1461 + cat $LOCALSTATE/packages.list ;; 20.1462 + esac 20.1463 + echo "================================================================================" 20.1464 + pkgs=`cat $LOCALSTATE/packages.list | wc -l` 20.1465 + eval_gettext "\$pkgs packages in the last recharged list."; echo 20.1466 + echo "" ;; 20.1467 + list-files) 20.1468 + # List files installed with the package. 20.1469 + # 20.1470 + check_for_package_on_cmdline 20.1471 + check_for_receipt 20.1472 + echo "" 20.1473 + echo -e "\033[1m`gettext \"Installed files with:\"`\033[0m $PACKAGE" 20.1474 + echo "================================================================================" 20.1475 + cat $INSTALLED/$PACKAGE/files.list | sort 20.1476 + echo "================================================================================" 20.1477 + files=`cat $INSTALLED/$PACKAGE/files.list | wc -l` 20.1478 + echo "$files files installed with $PACKAGE." 20.1479 + echo "" ;; 20.1480 + info) 20.1481 + # Information about package. 20.1482 + # 20.1483 + check_for_package_on_cmdline 20.1484 + check_for_receipt 20.1485 + EXTRAVERSION="" 20.1486 + . $INSTALLED/$PACKAGE/receipt 20.1487 + echo "" 20.1488 + echo -e "\033[1m`gettext \"Tazpkg information\"`\033[0m 20.1489 +================================================================================ 20.1490 +Package : $PACKAGE 20.1491 +Version : $VERSION$EXTRAVERSION 20.1492 +Category : $CATEGORY 20.1493 +Short desc : $SHORT_DESC 20.1494 +Maintainer : $MAINTAINER" 20.1495 + if [ ! "$DEPENDS" = "" ]; then 20.1496 + echo -e "Depends : $DEPENDS" 20.1497 + fi 20.1498 + if [ ! "$SUGGESTED" = "" ]; then 20.1499 + echo -e "Suggested : $SUGGESTED" 20.1500 + fi 20.1501 + if [ ! "$BUILD_DEPENDS" = "" ]; then 20.1502 + echo -e "Build deps : $BUILD_DEPENDS" 20.1503 + fi 20.1504 + if [ ! "$WANTED" = "" ]; then 20.1505 + echo -e "Wanted src : $WANTED" 20.1506 + fi 20.1507 + if [ ! "$WEB_SITE" = "" ]; then 20.1508 + echo -e "Web site : $WEB_SITE" 20.1509 + fi 20.1510 + echo "================================================================================" 20.1511 + echo "" ;; 20.1512 + desc) 20.1513 + # Display package description.txt if available. 20.1514 + if [ -f "$INSTALLED/$PACKAGE/description.txt" ]; then 20.1515 + echo "" 20.1516 + echo -e "\033[1m`gettext \"Description of:\"`\033[0m $PACKAGE" 20.1517 + echo "================================================================================" 20.1518 + cat $INSTALLED/$PACKAGE/description.txt 20.1519 + echo "================================================================================" 20.1520 + echo "" 20.1521 + else 20.1522 + echo "" 20.1523 + gettext "Sorry, no description available for this package."; echo 20.1524 + echo "" 20.1525 + fi ;; 20.1526 + search) 20.1527 + # Search for a package by pattern or name. 20.1528 + # 20.1529 + PATTERN="$2" 20.1530 + if [ -z "$PATTERN" ]; then 20.1531 + echo "" 20.1532 + gettext "Please specify a pattern or package name to search for."; echo 20.1533 + gettext "Example : 'tazpkg search paint'"; echo 20.1534 + echo "" 20.1535 + exit 0 20.1536 + fi 20.1537 + echo "" 20.1538 + echo -e "\033[1m`gettext \"Search result for:\"`\033[0m $PATTERN" 20.1539 + echo "" 20.1540 + # Default is to search in installed pkgs and the raw list. 20.1541 + case $3 in 20.1542 + -i|--installed) 20.1543 + search_in_installed_packages ;; 20.1544 + -l|--list) 20.1545 + search_in_packages_list ;; 20.1546 + -m|--mirror) 20.1547 + search_in_packages_txt ;; 20.1548 + *) 20.1549 + search_in_installed_packages 20.1550 + search_in_packages_list ;; 20.1551 + esac ;; 20.1552 + search-file) 20.1553 + # Search for a file by pattern or name in all files.list. 20.1554 + # 20.1555 + if [ -z "$2" ]; then 20.1556 + echo "" 20.1557 + gettext "Please specify a pattern or file name to search for."; echo 20.1558 + gettext "Example : 'tazpkg search-file libnss'"; echo 20.1559 + echo "" 20.1560 + exit 0 20.1561 + fi 20.1562 + echo "" 20.1563 + echo -e "\033[1m`gettext \"Search result for file\"`\033[0m $2" 20.1564 + echo "================================================================================" 20.1565 + 20.1566 + if [ "$3" == "--mirror" ]; then 20.1567 + 20.1568 + match=0 20.1569 + for i in $LOCALSTATE/files.list.lzma \ 20.1570 + $LOCALSTATE/undigest/*/files.list.lzma; do 20.1571 + [ -f $i ] || continue 20.1572 + unlzma -c $i | grep -- ".*:.*$2" | awk ' 20.1573 + BEGIN { last="" } 20.1574 + { 20.1575 + pkg=substr($0,0,index($0,":")-1); 20.1576 + file=substr($0,index($0,":")+2); 20.1577 + if (last != pkg) { 20.1578 + last = pkg; 20.1579 + printf("\n%c[1mPackage %s :%c[0m\n",27,pkg,27); 20.1580 + } 20.1581 + printf("%s\n",file); 20.1582 + }' 20.1583 + match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | wc -l`)) 20.1584 + done 20.1585 + 20.1586 + else 20.1587 + 20.1588 + # Check all pkg files.list in search match with specify the package 20.1589 + # name and the full path to the file(s). 20.1590 + for pkg in $INSTALLED/* 20.1591 + do 20.1592 + if grep -qs "$2" $pkg/files.list; then 20.1593 + . $pkg/receipt 20.1594 + echo "" 20.1595 + echo -e "\033[1m`gettext \"Package\"` $PACKAGE:\033[0m" 20.1596 + grep "$2" $pkg/files.list 20.1597 + files=`grep $2 $pkg/files.list | wc -l` 20.1598 + match=$(($match+$files)) 20.1599 + fi 20.1600 + done 20.1601 + 20.1602 + fi 20.1603 + pkg=$2 20.1604 + if [ "$match" = "" ]; then 20.1605 + eval_gettext "0 file found for: \$pkg"; echo 20.1606 + echo "" 20.1607 + else 20.1608 + echo "" 20.1609 + echo "================================================================================" 20.1610 + eval_gettext "\$match file(s) found for: \$pkg"; echo 20.1611 + echo "" 20.1612 + fi ;; 20.1613 + search-pkgname) 20.1614 + # Search for a package name 20.1615 + if [ -z "$2" ]; then 20.1616 + echo "" 20.1617 + gettext "Please specify a pattern or file name to search for."; echo 20.1618 + gettext "Example : 'tazpkg search-pkgname libnss'"; echo 20.1619 + echo "" 20.1620 + exit 0 20.1621 + fi 20.1622 + echo "" 20.1623 + echo -e "\033[1m`gettext \"Search result for file\"`\033[0m $2" 20.1624 + echo "================================================================================" 20.1625 + 20.1626 + # Search for a file on mirror and output only the package name 20.1627 + match=0 20.1628 + for i in $LOCALSTATE/files.list.lzma \ 20.1629 + $LOCALSTATE/undigest/*/files.list.lzma; do 20.1630 + [ -f $i ] || continue 20.1631 + unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | awk '{ print $1 }' 20.1632 + match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | wc -l`)) 20.1633 + done 20.1634 + file=$2 20.1635 + if [ "$match" = "" ]; then 20.1636 + eval_gettext "0 file found for : \$file"; echo 20.1637 + echo "" 20.1638 + else 20.1639 + echo "" 20.1640 + echo "================================================================================" 20.1641 + eval_gettext "$match pkg(s) found with file: \$file"; echo 20.1642 + echo "" 20.1643 + fi 20.1644 + ;; 20.1645 + install) 20.1646 + # Install .tazpkg packages. 20.1647 + # 20.1648 + check_root 20.1649 + check_for_package_on_cmdline 20.1650 + check_for_package_file 20.1651 + # Check if forced install. 20.1652 + DO_CHECK="yes" 20.1653 + ROOT="" 20.1654 + while [ -n "$3" ]; do 20.1655 + case "$3" in 20.1656 + --forced) 20.1657 + DO_CHECK="no" 20.1658 + ;; 20.1659 + --root=*) 20.1660 + ROOT="${3#--root=}" 20.1661 + ;; 20.1662 + --list=*) 20.1663 + INSTALL_LIST="${3#--list=}" 20.1664 + ;; 20.1665 + *) shift 2 20.1666 + echo -e "\nUnknown option $*.\n" 20.1667 + exit 1 20.1668 + ;; 20.1669 + esac 20.1670 + shift 20.1671 + done 20.1672 + if [ "$DO_CHECK" = "yes" ]; then 20.1673 + check_for_installed_package $ROOT 20.1674 + fi 20.1675 + install_package $ROOT 20.1676 + update_desktop_database $ROOT 20.1677 + update_mime_database $ROOT ;; 20.1678 + install-list|get-install-list) 20.1679 + # Install a set of packages from a list. 20.1680 + # 20.1681 + check_root 20.1682 + if [ -z "$2" ]; then 20.1683 + echo "" 20.1684 + gettext \ 20.1685 +"Please change directory (cd) to the packages repository and specify the 20.1686 +list of packages to install. Example : tazpkg install-list packages.list" 20.1687 + echo "" && exit 0 20.1688 + fi 20.1689 + # Check if the packages list exist. 20.1690 + list_file=$2 20.1691 + if [ ! -f "$list_file" ]; then 20.1692 + gettext "Unable to find : $list_file"; echo 20.1693 + exit 0 20.1694 + else 20.1695 + LIST=`cat $2` 20.1696 + fi 20.1697 + 20.1698 + # Remember processed list 20.1699 + export INSTALL_LIST="$2" 20.1700 + 20.1701 + # Set $COMMAND and install all packages. 20.1702 + if [ "$1" = "get-install-list" ]; then 20.1703 + COMMAND=get-install 20.1704 + else 20.1705 + COMMAND=install 20.1706 + fi 20.1707 + touch $2-processed 20.1708 + 20.1709 + # Upgrade tazpkg first. It may handle new features/formats... 20.1710 + # then upgrade essential packages early 20.1711 + for pkg in busybox-pam busybox gcc-lib-base glibc-base \ 20.1712 + slitaz-base-files tazpkg ; do 20.1713 + pkg=$(egrep $pkg-[0-9] $INSTALL_LIST) 20.1714 + [ -n "$pkg" ] || continue 20.1715 + echo "Adding implicit depends $pkg ..." 20.1716 + LIST="$pkg 20.1717 +$LIST" 20.1718 + done 20.1719 + 20.1720 + for pkg in $LIST 20.1721 + do 20.1722 + grep -qs ^$pkg$ $2-processed && continue 20.1723 + tazpkg $COMMAND $pkg --list=$2 "$3" "$4" "$5" 20.1724 + done 20.1725 + rm -f $2-processed ;; 20.1726 + add-flavor) 20.1727 + # Install a set of packages from a flavor. 20.1728 + # 20.1729 + install_flavor $2 ;; 20.1730 + install-flavor) 20.1731 + # Install a set of packages from a flavor and purge other ones. 20.1732 + # 20.1733 + install_flavor $2 --purge ;; 20.1734 + set-release) 20.1735 + # Change curent release and upgrade packages. 20.1736 + # 20.1737 + RELEASE=$2 20.1738 + if [ -z "$RELEASE" ]; then 20.1739 + echo "" 20.1740 + gettext "Please specify the release you want on the command line."; echo 20.1741 + gettext "Example: tazpkg set-release cooking"; echo 20.1742 + echo "" 20.1743 + exit 0 20.1744 + fi 20.1745 + rm /var/lib/tazpkg/mirror 20.1746 + echo "$RELEASE" > /etc/slitaz-release 20.1747 + tazpkg recharge && tazpkg upgrade 20.1748 + 20.1749 + # Install missing depends 20.1750 + cd $INSTALLED 20.1751 + for i in * ; do 20.1752 + DEPENDS="" 20.1753 + . $i/receipt 20.1754 + for j in $DEPENDS ; do 20.1755 + [ -d $j ] || tazpkg get-install $j 20.1756 + done 20.1757 + done ;; 20.1758 + remove) 20.1759 + # Remove packages. 20.1760 + # 20.1761 + check_root 20.1762 + check_for_package_on_cmdline 20.1763 + ROOT="" 20.1764 + while [ -n "$3" ]; do 20.1765 + case "$3" in 20.1766 + --root=*) 20.1767 + ROOT="${3#--root=}" 20.1768 + if [ "$ROOT" ]; then 20.1769 + ROOTOPTS="--root=$ROOT" 20.1770 + else 20.1771 + ROOTOPTS="" 20.1772 + fi 20.1773 + ;; 20.1774 + *) shift 2 20.1775 + echo -e "\nUnknown option $*.\n" 20.1776 + exit 1 20.1777 + ;; 20.1778 + esac 20.1779 + shift 20.1780 + done 20.1781 + if [ ! -f "$ROOT$INSTALLED/$PACKAGE/receipt" ]; then 20.1782 + echo "" 20.1783 + eval_gettext "\$PACKAGE is not installed."; echo 20.1784 + exit 0 20.1785 + else 20.1786 + ALTERED="" 20.1787 + THE_PACKAGE=$PACKAGE # altered by receipt 20.1788 + for i in $(cd $ROOT$INSTALLED ; ls); do 20.1789 + [ -f $ROOT$INSTALLED/$i/receipt ] || continue 20.1790 + DEPENDS="" 20.1791 + . $ROOT$INSTALLED/$i/receipt 20.1792 + case " $(echo $DEPENDS) " in 20.1793 + *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";; 20.1794 + esac 20.1795 + done 20.1796 + EXTRAVERSION="" 20.1797 + . $ROOT$INSTALLED/$THE_PACKAGE/receipt 20.1798 + fi 20.1799 + echo "" 20.1800 + if [ -n "$ALTERED" ]; then 20.1801 + eval_gettext "The following packages depend on \$PACKAGE:"; echo 20.1802 + for i in $ALTERED; do 20.1803 + echo " $i" 20.1804 + done 20.1805 + fi 20.1806 + REFRESH=$(cd $ROOT$INSTALLED ; grep -sl ^$PACKAGE$ */modifiers) 20.1807 + if [ -n "$REFRESH" ]; then 20.1808 + eval_gettext "The following packages have been modified by \$PACKAGE:"; echo 20.1809 + for i in $REFRESH; do 20.1810 + echo " ${i%/modifiers}" 20.1811 + done 20.1812 + fi 20.1813 + eval_gettext "Remove \$PACKAGE (\$VERSION\$EXTRAVERSION) ?"; echo 20.1814 + gettext "Please confirm uninstallation (y/N) : "; read anser 20.1815 + if [ "$anser" = "y" ]; then 20.1816 + echo "" 20.1817 + echo -e "\033[1m`gettext \"Removing:\"`\033[0m $PACKAGE" 20.1818 + echo "================================================================================" 20.1819 + # Pre remove commands. 20.1820 + if grep -q ^pre_remove $ROOT$INSTALLED/$PACKAGE/receipt; then 20.1821 + pre_remove 20.1822 + fi 20.1823 + gettext "Removing all files installed..." 20.1824 + if [ -f $ROOT$INSTALLED/$PACKAGE/modifiers ]; then 20.1825 + for mod in `cat $ROOT$INSTALLED/$PACKAGE/modifiers` 20.1826 + do 20.1827 + for file in `cat $ROOT$INSTALLED/$PACKAGE/files.list` 20.1828 + do 20.1829 + [ $(grep "^$(echo $file | grepesc)$" $ROOT$INSTALLED/$mod/files.list | wc -l) -gt 1 ] && continue 20.1830 + remove_with_path $ROOT$file 20.1831 + done 20.1832 + done 20.1833 + else 20.1834 + for file in `cat $ROOT$INSTALLED/$PACKAGE/files.list` 20.1835 + do 20.1836 + remove_with_path $ROOT$file 20.1837 + done 20.1838 + fi 20.1839 + status 20.1840 + if grep -q ^post_remove $ROOT$INSTALLED/$PACKAGE/receipt; then 20.1841 + post_remove 20.1842 + fi 20.1843 + # Remove package receipt. 20.1844 + gettext "Removing package receipt..." 20.1845 + rm -rf $ROOT$INSTALLED/$PACKAGE 20.1846 + status 20.1847 + sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION$/d" \ 20.1848 + $LOCALSTATE/installed.md5 2> /dev/null 20.1849 + # Log this activity 20.1850 + log Removed 20.1851 + if [ -n "$ALTERED" ]; then 20.1852 + eval_gettext "Remove packages depending on \$PACKAGE" 20.1853 + echo -n " (y/N) ? "; read anser 20.1854 + if [ "$anser" = "y" ]; then 20.1855 + for i in $ALTERED; do 20.1856 + if [ -d "$ROOT$INSTALLED/$i" ]; then 20.1857 + tazpkg remove $i $ROOTOPTS 20.1858 + fi 20.1859 + done 20.1860 + fi 20.1861 + fi 20.1862 + if [ -n "$REFRESH" ]; then 20.1863 + eval_gettext "Reinstall packages modified by \$PACKAGE" 20.1864 + echo -n " (y/N) ? "; read anser 20.1865 + if [ "$anser" = "y" ]; then 20.1866 + for i in $REFRESH; do 20.1867 + if [ $(wc -l < $ROOT$INSTALLED/$i) -gt 1 ]; then 20.1868 + eval_gettext "Check \$INSTALLED/\$i for reinstallation"; echo 20.1869 + continue 20.1870 + fi 20.1871 + rm -r $ROOT$INSTALLED/$i 20.1872 + tazpkg get-install ${i%/modifiers} $ROOTOPTS --forced 20.1873 + done 20.1874 + fi 20.1875 + fi 20.1876 + else 20.1877 + echo "" 20.1878 + eval_gettext "Uninstallation of \$PACKAGE cancelled."; echo 20.1879 + fi 20.1880 + echo "" ;; 20.1881 + extract) 20.1882 + # Extract .tazpkg cpio archive into a directory. 20.1883 + # 20.1884 + check_for_package_on_cmdline 20.1885 + check_for_package_file 20.1886 + echo "" 20.1887 + echo -e "\033[1m`gettext \"Extracting:\"`\033[0m $PACKAGE" 20.1888 + echo "================================================================================" 20.1889 + # If no directory destination is found on the cmdline 20.1890 + # we create one in the current dir using the package name. 20.1891 + if [ -n "$TARGET_DIR" ]; then 20.1892 + DESTDIR=$TARGET_DIR/$PACKAGE 20.1893 + else 20.1894 + DESTDIR=$PACKAGE 20.1895 + fi 20.1896 + mkdir -p $DESTDIR 20.1897 + gettext "Copying original package..." 20.1898 + cp $PACKAGE_FILE $DESTDIR 20.1899 + status 20.1900 + cd $DESTDIR 20.1901 + extract_package 20.1902 + echo "================================================================================" 20.1903 + eval_gettext "\$PACKAGE is extracted to: \$DESTDIR"; echo 20.1904 + echo "" ;; 20.1905 + recompress) 20.1906 + # Recompress .tazpkg cpio archive with lzma. 20.1907 + # 20.1908 + check_for_package_on_cmdline 20.1909 + check_for_package_file 20.1910 + echo "" 20.1911 + echo -e "\033[1m`gettext \"Recompressing:\"`\033[0m $PACKAGE" 20.1912 + echo "================================================================================" 20.1913 + mkdir -p $TMP_DIR 20.1914 + gettext "Copying original package..." 20.1915 + cp $PACKAGE_FILE $TMP_DIR 20.1916 + status 20.1917 + cd $TMP_DIR 20.1918 + extract_package 20.1919 + gettext "Recompressing the fs... " 20.1920 + find fs | cpio -o -H newc 2> /dev/null | lzma e fs.cpio.lzma -si 20.1921 + rm -rf fs 20.1922 + status 20.1923 + gettext "Creating new package... " 20.1924 + find . -print | cpio -o -H newc > \ 20.1925 + $TOP_DIR/$(basename $PACKAGE_FILE).$$ && mv -f \ 20.1926 + $TOP_DIR/$(basename $PACKAGE_FILE).$$ \ 20.1927 + $TOP_DIR/$(basename $PACKAGE_FILE) 20.1928 + status 20.1929 + cd $TOP_DIR 20.1930 + rm -rf $TMP_DIR ;; 20.1931 + list-config) 20.1932 + # List configuration files installed. 20.1933 + # 20.1934 + if [ "$2" = "--box" ]; then 20.1935 + mkdir -p $TMP_DIR && cd $TMP_DIR 20.1936 + FILES="$INSTALLED/*/volatile.cpio.gz" 20.1937 + [ -n "$3" ] && FILES="$INSTALLED/$3/volatile.cpio.gz" 20.1938 + for i in $FILES; do 20.1939 + zcat $i | cpio -idm > /dev/null 20.1940 + find * -type f 2>/dev/null | while read file; do 20.1941 + if [ ! -e /$file ]; then 20.1942 + echo -n "|--|--|--|File lost" 20.1943 + else 20.1944 + echo -n "$(stat -c "%A|%U|%G|%s|" /$file)" 20.1945 + cmp $file /$file > /dev/null 2>&1 || \ 20.1946 + echo -n "$(stat -c "%.16y" /$file)" 20.1947 + fi 20.1948 + echo "|/$file" 20.1949 + done 20.1950 + rm -rf * 20.1951 + done 20.1952 + cd $TOP_DIR 20.1953 + rm -rf $TMP_DIR 20.1954 + else 20.1955 + echo "" 20.1956 + echo -e "\033[1m`gettext \"Configuration files\"`" 20.1957 + echo "================================================================================" 20.1958 + for i in $INSTALLED/*/volatile.cpio.gz; do 20.1959 + [ -n "$2" -a "$i" != "$INSTALLED/$2/volatile.cpio.gz" ] && continue 20.1960 + [ -f "$i" ] || continue 20.1961 + zcat $i | cpio -t | grep -v "[0-9]* blocks" 20.1962 + done | sed 's|^|/|' | sort 20.1963 + echo "================================================================================" 20.1964 + echo "" 20.1965 + fi ;; 20.1966 + repack-config) 20.1967 + # Create SliTaz package archive from configuration files. 20.1968 + # 20.1969 + mkdir -p $TMP_DIR && cd $TMP_DIR 20.1970 + CONFIG_VERSION=1.0 20.1971 + mkdir config-$CONFIG_VERSION 20.1972 + cd config-$CONFIG_VERSION 20.1973 + for i in $INSTALLED/*/volatile.cpio.gz; do 20.1974 + zcat $i | cpio -t | grep -v "[0-9]* blocks" 20.1975 + done > files.list 20.1976 + mkdir fs 20.1977 + cd fs 20.1978 + ( cd / ; cpio -o -H newc ) < ../files.list | cpio -idm > /dev/null 20.1979 + mkdir -p etc/tazlito 20.1980 + for i in $INSTALLED/*/receipt; do 20.1981 + EXTRAVERSION="" 20.1982 + . $i 20.1983 + echo "$PACKAGE-$VERSION$EXTRAVERSION" 20.1984 + done > etc/tazlito/config-packages.list 20.1985 + cd .. 20.1986 + echo "etc/tazlito/config-packages.list" >> files.list 20.1987 + cat > receipt <<EOT 20.1988 +# SliTaz package receipt. 20.1989 + 20.1990 +PACKAGE="config" 20.1991 +VERSION="$CONFIG_VERSION" 20.1992 +CATEGORY="base-system" 20.1993 +SHORT_DESC="User configuration backup on $(date)" 20.1994 +DEPENDS="$(ls $INSTALLED)" 20.1995 +EOT 20.1996 + cd .. 20.1997 + tazpkg pack config-$CONFIG_VERSION 20.1998 + cp config-$CONFIG_VERSION.tazpkg $TOP_DIR 20.1999 + cd $TOP_DIR 20.2000 + rm -rf $TMP_DIR 20.2001 + ;; 20.2002 + repack) 20.2003 + # Create SliTaz package archive from an installed package. 20.2004 + # 20.2005 + check_for_package_on_cmdline 20.2006 + check_for_receipt 20.2007 + EXTRAVERSION="" 20.2008 + . $INSTALLED/$PACKAGE/receipt 20.2009 + echo "" 20.2010 + echo -e "\033[1mRepacking :\033[0m $PACKAGE-$VERSION$EXTRAVERSION.tazpkg" 20.2011 + echo "================================================================================" 20.2012 + if grep -qs ^NO_REPACK= $INSTALLED/$PACKAGE/receipt; then 20.2013 + echo "Can't repack $PACKAGE" 20.2014 + exit 1 20.2015 + fi 20.2016 + if [ -s $INSTALLED/$PACKAGE/modifiers ]; then 20.2017 + eval_gettext "Can't repack, \$PACKAGE files have been modified by:"; echo 20.2018 + for i in $(cat $INSTALLED/$PACKAGE/modifiers); do 20.2019 + echo " $i" 20.2020 + done 20.2021 + exit 1 20.2022 + fi 20.2023 + MISSING="" 20.2024 + while read i; do 20.2025 + [ -e "$i" ] && continue 20.2026 + [ -L "$i" ] || MISSING="$MISSING\n $i" 20.2027 + done < $INSTALLED/$PACKAGE/files.list 20.2028 + if [ -n "$MISSING" ]; then 20.2029 + gettext "Can't repack, the following files are lost:" 20.2030 + echo -e "$MISSING" 20.2031 + exit 1 20.2032 + fi 20.2033 + mkdir -p $TMP_DIR && cd $TMP_DIR 20.2034 + FILES="fs.cpio.lzma\n" 20.2035 + for i in $(ls $INSTALLED/$PACKAGE) ; do 20.2036 + [ "$i" = "volatile.cpio.gz" ] && continue 20.2037 + [ "$i" = "modifiers" ] && continue 20.2038 + cp $INSTALLED/$PACKAGE/$i . && FILES="$FILES$i\n" 20.2039 + done 20.2040 + ln -s / rootfs 20.2041 + mkdir tmp 20.2042 + sed 's/^/rootfs/' < files.list | cpio -o -H newc 2>/dev/null |\ 20.2043 + ( cd tmp ; cpio -idm >/dev/null ) 20.2044 + mv tmp/rootfs fs 20.2045 + if [ -f $INSTALLED/$PACKAGE/volatile.cpio.gz ]; then 20.2046 + zcat $INSTALLED/$PACKAGE/volatile.cpio.gz | \ 20.2047 + ( cd fs; cpio -idm ) 20.2048 + fi 20.2049 + if grep -q repack_cleanup $INSTALLED/$PACKAGE/receipt; then 20.2050 + . $INSTALLED/$PACKAGE/receipt 20.2051 + repack_cleanup fs 20.2052 + fi 20.2053 + if [ -f $INSTALLED/$PACKAGE/md5sum ]; then 20.2054 + sed 's, , fs,' < $INSTALLED/$PACKAGE/md5sum | \ 20.2055 + md5sum -s -c || { 20.2056 + echo "Can't repack, md5sum error." 20.2057 + cd $TOP_DIR 20.2058 + rm -rf $TMP_DIR 20.2059 + exit 1 20.2060 + } 20.2061 + fi 20.2062 + find fs | cpio -o -H newc 2> /dev/null | lzma e fs.cpio.lzma -si 20.2063 + echo -e "$FILES" | cpio -o -H newc 2> /dev/null > \ 20.2064 + $TOP_DIR/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 20.2065 + cd $TOP_DIR 20.2066 + \rm -R $TMP_DIR 20.2067 + eval_gettext "Package \$PACKAGE repacked successfully."; echo 20.2068 + echo "Size : `du -sh $PACKAGE-$VERSION$EXTRAVERSION.tazpkg`" 20.2069 + echo "" ;; 20.2070 + pack) 20.2071 + # Create SliTaz package archive using cpio and gzip. 20.2072 + # 20.2073 + check_for_package_on_cmdline 20.2074 + cd $PACKAGE 20.2075 + if [ ! -f "receipt" ]; then 20.2076 + gettext "Receipt is missing. Please read the documentation."; echo 20.2077 + exit 0 20.2078 + else 20.2079 + echo "" 20.2080 + echo -e "\033[1mPacking :\033[0m $PACKAGE" 20.2081 + echo "================================================================================" 20.2082 + # Create files.list with redirecting find outpout. 20.2083 + gettext "Creating the list of files..." && cd fs 20.2084 + find . -type f -print > ../files.list 20.2085 + find . -type l -print >> ../files.list 20.2086 + cd .. && sed -i s/'^.'/''/ files.list 20.2087 + status 20.2088 + gettext "Creating md5sum of files..." 20.2089 + while read file; do 20.2090 + [ -L "fs$file" ] && continue 20.2091 + [ -f "fs$file" ] || continue 20.2092 + case "$file" in 20.2093 + /lib/modules/*/modules.*|*.pyc) continue;; 20.2094 + esac 20.2095 + md5sum "fs$file" | sed 's/ fs/ /' 20.2096 + done < files.list > md5sum 20.2097 + status 20.2098 + UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \ 20.2099 + description.txt 2> /dev/null | awk \ 20.2100 + '{ sz=$1 } END { print sz }') 20.2101 + # Build cpio archives. 20.2102 + gettext "Compressing the fs... " 20.2103 + find fs | cpio -o -H newc | lzma e fs.cpio.lzma -si 20.2104 + rm -rf fs 20.2105 + status 20.2106 + PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \ 20.2107 + md5sum description.txt 2> /dev/null | awk \ 20.2108 + '{ sz=$1 } END { print sz }') 20.2109 + gettext "Updating receipt sizes..." 20.2110 + sed -i s/^PACKED_SIZE.*$// receipt 20.2111 + sed -i s/^UNPACKED_SIZE.*$// receipt 20.2112 + sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt 20.2113 + status 20.2114 + gettext "Creating full cpio archive... " 20.2115 + find . -print | cpio -o -H newc > ../$PACKAGE.tazpkg 20.2116 + status 20.2117 + gettext "Restoring original package tree... " 20.2118 + unlzma -c fs.cpio.lzma | cpio -idm 20.2119 + status 20.2120 + rm fs.cpio.lzma && cd .. 20.2121 + echo "================================================================================" 20.2122 + eval_gettext "Package \$PACKAGE compressed successfully."; echo 20.2123 + echo "Size : `du -sh $PACKAGE.tazpkg`" 20.2124 + echo "" 20.2125 + fi ;; 20.2126 + recharge) 20.2127 + # Recharge packages.list from a mirror. 20.2128 + # 20.2129 + check_root 20.2130 + for path in $LOCALSTATE $LOCALSTATE/undigest/*; do 20.2131 + [ -f $path/mirror ] || continue 20.2132 + echo "" 20.2133 + if [ "$path" != "$LOCALSTATE" ]; then 20.2134 + echo "Recharging undigest $(basename $path):" 20.2135 + fi 20.2136 + cd $path 20.2137 + if [ -f "packages.list" ]; then 20.2138 + gettext "Creating backup of the last packages list..." 20.2139 + mv -f packages.desc packages.desc.bak 2>/dev/null 20.2140 + mv -f packages.md5 packages.md5.txt 2>/dev/null 20.2141 + mv -f packages.txt packages.txt.bak 2>/dev/null 20.2142 + mv -f packages.list packages.list.bak 2>/dev/null 20.2143 + mv -f packages.equiv packages.equiv.bak 2>/dev/null 20.2144 + mv -f files.list.lzma files.list.lzma.bak 2> /dev/null 20.2145 + mv -f mirrors mirrors.bak 2> /dev/null 20.2146 + status 20.2147 + fi 20.2148 + download_from "$(cat mirror)" packages.desc 20.2149 + download_from "$(cat mirror)" packages.md5 20.2150 + download_from "$(cat mirror)" packages.txt 20.2151 + download_from "$(cat mirror)" packages.list 20.2152 + download_from "$(cat mirror)" packages.equiv 20.2153 + download_from "$(cat mirror)" files.list.lzma 20.2154 + download_from "$(sed 's|packages/.*||' < mirror)" mirrors 20.2155 + [ -f mirrors ] || mv mirrors.bak mirrors 2> /dev/null 20.2156 + suffix=$(head -1 mirror) 20.2157 + suffix=packages${suffix#*/packages} 20.2158 + for i in $(cat mirrors 2> /dev/null); do 20.2159 + grep -qs $i mirror || echo $i$suffix >> mirror 20.2160 + done 20.2161 + if [ -f "packages.list.bak" ]; then 20.2162 + diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff 20.2163 + sed -i s/+// packages.diff 20.2164 + echo "" 20.2165 + echo -e "\033[1m`gettext \"Mirrored packages diff\"`\033[0m" 20.2166 + echo "================================================================================" 20.2167 + cat packages.diff 20.2168 + new_pkgs=`cat packages.diff | wc -l` 20.2169 + if [ "$new_pkgs" != 0 ]; then 20.2170 + echo "================================================================================" 20.2171 + eval_gettext "\$new_pkgs new packages on the mirror."; echo 20.2172 + echo "" 20.2173 + else 20.2174 + gettext "No new packages on the mirror."; echo 20.2175 + echo "" 20.2176 + fi 20.2177 + else 20.2178 + echo -e " 20.2179 +================================================================================" 20.2180 + gettext \ 20.2181 +"Last packages.list is ready to use. Note that next time you recharge the 20.2182 +list, a list of differences will be displayed to show new and upgradeable 20.2183 +packages." 20.2184 + echo "" 20.2185 + fi 20.2186 + done ;; 20.2187 + upgradeable) 20.2188 + # Build upgradeable-packages.list quickly. 20.2189 + # 20.2190 + check_root 20.2191 + cd $LOCALSTATE 20.2192 + while read md5 file ; do 20.2193 + grep -qs "$md5 $file" packages.md5 && continue 20.2194 + for i in 1 2 3 4 5; do 20.2195 + file=${file%-*} 20.2196 + [ -d installed/$file ] || continue 20.2197 + echo $file 20.2198 + break 20.2199 + done 20.2200 + done < installed.md5 > upgradeable-packages.list ;; 20.2201 + upgrade) 20.2202 + # Upgrade all installed packages with the new version from the mirror. 20.2203 + # 20.2204 + check_root 20.2205 + check_for_packages_list 20.2206 + cd $LOCALSTATE 20.2207 + # Touch the blocked pkgs list to avoid errors and remove any old 20.2208 + # upgrade list. 20.2209 + touch blocked-packages.list 20.2210 + rm -f upgradeable-packages.list 20.2211 + echo "" 20.2212 + echo -e "\033[1m`gettext \"Available upgrades\"`\033[0m" 20.2213 + echo "================================================================================" 20.2214 + echo "" 20.2215 + # Some packages must be installed first 20.2216 + FIRST_CLASS_PACKAGE=" glibc-base slitaz-base-files slitaz-boot-scripts " 20.2217 + if [ -n "$PACKAGE_FILE" -a -d "$INSTALLED/$PACKAGE_FILE" ]; then 20.2218 + ALL=$INSTALLED/$PACKAGE_FILE 20.2219 + else 20.2220 + ALL="$(ls -d $INSTALLED/*)" 20.2221 + fi 20.2222 + for pkg in $ALL 20.2223 + do 20.2224 + [ -f $pkg/receipt ] || continue 20.2225 + EXTRAVERSION="" 20.2226 + . $pkg/receipt 20.2227 + # Display package name to show that Tazpkg is working... 20.2228 + echo -en "\\033[0G " 20.2229 + echo -en "\\033[0G$PACKAGE" 20.2230 + # Skip specified pkgs listed in $LOCALSTATE/blocked-packages.list 20.2231 + if grep -qs "^$PACKAGE" $BLOCKED; then 20.2232 + blocked=$(($blocked+1)) 20.2233 + else 20.2234 + # Check if the installed package is in the current list (other 20.2235 + # mirror or local). 20.2236 + NEW_PACKAGE=$(get_package_filename $PACKAGE) 20.2237 + 20.2238 + if [ -n "$NEW_PACKAGE" ]; then 20.2239 + # Set new pkg and version for future comparison 20.2240 + NEW_VERSION=`echo $NEW_PACKAGE | sed s/$PACKAGE-/''/` 20.2241 + # Change '-' and 'pre' to points. 20.2242 + NEW_VERSION=`echo $NEW_VERSION | sed s/'-'/'.'/` 20.2243 + VERSION=`echo $VERSION | sed s/'-'/'.'/`$EXTRAVERSION 20.2244 + NEW_VERSION=`echo $NEW_VERSION | sed s/'pre'/'.'/` 20.2245 + VERSION=`echo $VERSION | sed s/'pre'/'.'/` 20.2246 + NEW_VERSION=`echo $NEW_VERSION | sed 's/[A-Z]\.//'` 20.2247 + VERSION=`echo $VERSION | sed 's/[A-Z]\.//'` 20.2248 + # Compare version. Upgrades are only available for official 20.2249 + # packages, so we control the mirror and it should be ok if 20.2250 + # we just check for equality. 20.2251 + RELEASE="" 20.2252 + if [ -f installed.md5 -a -f packages.md5 ]; then 20.2253 + current_md5=$(grep -s " $PACKAGE-$VERSION" installed.md5 | awk '{ print $1 }') 20.2254 + new_md5=$(grep -hs " $PACKAGE-$VERSION" packages.md5 undigest/*/packages.md5 | head -1 | awk '{ print $1 }') 20.2255 + [ -n "$current_md5" ] && [ -n "$new_md5" ] && 20.2256 + [ "$current_md5" != "$new_md5" ] && RELEASE=build 20.2257 + fi 20.2258 + if [ "$VERSION" != "$NEW_VERSION" -o -n "$RELEASE" ]; then 20.2259 + # Version seems different. Check for major, minor or 20.2260 + # revision 20.2261 + PKG_MAJOR=`echo ${VERSION%_*} | cut -f1 -d"."` 20.2262 + NEW_MAJOR=`echo ${NEW_VERSION%_*} | cut -f1 -d"."` 20.2263 + PKG_MINOR=`echo ${VERSION%_*} | cut -f2 -d"."` 20.2264 + NEW_MINOR=`echo ${NEW_VERSION%_*} | cut -f2 -d"."` 20.2265 + # Minor 20.2266 + if [ "$NEW_MINOR" -gt "$PKG_MINOR" ] 2> /dev/null; then 20.2267 + RELEASE=minor 20.2268 + fi 20.2269 + if [ "$NEW_MINOR" -lt "$PKG_MINOR" ] 2> /dev/null; then 20.2270 + RELEASE=$WARNING 20.2271 + FIXE=yes 20.2272 + fi 20.2273 + # Major 20.2274 + if [ "$NEW_MAJOR" -gt "$PKG_MAJOR" ] 2> /dev/null; then 20.2275 + RELEASE=major 20.2276 + FIXE="" 20.2277 + fi 20.2278 + if [ "$NEW_MAJOR" -lt "$PKG_MAJOR" ] 2> /dev/null; then 20.2279 + RELEASE=WARNING 20.2280 + FIXE=yes 20.2281 + fi 20.2282 + # Default to revision. 20.2283 + if [ -z $RELEASE ]; then 20.2284 + RELEASE=revision 20.2285 + fi 20.2286 + # Pkg name is already displayed by the check process. 20.2287 + echo -en "\033[24G $VERSION" 20.2288 + echo -en "\033[38G --->" 20.2289 + echo -en "\033[43G $NEW_VERSION" 20.2290 + echo -en "\033[58G $CATEGORY" 20.2291 + echo -e "\033[72G $RELEASE" 20.2292 + up=$(($up+1)) 20.2293 + echo "$PACKAGE" >> upgradeable-packages.list 20.2294 + case "$FIRST_CLASS_PACKAGE" in 20.2295 + *\ $PACKAGE\ *) echo "$PACKAGE" >> upgradeable-packages.list$$;; 20.2296 + esac 20.2297 + unset RELEASE 20.2298 + fi 20.2299 + packages=$(($packages+1)) 20.2300 + fi 20.2301 + fi 20.2302 + done 20.2303 + if [ -z $blocked ]; then 20.2304 + blocked=0 20.2305 + fi 20.2306 + # Clean last checked package and display summary. 20.2307 + if [ ! "$up" = "" ]; then 20.2308 + echo -e "\\033[0G " 20.2309 + echo "================================================================================" 20.2310 + eval_gettext "\$packages installed and listed packages to consider, \$up to upgrade, \$blocked blocked."; echo 20.2311 + echo "" 20.2312 + else 20.2313 + echo -e "\\033[0G`gettext \"System is up-to-date.\"` " 20.2314 + echo "" 20.2315 + echo "================================================================================" 20.2316 + eval_gettext "\$packages installed and listed packages to consider, 0 to upgrade, \$blocked blocked."; echo 20.2317 + echo "" 20.2318 + exit 0 20.2319 + fi 20.2320 + # What to do if major or minor version is smaller. 20.2321 + if [ "$FIXE" == "yes" ]; then 20.2322 + gettext \ 20.2323 +"WARNING ---> Installed package seems more recent than the mirrored 20.2324 +one. You can block packages using the command : 'tazpkg block package'. 20.2325 +Or upgrade packages at your own risk." 20.2326 + echo "" 20.2327 + fi 20.2328 + # Ask for upgrade, it can be done another time. 20.2329 + echo -n "Upgrade now (y/N) ? "; read anser 20.2330 + if [ ! "$anser" = "y" ]; then 20.2331 + echo "" 20.2332 + gettext "Exiting. No package upgraded."; echo 20.2333 + echo "" 20.2334 + exit 0 20.2335 + fi 20.2336 + # If anser is yes (y). Install all new versions. 20.2337 + cat upgradeable-packages.list >> upgradeable-packages.list$$ 20.2338 + mv -f upgradeable-packages.list$$ upgradeable-packages.list 20.2339 + yes y | tazpkg get-install-list upgradeable-packages.list --forced 20.2340 + rm -f upgradeable-packages.list 20.2341 + ;; 20.2342 + bugs) 20.2343 + # Show known bugs in package(s) 20.2344 + # 20.2345 + cd $INSTALLED 20.2346 + shift 20.2347 + LIST=$@ 20.2348 + [ -n "$LIST" ] || LIST=`ls` 20.2349 + MSG=`gettext "No known bugs."` 20.2350 + for PACKAGE in $LIST; do 20.2351 + BUGS="" 20.2352 + EXTRAVERSION="" 20.2353 + . $PACKAGE/receipt 20.2354 + if [ -n "$BUGS" ]; then 20.2355 + MSG=`gettext "Bug list completed"` 20.2356 + echo "" 20.2357 + eval_gettext "Bugs in package \$PACKAGE version \$VERSION\$EXTRAVERSION:"; echo 20.2358 + cat <<EOT 20.2359 + $BUGS 20.2360 +EOT 20.2361 + fi 20.2362 + done 20.2363 + echo "$MSG" ;; 20.2364 + check) 20.2365 + # Check installed packages set. 20.2366 + # 20.2367 + check_root 20.2368 + cd $INSTALLED 20.2369 + for PACKAGE in `ls`; do 20.2370 + if [ ! -f $PACKAGE/receipt ]; then 20.2371 + eval_gettext "The package \$PACKAGE installation has not completed"; echo 20.2372 + continue 20.2373 + fi 20.2374 + DEPENDS="" 20.2375 + EXTRAVERSION="" 20.2376 + . $PACKAGE/receipt 20.2377 + if [ -s $PACKAGE/modifiers ]; then 20.2378 + eval_gettext \ 20.2379 + "The package \$PACKAGE \$VERSION\$EXTRAVERSION has been modified by:"; echo 20.2380 + for i in $(cat $PACKAGE/modifiers); do 20.2381 + echo " $i" 20.2382 + done 20.2383 + fi 20.2384 + MSG="Files lost from $PACKAGE $VERSION$EXTRAVERSION :\n" 20.2385 + while read file; do 20.2386 + [ -e "$file" ] && continue 20.2387 + if [ -L "$file" ]; then 20.2388 + MSG="$MSG target of symlink" 20.2389 + fi 20.2390 + echo -e "$MSG $file" 20.2391 + MSG="" 20.2392 + done < $PACKAGE/files.list 20.2393 + MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" 20.2394 + for i in $DEPENDS; do 20.2395 + [ -d $i ] && continue 20.2396 + [ -d $(equivalent_pkg $i) ] && continue 20.2397 + echo -e "$MSG $i" 20.2398 + MSG="" 20.2399 + done 20.2400 + MSG="Dependencies loop between $PACKAGE and :\n" 20.2401 + ALL_DEPS="" 20.2402 + check_for_deps_loop $PACKAGE $DEPENDS 20.2403 + done 20.2404 + echo -n "Looking for known bugs... " 20.2405 + tazpkg bugs 20.2406 + if [ "$PACKAGE_FILE" = "--full" ]; then 20.2407 + for file in */md5sum; do 20.2408 + CONFIG_FILES="" 20.2409 + . $(dirname "$file")/receipt 20.2410 + [ -s "$file" ] || continue 20.2411 + while read md5 f; do 20.2412 + [ -f $f ] || continue 20.2413 + for i in $CONFIG_FILES; do 20.2414 + case "$f" in 20.2415 + $i|$i/*) continue 2;; 20.2416 + esac 20.2417 + done 20.2418 + echo "$md5 $f" 20.2419 + done < "$file" | md5sum -c - 2> /dev/null | \ 20.2420 + grep -v OK$ | sed 's/FAILED$/MD5SUM MISMATCH/' 20.2421 + done 20.2422 + FILES=" " 20.2423 + for file in $(cat */files.list); do 20.2424 + [ -d "$file" ] && continue 20.2425 + case "$FILES" in *\ $file\ *) continue;; esac 20.2426 + [ $(grep "^$(echo $file | grepesc)$" */files.list 2> /dev/null | \ 20.2427 + wc -l) -gt 1 ] || continue 20.2428 + FILES="$FILES$file " 20.2429 + echo "The following packages provide $file :" 20.2430 + grep -l "^$(echo $file | grepesc)$" */files.list | while read f 20.2431 + do 20.2432 + pkg=${f%/files.list} 20.2433 + echo -n " $pkg" 20.2434 + if [ -f $pkg/modifiers ]; then 20.2435 + echo -n " (overridden by $(echo "$(cat $pkg/modifiers)"))" 20.2436 + fi 20.2437 + echo "" 20.2438 + done 20.2439 + done 20.2440 + MSG="No package has installed the following files:\n" 20.2441 + find /etc /bin /sbin /lib /usr /var/www \ 20.2442 + -not -type d 2> /dev/null | while read file; do 20.2443 + case "$file" in *\[*) continue;; esac 20.2444 + grep -q "^$(echo $file | grepesc)$" */files.list && continue 20.2445 + echo -e "$MSG $file" 20.2446 + MSG="" 20.2447 + done 20.2448 + fi 20.2449 + echo "Check completed." ;; 20.2450 + block) 20.2451 + # Add a pkg name to the list of blocked packages. 20.2452 + # 20.2453 + check_root 20.2454 + check_for_package_on_cmdline 20.2455 + echo "" 20.2456 + if grep -qs "^$PACKAGE" $BLOCKED; then 20.2457 + eval_gettext "\$PACKAGE is already in the blocked packages list."; echo 20.2458 + echo "" 20.2459 + exit 0 20.2460 + else 20.2461 + eval_gettext "Add \$PACKAGE to : \$BLOCKED..." 20.2462 + echo $PACKAGE >> $BLOCKED 20.2463 + status 20.2464 + # Log this activity 20.2465 + . $INSTALLED/$PACKAGE/receipt 20.2466 + log Blocked 20.2467 + fi 20.2468 + echo "" ;; 20.2469 + unblock) 20.2470 + # Remove a pkg name from the list of blocked packages. 20.2471 + # 20.2472 + check_root 20.2473 + check_for_package_on_cmdline 20.2474 + echo "" 20.2475 + if grep -qs "^$PACKAGE" $BLOCKED; then 20.2476 + eval_gettext "Removing \$PACKAGE from : \$BLOCKED..." 20.2477 + sed -i s/$PACKAGE/''/ $BLOCKED 20.2478 + sed -i '/^$/d' $BLOCKED 20.2479 + status 20.2480 + # Log this activity 20.2481 + . $INSTALLED/$PACKAGE/receipt 20.2482 + log Unblocked 20.2483 + else 20.2484 + eval_gettext "\$PACKAGE is not in the blocked packages list." 20.2485 + echo "" 20.2486 + exit 0 20.2487 + fi 20.2488 + echo "" ;; 20.2489 + get) 20.2490 + # Downlowd a package with wget. 20.2491 + # 20.2492 + check_for_package_on_cmdline 20.2493 + check_for_packages_list 20.2494 + check_for_package_in_list 20.2495 + echo "" 20.2496 + download $PACKAGE.tazpkg 20.2497 + echo "" ;; 20.2498 + get-install) 20.2499 + # Download and install a package. 20.2500 + # 20.2501 + check_root 20.2502 + check_for_package_on_cmdline 20.2503 + check_for_packages_list 20.2504 + DO_CHECK="" 20.2505 + while [ -n "$3" ]; do 20.2506 + case "$3" in 20.2507 + --forced) 20.2508 + DO_CHECK="no" 20.2509 + ;; 20.2510 + --root=*) 20.2511 + ROOT="${3#--root=}" 20.2512 + ;; 20.2513 + --list=*) 20.2514 + INSTALL_LIST="${3#--list=}" 20.2515 + ;; 20.2516 + *) shift 2 20.2517 + echo -e "\nUnknown option $*.\n" 20.2518 + exit 1 20.2519 + ;; 20.2520 + esac 20.2521 + shift 20.2522 + done 20.2523 + AUTOEXEC="no" 20.2524 + if ! check_for_package_in_list check; then 20.2525 + PACKAGE=get-$PACKAGE 20.2526 + AUTOEXEC=$PACKAGE 20.2527 + check_for_package_in_list 20.2528 + if [ -n "$(get_installed_package_pathname $PACKAGE $ROOT)" ]; then 20.2529 + $AUTOEXEC $ROOT 20.2530 + exit 0 20.2531 + fi 20.2532 + fi 20.2533 + # Check if forced install. 20.2534 + if [ "$DO_CHECK" = "no" ]; then 20.2535 + rm -f $CACHE_DIR/$PACKAGE.tazpkg 20.2536 + else 20.2537 + check_for_installed_package $ROOT 20.2538 + fi 20.2539 + cd $CACHE_DIR 20.2540 + if [ -f "$PACKAGE.tazpkg" ]; then 20.2541 + echo "$PACKAGE already in the cache : $CACHE_DIR" 20.2542 + # Check package download was finished 20.2543 + tail -c 2k $PACKAGE.tazpkg | grep -q 00000000TRAILER || { 20.2544 + eval_gettext "Continuing \$PACKAGE download"; echo 20.2545 + download $PACKAGE.tazpkg 20.2546 + } 20.2547 + if [ "$(md5sum $PACKAGE.tazpkg)" != "$(grep " $PACKAGE.tazpkg$" /var/lib/tazpkg/packages.md5)" ]; then 20.2548 + rm -f $PACKAGE.tazpkg 20.2549 + download $PACKAGE.tazpkg 20.2550 + fi 20.2551 + else 20.2552 + echo "" 20.2553 + download $PACKAGE.tazpkg 20.2554 + fi 20.2555 + PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg 20.2556 + install_package $ROOT 20.2557 + [ "$AUTOEXEC" != "no" ] && $PACKAGE $ROOT 20.2558 + update_desktop_database $ROOT 20.2559 + update_mime_database $ROOT ;; 20.2560 + clean-cache) 20.2561 + # Remove all downloaded packages. 20.2562 + # 20.2563 + check_root 20.2564 + files=`ls -1 $CACHE_DIR | wc -l` 20.2565 + echo "" 20.2566 + echo -e "\033[1m`gettext \"Clean cache:\"`\033[0m $CACHE_DIR" 20.2567 + echo "================================================================================" 20.2568 + gettext "Cleaning cache directory..." 20.2569 + rm -rf $CACHE_DIR/* 20.2570 + status 20.2571 + echo "================================================================================" 20.2572 + eval_gettext "\$files file(s) removed from cache."; echo 20.2573 + echo "" ;; 20.2574 + list-undigest) 20.2575 + # list undigest URLs. 20.2576 + # 20.2577 + if [ "$2" = "--box" ]; then 20.2578 + for i in $LOCALSTATE/undigest/*/mirror; do 20.2579 + [ -f $i ] || continue 20.2580 + echo "$(basename $(dirname $i))|$(cat $i)" 20.2581 + done 20.2582 + else 20.2583 + echo "" 20.2584 + echo -e "\033[1m`gettext \"Current undigest(s)\"`\033[0m" 20.2585 + echo "================================================================================" 20.2586 + for i in $LOCALSTATE/undigest/*/mirror; do 20.2587 + if [ ! -f $i ]; then 20.2588 + gettext "No undigest mirror found."; echo 20.2589 + exit 1 20.2590 + fi 20.2591 + echo "$(basename $(dirname $i)) $(cat $i)" 20.2592 + done 20.2593 + echo "" 20.2594 + fi ;; 20.2595 + remove-undigest) 20.2596 + # remove undigest URL. 20.2597 + # 20.2598 + check_root 20.2599 + if [ -d $LOCALSTATE/undigest/$2 ]; then 20.2600 + echo -n "Remove $2 undigest (y/N) ? "; read anser 20.2601 + if [ "$anser" = "y" ]; then 20.2602 + echo -n "Removing $2 undigest..." 20.2603 + rm -rf $LOCALSTATE/undigest/$2 20.2604 + status 20.2605 + rmdir $LOCALSTATE/undigest 2> /dev/null 20.2606 + fi 20.2607 + else 20.2608 + echo "Undigest $2 not found" 20.2609 + fi ;; 20.2610 + add-undigest|setup-undigest) 20.2611 + # Add undigest URL. 20.2612 + # 20.2613 + check_root 20.2614 + undigest=$2 20.2615 + [ -d $LOCALSTATE/undigest ] || mkdir $LOCALSTATE/undigest 20.2616 + if [ -z "$undigest" ]; then 20.2617 + i=1 20.2618 + while [ -d $LOCALSTATE/undigest/$i ]; do 20.2619 + i=$(($i+1)) 20.2620 + done 20.2621 + undigest=$i 20.2622 + fi 20.2623 + if [ ! -d $LOCALSTATE/undigest/$undigest ]; then 20.2624 + eval_gettext "Creating new undigest \$undigest."; echo 20.2625 + mkdir $LOCALSTATE/undigest/$undigest 20.2626 + fi 20.2627 + setup_mirror $LOCALSTATE/undigest/$undigest $3 ;; 20.2628 + setup-mirror) 20.2629 + # Change mirror URL. 20.2630 + # 20.2631 + check_root 20.2632 + setup_mirror $LOCALSTATE $2 ;; 20.2633 + reconfigure) 20.2634 + # Replay post_install from receipt 20.2635 + # 20.2636 + check_for_package_on_cmdline 20.2637 + check_root 20.2638 + ROOT="" 20.2639 + while [ -n "$3" ]; do 20.2640 + case "$3" in 20.2641 + --root=*) 20.2642 + ROOT="${3#--root=}/" ;; 20.2643 + *) shift 2 20.2644 + echo -e "\nUnknown option $*.\n" 20.2645 + exit 1 ;; 20.2646 + esac 20.2647 + shift 20.2648 + done 20.2649 + if [ -d "$ROOT$INSTALLED/$PACKAGE" ]; then 20.2650 + check_for_receipt $ROOT 20.2651 + # Check for post_install 20.2652 + if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then 20.2653 + . $ROOT$INSTALLED/$PACKAGE/receipt 20.2654 + post_install $ROOT 20.2655 + # Log this activity 20.2656 + [ -n "$ROOT" ] || log Reconfigured 20.2657 + else 20.2658 + echo "" 20.2659 + eval_gettext "Nothing to do for \$PACKAGE."; echo 20.2660 + fi 20.2661 + else 20.2662 + echo "" 20.2663 + eval_gettext "Package \$PACKAGE is not installed."; echo 20.2664 + gettext "Install package with 'tazpkg install' or 'tazpkg get-install'"; echo 20.2665 + echo "" 20.2666 + fi ;; 20.2667 + shell) 20.2668 + # Tazpkg SHell 20.2669 + # 20.2670 + if test $(id -u) = 0 ; then 20.2671 + PROMPT="\\033[1;33mtazpkg\\033[0;39m# " 20.2672 + else 20.2673 + PROMPT="\\033[1;33mtazpkg\\033[0;39m> " 20.2674 + fi 20.2675 + if [ ! "$2" = "--noheader" ]; then 20.2676 + clear 20.2677 + echo "" 20.2678 + echo -e "\033[1mTazpkg SHell.\033[0m" 20.2679 + echo "================================================================================" 20.2680 + gettext "Type 'usage' to list all available commands or 'quit' or 'q' to exit."; echo 20.2681 + echo "" 20.2682 + fi 20.2683 + while true 20.2684 + do 20.2685 + echo -en "$PROMPT"; read cmd 20.2686 + case $cmd in 20.2687 + q|quit) 20.2688 + break ;; 20.2689 + shell) 20.2690 + gettext "You are already running a Tazpkg SHell."; echo ;; 20.2691 + su) 20.2692 + su -c 'exec tazpkg shell --noheader' && break ;; 20.2693 + "") 20.2694 + continue ;; 20.2695 + *) 20.2696 + tazpkg $cmd ;; 20.2697 + esac 20.2698 + done ;; 20.2699 + depends) 20.2700 + # Display dependencies tree 20.2701 + cd $INSTALLED 20.2702 + ALL_DEPS="" 20.2703 + if [ -f $2/receipt ]; then 20.2704 + dep_scan $2 "" 20.2705 + fi ;; 20.2706 + rdepends) 20.2707 + # Display reverse dependencies tree 20.2708 + cd $INSTALLED 20.2709 + ALL_DEPS="" 20.2710 + if [ -f $2/receipt ]; then 20.2711 + rdep_scan $2 20.2712 + fi ;; 20.2713 + convert) 20.2714 + # convert misc package format to .tazpkg 20.2715 + check_for_package_file 20.2716 + case "$PACKAGE_FILE" in 20.2717 + *.deb|*.udeb) 20.2718 + convert_deb;; 20.2719 + *.rpm) 20.2720 + convert_rpm;; 20.2721 + *.tgz) 20.2722 + convert_tgz;; 20.2723 + *.pkg.tar.gz) 20.2724 + convert_arch;; 20.2725 + *.ipk|*.opk) 20.2726 + convert_ipk;; 20.2727 + *) 20.2728 + gettext "Unsupported format"; echo ;; 20.2729 + esac ;; 20.2730 + link) 20.2731 + # link a package from another slitaz installation 20.2732 + PACKAGE=$2 20.2733 + if [ ! -d "$TARGET_DIR" -o \ 20.2734 + ! -d "$TARGET_DIR$INSTALLED/$PACKAGE" ]; then 20.2735 + cat <<EOT 20.2736 +usage: tazpkg link package_name slitaz_root 20.2737 +example: 'tazpkg link openoffice /mnt' will use less than 100k in 20.2738 + your ram running system. 20.2739 +EOT 20.2740 + exit 1 20.2741 + fi 20.2742 + if [ -e "$INSTALLED/$PACKAGE" ]; then 20.2743 + eval_gettext "\$PACKAGE is already installed."; echo 20.2744 + exit 1 20.2745 + fi 20.2746 + ln -s $TARGET_DIR$INSTALLED/$PACKAGE $INSTALLED 20.2747 + DEPENDS="$(. $INSTALLED/$PACKAGE/receipt ; echo $DEPENDS)" 20.2748 + MISSING="" 20.2749 + for i in $DEPENDS; do 20.2750 + [ -e $INSTALLED/$i ] && continue 20.2751 + MISSING="$MISSING$i " 20.2752 + eval_gettext "Missing : \$i"; echo 20.2753 + done 20.2754 + if [ -n "$MISSING" ]; then 20.2755 + echo "" 20.2756 + gettext "Link all missing dependencies (y/N) ? "; read answer 20.2757 + echo "" 20.2758 + if [ "$answer" = "y" ]; then 20.2759 + for i in $MISSING; do 20.2760 + tazpkg link $i $TARGET_DIR 20.2761 + done 20.2762 + else 20.2763 + echo "" 20.2764 + eval_gettext "Leaving dependencies for \$PACKAGE unsolved."; echo 20.2765 + gettext "The package is installed but will probably not work."; echo 20.2766 + echo "" 20.2767 + fi 20.2768 + fi 20.2769 + . $INSTALLED/$PACKAGE/receipt 20.2770 + if grep -q ^pre_install $INSTALLED/$PACKAGE/receipt; then 20.2771 + pre_install 20.2772 + fi 20.2773 + while read path; do 20.2774 + [ -e $path ] && continue 20.2775 + while true; do 20.2776 + dir=$(dirname $path) 20.2777 + [ -e $dir ] && break 20.2778 + path=$dir 20.2779 + done 20.2780 + ln -s $TARGET_DIR$path $dir 20.2781 + done < $INSTALLED/$PACKAGE/files.list 20.2782 + if grep -q ^post_install $INSTALLED/$PACKAGE/receipt; then 20.2783 + post_install 20.2784 + fi ;; 20.2785 + usage|*) 20.2786 + # Print a short help or give usage for an unknown or empty command. 20.2787 + usage ;; 20.2788 +esac 20.2789 + 20.2790 +exit 0
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/tazwok.conf Thu Nov 25 03:30:16 2010 +0000 21.3 @@ -0,0 +1,47 @@ 21.4 +# tazwok.conf: Tazwok configuration file. 21.5 +# 21.6 + 21.7 +# Wok directory/tree to find receipts and build packages. 21.8 +# By default on SliTaz the directory is /home/slitaz/wok. 21.9 +WOK="/home/slitaz/wok" 21.10 + 21.11 +# The path to the source tarballs of the binary packages. 21.12 +SOURCES_REPOSITORY="/home/slitaz/src" 21.13 + 21.14 +# This path sets the binary packages repository. It's where all 21.15 +# gen *.tazpkg will be stored when using the gen-repository command. 21.16 +PACKAGES_REPOSITORY="/home/slitaz/packages" 21.17 + 21.18 +# Default build host. 21.19 +BUILD_HOST=i486-pc-linux-gnu 21.20 + 21.21 +# Default tool prefix. 21.22 +TOOLPREFIX="${BUILD_HOST}-" 21.23 + 21.24 +# Default arguments for GNU configure. 21.25 +CONFIGURE_ARGS="--build=$BUILD_HOST --host=$BUILD_HOST" 21.26 + 21.27 +# Translation files to be included in packages. Note that you can specify 21.28 +# several locales. 21.29 +LOCALE="fr" 21.30 + 21.31 +# Mirrors URLs. To download sources near your location. 21.32 +# GNU mirror : 21.33 +GNU_MIRROR="ftp://sunsite.cnlab-switch.ch/mirror/gnu" 21.34 +# SourceForge mirror : 21.35 +SF_MIRROR="http://switch.dl.sourceforge.net/sourceforge" 21.36 +# Xorg mirror : 21.37 +XORG_MIRROR="ftp://ftp.solnet.ch/mirror/x.org/pub/individual" 21.38 + 21.39 +# Favorite console editor. 21.40 +EDITOR="nano" 21.41 + 21.42 +# FSH standard directories with init. Package generation will abort if 21.43 +# a file is installed in a non-specified path. Note /vz is for OpenVZ. 21.44 +FSH="bin boot dev etc home init lib media mnt proc root sbin share sys \ 21.45 +tmp usr var vz usr/bin usr/games usr/include usr/lib usr/local usr/sbin \ 21.46 +usr/share usr/src" 21.47 + 21.48 +# tazpkg compression "gzip" or "lzma". 21.49 +COMPRESSION="lzma" 21.50 +