slitaz-base-files 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 | e22ca9050ae8 |
children | cd043522cb43 |
files | rootfs/etc/slitaz/slitaz.conf rootfs/usr/lib/slitaz/libtaz rootfs/usr/lib/slitaz/libtaz-modules/commons |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/rootfs/etc/slitaz/slitaz.conf Thu Apr 12 14:05:36 2012 +0000 1.3 @@ -0,0 +1,122 @@ 1.4 +######################################################################## 1.5 +# This is the generic SliTaz configuration file used by libtaz to get 1.6 +# the default options and directories. 1.7 +# 1.8 +# These variables can be overwritten by a lower level of configuration. 1.9 +# Order for loading variables (the latest definition is kept) : 1.10 +# slitaz.conf (then) main app.conf (or) local app.conf 1.11 +# (or) *.conf of the command line (then) arguments of the command line 1.12 +# 1.13 +# ** Alpha Comment by GoKhlaYeh: ** 1.14 +# With libtaz, I plan to change the default location of some important 1.15 +# directories to fit the server hierarchy. In a general view I want 1.16 +# to make the organisation on the server and on a released system similar. 1.17 +# The goal is having tools working out-of-the-box in both cases to make 1.18 +# the contributors work easier and efficient. 1.19 +# These changes will takes place with a Release Candidate, when libtaz 1.20 +# implementation in all SliTaz tools will be finalised, and all code fully 1.21 +# reviewed. Hope everybody agree with that ;). 1.22 +# 1.23 + 1.24 +######################################################################## 1.25 +# COMMON DIRECTORIES 1.26 +######################## 1.27 + 1.28 +# Slitaz logs directory. 1.29 +SLITAZ_LOG="/var/log/slitaz" 1.30 + 1.31 +# Slitaz version. 1.32 +SLITAZ_VERSION="$(cat /etc/slitaz-release)" 1.33 + 1.34 +# Slitaz directory. 1.35 +SLITAZ_DIR="/home/slitaz" 1.36 + 1.37 +# Local repository for current version (can contain local packages 1.38 +# repository, wok, sources, ...). 1.39 +LOCAL_REPOSITORY="$SLITAZ_DIR/$SLITAZ_VERSION" 1.40 + 1.41 +# base url mirror 1.42 +BASE_MIRROR="http://mirror.slitaz.org" 1.43 + 1.44 +# Online packages repository. 1.45 +ONLINE_REPOSITORY="$BASE_MIRROR/packages/$SLITAZ_VERSION/" 1.46 + 1.47 +# Source tarball mirror 1.48 +ONLINE_SRC_REPOSITORY="$BASE_MIRROR/sources/packages/" 1.49 + 1.50 +# Packages cache directory. 1.51 +CACHE_DIR="/var/cache/tazpkg" 1.52 + 1.53 +# Path to repository data. 1.54 +LOCALSTATE="/var/lib/tazpkg" 1.55 + 1.56 +# Path to installation data. 1.57 +INSTALLED="$LOCALSTATE/installed" 1.58 + 1.59 +# Path to slitaz mirror data. 1.60 +MIRROR_DIR="/var/www/slitaz/mirror" 1.61 + 1.62 +# tazpkg-web variables 1.63 + 1.64 +# Path to xHTML and XML templates. 1.65 +LIB_DIR="/var/lib/tazpkg-web" 1.66 + 1.67 +# Path to the Web interface. 1.68 +WEB_INTERFACE="$SLITAZ_DIR/www/pkgs" 1.69 + 1.70 +# Path to each version. 1.71 +STABLE="$SLITAZ_DIR/stable" 1.72 +COOKING="$SLITAZ_DIR/cooking" 1.73 + 1.74 +######################################################################## 1.75 +# COMMON VARIABLES 1.76 +######################## 1.77 + 1.78 +# the type of checksum and ext for packages.md5-like file 1.79 +# md5sum : default (but weak) 1.80 +# sha1sum 1.81 +# sha256sum 1.82 +# sha512sum 1.83 + 1.84 +CHECKSUM="md5sum" 1.85 +SUM="${CHECKSUM/sum}" 1.86 + 1.87 +# Packages categories. 1.88 +CATEGORIES=" 1.89 +base-system 1.90 +x-window 1.91 +utilities 1.92 +network 1.93 +graphics 1.94 +multimedia 1.95 +office 1.96 +development 1.97 +system-tools 1.98 +security 1.99 +games 1.100 +misc 1.101 +meta 1.102 +non-free" 1.103 + 1.104 + 1.105 +######################################################################## 1.106 +# LIBTAZ OPTIONS 1.107 +######################## 1.108 +# These options are the default settings for all SliTaz tools which use 1.109 +# libtaz. They are : 1.110 +# * tazwok 1.111 +# * tazpkg 1.112 + 1.113 +# If this option is enabled - automatically install needed packages. It 1.114 +# can be depends, build_depends, or package needed to perform a specific 1.115 +# task. 1.116 +# Value can be : 1.117 +# * yes = enabled 1.118 +# * anything else = disabled 1.119 +auto_install=yes 1.120 + 1.121 +# If you want to log all operations (into /var/log/slitaz), 1.122 +# uncomment the following line 1.123 +# Note: all important operations are logged by default. 1.124 +#report_log_all=yes 1.125 +
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/rootfs/usr/lib/slitaz/libtaz Thu Apr 12 14:05:36 2012 +0000 2.3 @@ -0,0 +1,98 @@ 2.4 +######################################################################## 2.5 +# This is the SliTaz main library (/usr/lib/slitaz/libtaz). 2.6 +# libtaz is modular : see explanation of the function source_lib below. 2.7 +# 2.8 +# Author : Antoine Bodin <gokhlayeh@mailoo.org> 2.9 +# 2.10 +# Version : 0.0.1 (alpha1) 2.11 +# 2.12 +# Documentation : none (will be available with beta version) 2.13 +# The documentation will include an explanation of all functions, how to 2.14 +# use them and how to improve this library. 2.15 +# 2.16 +# Devnotes (suppress while beta is released) : 2.17 +# Add a generic download script ? -> download from tazlito & tazwok 2.18 +# Add a generic create/cleanup script for tmp files ? 2.19 +# check_for (pkg on cmd line, pkg, receipt, etc.) -> tazwok,tazpkg,list 2.20 +# 2.21 +# Note: as the work is in progress some parts are dirty code or others 2.22 +# are not finished. I will update this because we need the libdep. 2.23 +# 2.24 +######################################################################## 2.25 +# INITIALIZATION 2.26 +######################## 2.27 +# Load the Slitaz main configuration file : /etc/slitaz/slitaz.conf. 2.28 +# Don't load it if an application is called by one already, 2.29 +# to avoid options overwrite. 2.30 + 2.31 +. /etc/slitaz/slitaz.conf 2.32 + 2.33 +# Load the command as some modules use it. 2.34 +log_command="$0 $@" 2.35 + 2.36 +# Define & create a temporary directory as it's used by report. 2.37 +tmp=/tmp/$(basename $0)-$$ 2.38 +mkdir -p $tmp 2.39 + 2.40 +######################################################################## 2.41 +# EXIT FUNCTIONS 2.42 +######################## 2.43 +# run_on_exit commands are executed when apps exit (whatever the reason) 2.44 +# run_on_kill commands are executed only when apps are killed (or Ctrl+C) 2.45 +# Note : one command per line in the variable. 2.46 +run_on_exit="rm -rf $tmp" 2.47 +run_on_kill="" 2.48 +trap run_on_exit EXIT 2.49 +trap run_on_kill INT KILL 2.50 + 2.51 +run_on_exit() 2.52 +{ 2.53 + echo "$run_on_exit" | while read c; do 2.54 + run_on_exit=$(echo "$run_on_exit" | sed 1d) 2.55 + $c 2.56 + done 2.57 + trap - EXIT 2.58 + exit 2.59 +} 2.60 + 2.61 +run_on_kill() 2.62 +{ 2.63 + echo "$run_on_kill" | while read c; do 2.64 + run_on_kill=$(echo "$run_on_kill" | sed 1d) 2.65 + $c 2.66 + done 2.67 + trap - INT KILL 2.68 + run_on_exit 2.69 +} 2.70 + 2.71 +######################################################################## 2.72 +# This function should be used after sourcing libtaz to source modular 2.73 +# libraries. Libtaz only sources main configuration files and contains only 2.74 +# this function. The modular libraries should be put in the slitaz lib 2.75 +# directory (/usr/lib/slitaz/libtaz-modules). 2.76 +# 2.77 +# Usage : source_lib lib [lib2] [lib3] ... 2.78 +# 2.79 +# Description of libraries included with libtaz : 2.80 +# commons : functions used by most SliTaz scripts 2.81 +# get_option* : function to check & parse arguments of a command line 2.82 +# report : display and log scripts in a configurable way 2.83 +# 2.84 +# * needs a code review, please don't use them for production : code can 2.85 +# be hardly modified. 2.86 +# 2.87 +# All these libraries contains additional functions. Check them to 2.88 +# know which ones and how to use them. 2.89 +# More information will be available at beta release. 2.90 + 2.91 +sourced_lib="" 2.92 +source_lib() 2.93 +{ 2.94 + for i in $@; do 2.95 + [ "$(echo $sourced_lib | grep $i)" ] && continue 2.96 + [ ! -f "/usr/lib/slitaz/libtaz-modules/$i" ] && \ 2.97 + echo "WARNING: libtaz source_lib: can't find /usr/lib/slitaz/libtaz-modules/$i" >&2 && \ 2.98 + continue 2.99 + . /usr/lib/slitaz/libtaz-modules/$i && sourced_lib="$sourced_lib $i" 2.100 + done 2.101 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/rootfs/usr/lib/slitaz/libtaz-modules/commons Thu Apr 12 14:05:36 2012 +0000 3.3 @@ -0,0 +1,84 @@ 3.4 +status() 3.5 +{ 3.6 + local CHECK=$? 3.7 + echo -en "\\033[70G[ " 3.8 + if [ $CHECK = 0 ]; then 3.9 + echo -en "\\033[1;32mOK" 3.10 + else 3.11 + echo -en "\\033[1;31mFailed" 3.12 + fi 3.13 + echo -e "\\033[0;39m ]" 3.14 +} 3.15 + 3.16 +get_config() 3.17 +{ 3.18 + if [ -f "./`basename $0`.conf" ]; then 3.19 + . ./`basename $0`.conf 3.20 + elif [ -f "/etc/slitaz/`basename $0`.conf" ]; then 3.21 + . /etc/slitaz/`basename $0`.conf 3.22 + else 3.23 + echo -e "\nUnable to find the configuration file : /etc/slitaz/`basename $0`.conf" >&2 3.24 + echo -e "Please read the `basename $0` documentation.\n" >&2 3.25 + exit 1 3.26 + fi 3.27 +} 3.28 + 3.29 +# The classic SliTaz check_root function used in nearly all SliTaz tools. 3.30 +check_root() 3.31 +{ 3.32 + [ $(id -u) = 0 ] && return 3.33 + echo -e "\nYou must be root to run `basename $0` with this option." >&2 3.34 + echo -e "Please type 'su' and root password to become super-user.\n" >&2 3.35 + exit 1 3.36 +} 3.37 + 3.38 +# A classic check_dir function: - create directory if needed and echo about it. 3.39 +# Return error if directory is created (to chain other commands with ||) 3.40 +check_dir() 3.41 +{ 3.42 + if ! [ -d "$1" ]; then 3.43 + echo -n "Creating $1..." 3.44 + mkdir -p "$1" 3.45 + status 3.46 + return 1 3.47 + fi 3.48 +} 3.49 + 3.50 +# Install package if missing. 3.51 +check_pkg() 3.52 +{ 3.53 + if ! [ -d $INSTALLED/$1 ]; then 3.54 +# report step "Installing package : $1" 3.55 + tazpkg get-install $1 3.56 +# report end-step 3.57 + fi 3.58 +} 3.59 + 3.60 +# Display a horizontal line, can be used for a clearer script. 3.61 +horizontal_line() 3.62 +{ 3.63 + echo "================================================================================" 3.64 +} 3.65 + 3.66 +# Store -- options in a variable. 3.67 +# Test phase. 3.68 +# Need to add something to filter options and report errors in case option is not 3.69 +# listed and used by the command. 3.70 +get_options() 3.71 +{ 3.72 + if echo "$log_command" | fgrep -q ' '--help; then 3.73 + echo "Available options for $(echo `basename "$log_command"` | cut -d ' ' -f 1,2) : $get_options_list" 3.74 + exit 0 3.75 + fi 3.76 + for get_option in $(echo "$log_command" | tr ' ' '\n' | grep ^-- | sed 's/^--//'); do 3.77 + if [ "${get_options_list/${get_option%%=*}}" = "$get_options_list" ]; then 3.78 + echo "Option ${get_option%%=*} is incorrect, valid options are : $get_options_list". >&2 3.79 + exit 1 3.80 + fi 3.81 + if [ "$get_option" = "${get_option/=}" ]; then 3.82 + export $get_option=yes 3.83 + else 3.84 + export $get_option 3.85 + fi 3.86 + done 3.87 +}