slitaz-tools diff oldstuff/tazfile @ rev 994
tazbox/video: add 3gp files
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Jun 04 13:59:25 2016 +0200 (2016-06-04) |
parents | 7e8f98aac2f9 |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/oldstuff/tazfile Sat Jun 04 13:59:25 2016 +0200 1.3 @@ -0,0 +1,140 @@ 1.4 +#!/bin/sh 1.5 +# Tazfile - Tiny autonomus zone files locator. 1.6 +# 1.7 +# This is a lightweight files locator for *.tazpkg files written in 1.8 +# SHell script. It works well with Busybox ash shell and bash. Tazfile lets you 1.9 +# create and explore a files list database. 1.10 +# 1.11 +# (C) 2008 SliTaz - GNU General Public License v3. 1.12 +# 1.13 +# Author : Pascal Bellard <pascal.bellard@slitaz.org> 1.14 +# 1.15 +VERSION=1.0 1.16 + 1.17 +#################### 1.18 +# Script variables # 1.19 +#################### 1.20 + 1.21 +# Initialize some variables to use words 1.22 +# rather than numbers for functions and actions. 1.23 +COMMAND=$1 1.24 +TOP_DIR=`pwd` 1.25 +TMP_DIR=/tmp/tazfile-$$-$RANDOM 1.26 + 1.27 +# Path to tazpkg used dir and configuration files 1.28 +LOCALSTATE=/var/lib/tazpkg 1.29 +INSTALLED=$LOCALSTATE/installed 1.30 +MIRROR=$LOCALSTATE/mirror 1.31 +FILES_LIST=$LOCALSTATE/files.list.lzma 1.32 +DEFAULT_MIRROR="http://download.tuxfamily.org/slitaz/packages/`cat /etc/slitaz-release`/" 1.33 + 1.34 +# Check if the directories and files used by Tazfile 1.35 +# exist. If not and user is root we create them. 1.36 +if test $(id -u) = 0 ; then 1.37 + if [ ! -d "$INSTALLED" ]; then 1.38 + mkdir -p $INSTALLED 1.39 + fi 1.40 + if [ ! -f "$LOCALSTATE/mirror" ]; then 1.41 + echo "$DEFAULT_MIRROR" > $LOCALSTATE/mirror 1.42 + fi 1.43 +fi 1.44 + 1.45 +#################### 1.46 +# Script functions # 1.47 +#################### 1.48 + 1.49 +# Print the usage. 1.50 +usage () 1.51 +{ 1.52 + echo -e "SliTaz files locator - Version: $VERSION\n 1.53 +\033[1mUsage:\033[0m tazfile [command] [file...]\n 1.54 +\033[1mCommands: \033[0m 1.55 + usage Print this short usage. 1.56 + build Build a files list to stdout from a list of packages. 1.57 + recharge Recharge your $(basename $FILES_LIST) from the mirror. 1.58 + search Search for file(s) in all (installed or not) packages. 1.59 + 1.60 +\033[1mExample: \033[0m 1.61 + $ find . -name '*.tazpkg' | tazfile build > $(basename $FILES_LIST) 1.62 + $ tazfile recharge 1.63 + $ tazfile search awk cpio " 1.64 +} 1.65 + 1.66 +# Check for packages.list to download and install packages. 1.67 +check_for_files_list_lzma() 1.68 +{ 1.69 + if [ ! -f "$FILES_LIST" ]; then 1.70 + echo -e " 1.71 +Unable to find the list : $FILES_LIST\n 1.72 +You must probably run 'tazfile recharge' as root to get the latest list of 1.73 +files available on the mirror.\n" 1.74 + exit 0 1.75 + fi 1.76 +} 1.77 + 1.78 +# Download a file trying all mirrors 1.79 +download() 1.80 +{ 1.81 + for i in $(cat $MIRROR); do 1.82 + wget $i$@ && break 1.83 + done 1.84 +} 1.85 + 1.86 +build_database() 1.87 +{ 1.88 + while read pkg; do 1.89 + cat $pkg | ( cd $TMP_DIR 1.90 + cpio -iu > /dev/null 2>&1 1.91 + . ./receipt 1.92 + echo "$PACKAGE" 1.93 + cat ./files.list ) | awk ' 1.94 + BEGIN { name="" } 1.95 + { 1.96 + if (name == "") name=$0; 1.97 + else printf("%s: %s\n",name,$0); 1.98 + }' 1.99 + done 1.100 +} 1.101 + 1.102 +################### 1.103 +# Tazpkg commands # 1.104 +################### 1.105 + 1.106 +case "$COMMAND" in 1.107 + build) 1.108 + # Create files.list.lzma to stdout. 1.109 + # 1.110 + mkdir $TMP_DIR 1.111 + build_database | lzma e -si -so 1.112 + rm -rf $TMP_DIR 1.113 + ;; 1.114 + recharge) 1.115 + # Recharge files.list.lzma from a mirror. 1.116 + # 1.117 + cd $LOCALSTATE 1.118 + echo "" 1.119 + mv -f $FILES_LIST $FILES_LIST.old 2> /dev/null 1.120 + download $(basename $FILES_LIST) 1.121 + ;; 1.122 + search) 1.123 + # Search for a file by pattern or name in files.list.lzma. 1.124 + # 1.125 + check_for_files_list_lzma 1.126 + while [ -n "$2" ]; do 1.127 + unlzma -c $FILES_LIST | \ 1.128 + grep -i -- "$2$" | while read line; do 1.129 + pkg=${line%:*} 1.130 + if [ -d $INSTALLED/$pkg ]; then 1.131 + echo -n "[already installed] " 1.132 + fi 1.133 + echo "$line" 1.134 + done 1.135 + shift 1.136 + done 1.137 + ;; 1.138 + usage|*) 1.139 + # Print a short help or give usage for an unknown or empty command. 1.140 + # 1.141 + usage 1.142 + ;; 1.143 +esac