slitaz-base-files annotate rootfs/usr/lib/slitaz/libtaz @ rev 123
Add libtaz minus report module. I added config options for tazpkg-web in slitaz.conf. Also added a BASE_MIRROR variable so it can be changed.
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Thu Apr 12 14:05:36 2012 +0000 (2012-04-12) |
parents | |
children |
rev | line source |
---|---|
slaxemulator@123 | 1 ######################################################################## |
slaxemulator@123 | 2 # This is the SliTaz main library (/usr/lib/slitaz/libtaz). |
slaxemulator@123 | 3 # libtaz is modular : see explanation of the function source_lib below. |
slaxemulator@123 | 4 # |
slaxemulator@123 | 5 # Author : Antoine Bodin <gokhlayeh@mailoo.org> |
slaxemulator@123 | 6 # |
slaxemulator@123 | 7 # Version : 0.0.1 (alpha1) |
slaxemulator@123 | 8 # |
slaxemulator@123 | 9 # Documentation : none (will be available with beta version) |
slaxemulator@123 | 10 # The documentation will include an explanation of all functions, how to |
slaxemulator@123 | 11 # use them and how to improve this library. |
slaxemulator@123 | 12 # |
slaxemulator@123 | 13 # Devnotes (suppress while beta is released) : |
slaxemulator@123 | 14 # Add a generic download script ? -> download from tazlito & tazwok |
slaxemulator@123 | 15 # Add a generic create/cleanup script for tmp files ? |
slaxemulator@123 | 16 # check_for (pkg on cmd line, pkg, receipt, etc.) -> tazwok,tazpkg,list |
slaxemulator@123 | 17 # |
slaxemulator@123 | 18 # Note: as the work is in progress some parts are dirty code or others |
slaxemulator@123 | 19 # are not finished. I will update this because we need the libdep. |
slaxemulator@123 | 20 # |
slaxemulator@123 | 21 ######################################################################## |
slaxemulator@123 | 22 # INITIALIZATION |
slaxemulator@123 | 23 ######################## |
slaxemulator@123 | 24 # Load the Slitaz main configuration file : /etc/slitaz/slitaz.conf. |
slaxemulator@123 | 25 # Don't load it if an application is called by one already, |
slaxemulator@123 | 26 # to avoid options overwrite. |
slaxemulator@123 | 27 |
slaxemulator@123 | 28 . /etc/slitaz/slitaz.conf |
slaxemulator@123 | 29 |
slaxemulator@123 | 30 # Load the command as some modules use it. |
slaxemulator@123 | 31 log_command="$0 $@" |
slaxemulator@123 | 32 |
slaxemulator@123 | 33 # Define & create a temporary directory as it's used by report. |
slaxemulator@123 | 34 tmp=/tmp/$(basename $0)-$$ |
slaxemulator@123 | 35 mkdir -p $tmp |
slaxemulator@123 | 36 |
slaxemulator@123 | 37 ######################################################################## |
slaxemulator@123 | 38 # EXIT FUNCTIONS |
slaxemulator@123 | 39 ######################## |
slaxemulator@123 | 40 # run_on_exit commands are executed when apps exit (whatever the reason) |
slaxemulator@123 | 41 # run_on_kill commands are executed only when apps are killed (or Ctrl+C) |
slaxemulator@123 | 42 # Note : one command per line in the variable. |
slaxemulator@123 | 43 run_on_exit="rm -rf $tmp" |
slaxemulator@123 | 44 run_on_kill="" |
slaxemulator@123 | 45 trap run_on_exit EXIT |
slaxemulator@123 | 46 trap run_on_kill INT KILL |
slaxemulator@123 | 47 |
slaxemulator@123 | 48 run_on_exit() |
slaxemulator@123 | 49 { |
slaxemulator@123 | 50 echo "$run_on_exit" | while read c; do |
slaxemulator@123 | 51 run_on_exit=$(echo "$run_on_exit" | sed 1d) |
slaxemulator@123 | 52 $c |
slaxemulator@123 | 53 done |
slaxemulator@123 | 54 trap - EXIT |
slaxemulator@123 | 55 exit |
slaxemulator@123 | 56 } |
slaxemulator@123 | 57 |
slaxemulator@123 | 58 run_on_kill() |
slaxemulator@123 | 59 { |
slaxemulator@123 | 60 echo "$run_on_kill" | while read c; do |
slaxemulator@123 | 61 run_on_kill=$(echo "$run_on_kill" | sed 1d) |
slaxemulator@123 | 62 $c |
slaxemulator@123 | 63 done |
slaxemulator@123 | 64 trap - INT KILL |
slaxemulator@123 | 65 run_on_exit |
slaxemulator@123 | 66 } |
slaxemulator@123 | 67 |
slaxemulator@123 | 68 ######################################################################## |
slaxemulator@123 | 69 # This function should be used after sourcing libtaz to source modular |
slaxemulator@123 | 70 # libraries. Libtaz only sources main configuration files and contains only |
slaxemulator@123 | 71 # this function. The modular libraries should be put in the slitaz lib |
slaxemulator@123 | 72 # directory (/usr/lib/slitaz/libtaz-modules). |
slaxemulator@123 | 73 # |
slaxemulator@123 | 74 # Usage : source_lib lib [lib2] [lib3] ... |
slaxemulator@123 | 75 # |
slaxemulator@123 | 76 # Description of libraries included with libtaz : |
slaxemulator@123 | 77 # commons : functions used by most SliTaz scripts |
slaxemulator@123 | 78 # get_option* : function to check & parse arguments of a command line |
slaxemulator@123 | 79 # report : display and log scripts in a configurable way |
slaxemulator@123 | 80 # |
slaxemulator@123 | 81 # * needs a code review, please don't use them for production : code can |
slaxemulator@123 | 82 # be hardly modified. |
slaxemulator@123 | 83 # |
slaxemulator@123 | 84 # All these libraries contains additional functions. Check them to |
slaxemulator@123 | 85 # know which ones and how to use them. |
slaxemulator@123 | 86 # More information will be available at beta release. |
slaxemulator@123 | 87 |
slaxemulator@123 | 88 sourced_lib="" |
slaxemulator@123 | 89 source_lib() |
slaxemulator@123 | 90 { |
slaxemulator@123 | 91 for i in $@; do |
slaxemulator@123 | 92 [ "$(echo $sourced_lib | grep $i)" ] && continue |
slaxemulator@123 | 93 [ ! -f "/usr/lib/slitaz/libtaz-modules/$i" ] && \ |
slaxemulator@123 | 94 echo "WARNING: libtaz source_lib: can't find /usr/lib/slitaz/libtaz-modules/$i" >&2 && \ |
slaxemulator@123 | 95 continue |
slaxemulator@123 | 96 . /usr/lib/slitaz/libtaz-modules/$i && sourced_lib="$sourced_lib $i" |
slaxemulator@123 | 97 done |
slaxemulator@123 | 98 } |