# HG changeset patch # User Aleksej Bobylev # Date 1437832218 -10800 # Node ID f7e9a5b8477be0af590b1a0a4f654ae16a69efc7 # Parent e1399e7ca7ff8736ea13877566105ae3e20b5c43 Add README.devel; introduce libexec for modules; rename modules; support install variables in Makefile. diff -r e1399e7ca7ff -r f7e9a5b8477b Makefile --- a/Makefile Fri Jul 24 17:13:16 2015 +0200 +++ b/Makefile Sat Jul 25 16:50:18 2015 +0300 @@ -1,13 +1,21 @@ # Makefile for TazPkg. # -PREFIX?=/usr -DOCDIR?=$(PREFIX)/share/doc -SYSCONFDIR?=/etc/slitaz +prefix?=/usr +exec_prefix?=$(prefix) +bindir?=$(exec_prefix)/bin +libexecdir?=$(exec_prefix)/libexec +datarootdir?=$(prefix)/share +sysconfdir?=/etc +docdir?=$(datarootdir)/doc/tazpkg +libdir?=$(exec_prefix)/lib +localedir?=$(datarootdir)/locale +iconsdir?=$(datarootdir)/icons + DESTDIR?= LINGUAS?=el es fr pl pt_BR ru sv zh_CN zh_TW -VERSION:=$(shell grep ^VERSION=[0-9] tazpkg | cut -d '=' -f 2) -ICONS = $(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32 +VERSION:=$(shell grep ^VERSION=[0-9] tazpkg | cut -d'=' -f2) +ICONS = $(DESTDIR)$(iconsdir)/hicolor/32x32 tmpdir = tar-install/tazpkg-$(VERSION) tarball = tazpkg-$(VERSION).tar.gz @@ -21,8 +29,9 @@ xgettext -o po/tazpkg.pot -L Shell \ --package-name=TazPkg \ --package-version="$(VERSION)" -kaction -ktitle -k_ -k_n -k_p:1,2 \ - ./tazpkg ./modules/tazpkg-convert ./modules/tazpkg-find-depends ./tazpkg-box \ - ./tazpanel/pkgs.cgi ./tazpkg-notify ./modules/tazpkg-help + ./tazpkg \ + ./modules/convert ./modules/find-depends ./modules/help \ + ./tazpkg-box ./tazpkg-notify ./tazpanel/pkgs.cgi msgmerge: @for l in $(LINGUAS); do \ @@ -48,25 +57,27 @@ install: msgfmt # TazPkg command line interface - install -m 0755 -d $(DESTDIR)$(PREFIX)/bin - install -m 0777 tazpkg $(DESTDIR)$(PREFIX)/bin - #-[ "$(VERSION)" ] && sed -i 's/^VERSION=[0-9].*/VERSION=$(VERSION)/' $(DESTDIR)$(PREFIX)/bin/tazpkg - install -m 0777 modules/tazpkg-convert $(DESTDIR)$(PREFIX)/bin - install -m 0777 modules/tazpkg-help $(DESTDIR)$(PREFIX)/bin - install -m 0755 -d $(DESTDIR)$(PREFIX)/lib/tazpkg - install -m 0777 modules/tazpkg-find-depends $(DESTDIR)$(PREFIX)/lib/tazpkg + install -m 0755 -d $(DESTDIR)$(bindir) + install -m 0755 tazpkg $(DESTDIR)$(bindir) + + # TazPkg modules + install -m 0755 -d $(DESTDIR)$(libexecdir)/tazpkg + install -m 0755 modules/* $(DESTDIR)$(libexecdir)/tazpkg + # Substitute "@@MODULES@@" with modules path + sed -i "s|@@MODULES@@|$(libexecdir)/tazpkg|g" $(DESTDIR)$(bindir)/tazpkg + sed -i "s|@@MODULES@@|$(libexecdir)/tazpkg|g" $(DESTDIR)$(libexecdir)/tazpkg/convert # TazPkg-box GUI - install -m 0777 tazpkg-notify $(DESTDIR)$(PREFIX)/bin - install -m 0777 tazpkg-box $(DESTDIR)$(PREFIX)/bin + install -m 0777 tazpkg-notify $(DESTDIR)$(bindir) + install -m 0777 tazpkg-box $(DESTDIR)$(bindir) # Configuration files - install -m 0755 -d $(DESTDIR)$(SYSCONFDIR) - install -m 0644 tazpkg.conf $(DESTDIR)$(SYSCONFDIR) + install -m 0755 -d $(DESTDIR)$(sysconfdir)/slitaz + install -m 0644 tazpkg.conf $(DESTDIR)$(sysconfdir)/slitaz # Documentation - install -m 0755 -d $(DESTDIR)$(DOCDIR)/tazpkg - cp -a doc/* $(DESTDIR)$(DOCDIR)/tazpkg + install -m 0755 -d $(DESTDIR)$(docdir) + cp -a doc/* $(DESTDIR)$(docdir) # TazPanel files install -m 0755 -d $(DESTDIR)/var/www/tazpanel/menu.d @@ -76,13 +87,13 @@ install -m 0644 tazpanel/pkgs.css $(DESTDIR)/var/www/tazpanel/styles/default # The i18n files - install -m 0755 -d $(DESTDIR)$(PREFIX)/share/locale - cp -a po/mo/* $(DESTDIR)$(PREFIX)/share/locale + install -m 0755 -d $(DESTDIR)$(localedir) + cp -a po/mo/* $(DESTDIR)$(localedir) # Desktop integration - mkdir -p $(DESTDIR)$(PREFIX)/share - cp -a applications $(DESTDIR)$(PREFIX)/share - #cp -a mime $(DESTDIR)$(PREFIX)/share # moved to shared-mime-info package + install -m 0755 -d $(DESTDIR)$(datarootdir)/applications + install -m 0644 applications/*.desktop $(DESTDIR)$(datarootdir)/applications + #cp -a mime $(DESTDIR)$(datarootdir) # moved to shared-mime-info package # Default icons install -m 0755 -d $(ICONS)/apps @@ -94,37 +105,40 @@ ln -fs tazpkg.png $(ICONS)/apps/TazPkg.png # icon for Yad # TazPkg Notify XDG autostart - mkdir -p $(DESTDIR)/etc/xdg - cp -a xdg/autostart $(DESTDIR)/etc/xdg + mkdir -p $(DESTDIR)$(sysconfdir)/xdg + cp -a xdg/autostart $(DESTDIR)$(sysconfdir)/xdg # Uninstallation and clean-up commands. uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/tazpkg - rm -f $(DESTDIR)$(PREFIX)/bin/tazpkg-convert - rm -f $(DESTDIR)$(PREFIX)/lib/tazpkg/tazpkg-find-depends + rm -f $(DESTDIR)$(bindir)/tazpkg + rm -f $(DESTDIR)$(libexecdir)/tazpkg/convert + rm -f $(DESTDIR)$(libexecdir)/tazpkg/find-depends + rm -f $(DESTDIR)$(libexecdir)/tazpkg/help - rm -f $(DESTDIR)$(PREFIX)/bin/tazpkg-notify - rm -f $(DESTDIR)$(PREFIX)/bin/tazpkg-box + rm -f $(DESTDIR)$(bindir)/tazpkg-notify + rm -f $(DESTDIR)$(bindir)/tazpkg-box - rm -f $(DESTDIR)$(SYSCONFDIR)/tazpkg.conf + rm -f $(DESTDIR)$(sysconfdir)/slitaz/tazpkg.conf - rm -rf $(DESTDIR)$(DOCDIR)/tazpkg + rm -rf $(DESTDIR)$(docdir)/tazpkg*.html + rm $(DESTDIR)$(docdir) rm -f $(DESTDIR)/var/www/tazpanel/pkgs.cgi rm -f $(DESTDIR)/var/www/tazpanel/menu.d/pkgs + rm -f $(DESTDIR)/var/www/tazpanel/styles/default/pkgs.css - rm -rf $(DESTDIR)$(PREFIX)/share/locale/*/LC_MESSAGES/tazpkg.mo + rm -rf $(DESTDIR)$(localedir)/*/LC_MESSAGES/tazpkg.mo - rm -f $(DESTDIR)$(PREFIX)/share/applications/tazpkg-*.desktop - rm -f $(DESTDIR)$(PREFIX)/share/applications/tazpanel-pkgs.desktop + rm -f $(DESTDIR)$(datarootdir)/applications/tazpkg-*.desktop + rm -f $(DESTDIR)$(datarootdir)/applications/tazpanel-pkgs.desktop rm -f $(ICONS)/apps/tazpkg.png rm -f $(ICONS)/actions/tazpkg-up.png rm -f $(ICONS)/status/tazpkg-installed.png - rm -f $(DESTDIR)/etc/xdg/autostart/tazpkg-notify.desktop + rm -f $(DESTDIR)$(sysconfdir)/xdg/autostart/tazpkg-notify.desktop clean: @@ -142,7 +156,7 @@ make DESTDIR=${tmpdir} install cd tar-install ; \ - tar cvzf ${tarball} tazpkg-$(VERSION) ; \ + tar -cvzf ${tarball} tazpkg-$(VERSION) ; \ cd - @echo "** Tarball successfully created in tar-install/${tarball}" diff -r e1399e7ca7ff -r f7e9a5b8477b README.devel --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.devel Sat Jul 25 16:50:18 2015 +0300 @@ -0,0 +1,107 @@ +README file for TazPkg developers +================================= + + +Desktop integration +------------------- + +mimeapps.list: this file deprecated and not installed +https://wiki.archlinux.org/index.php/Default_applications +(Also, defaults.list deprecated.) + +MIME-type "x-scheme-handler/tazpkg" already listed in the tazpkg-url.desktop + + +Categories for .desktop files are listed here: +http://standards.freedesktop.org/menu-spec/menu-spec-1.0.html + +tazpanel-pkgs.desktop: sub-category PackageManager -> category Settings + + +TazPkg modules +-------------- + +About 4,000 lines of code is too big to effectively maintain it in single file. + +Linux way [https://en.wikibooks.org/wiki/Linux_Guide/How_Linux_Works]: +> The Linux Way can be summarized as: +> * Use programs that do only one task, but do it well. +> * To accomplish complex tasks, use several programs linked together. +> * Store information in human-readable plain text files whenever it is +> possible. +> * There is no "one true way" to do anything. +> * Prefer commandline tools over graphical tools. + +It decided to split single tazpkg code into few independent modules. + +Goals: not to scroll thousand of lines to move forth and back to the internal +tazpkg functions and to the main tazpkg code; knowledge that single code +changing in the one place will not have side effect in the other place; reduce +the barrier to entry for new developers. + + +Place best fit tazpkg modules is /usr/libexec directory. +http://www.linuxbase.org/betaspecs/fhs/fhs/ch04s07.html + +> /usr/libexec includes internal binaries that are not intended to be executed +> directly by users or shell scripts. Applications may use a single subdirectory +> under /usr/libexec. + +> Applications which use /usr/libexec in this way must not also use /usr/lib to +> store internal binaries, though they may use /usr/lib for the other purposes +> documented here. + +So, directory for tazpkg modules is /usr/libexec/tazpkg/. +It is out of the PATH, so modules will not interfere with original Linux +commands and will not autocomplete in the terminal. Nothing changed with the +user experience: it is still single tazpkg. + + +To execute module we need to know full path to the module. +We can use simple names for modules such as "help", "convert", "list", etc. + + +Directory variables +------------------- + +Many programs can be configured using variables such as prefix, docdir, etc.: + make prefix=/usr install + +All variables are in lower case (only DESTDIR is in upper case). See more here: +https://www.gnu.org/prep/standards/html_node/Directory-Variables.html + +Makefile contains variables support with default values. +Default prefix=/usr, all other variables are defaults to values described +at the given link. + + +Code commenting +--------------- + +Developer comments are very important to understand how program works. +But that comments are useless to the end user and they just increase the size +of the scripts without making any changes to the script business logic. It also +increase the size of the scripts that includes shared "libs" such as libtaz.sh. + +We can strip all the comments from installed scripts, leaving that comments +for developers in the SliTaz Hg repositories. + +We need only to leave "#!/bin/sh" line and one-two lines of comments described +what it is and where you can find the original scripts if you want to develop +them. + + +Tests +----- + +Tests are the important part of the development process. TazPkg development is +not easy. We have no automated tests at the moment. Only we can do manual tests, +but we even have no check-list. + +To test tazpkg effectively we need two sorts of the tests. One set of the tests +we can reproduce in the local file system (inside special prepared chroot +environment). For other tests we need special test-server that provide special +test cases (emulate package database changes), also provide both main and few +undigest repositories. We can set up special scripts and test repository on the +existing server (cook.slitaz.org). + diff -r e1399e7ca7ff -r f7e9a5b8477b applications/tazpanel-pkgs.desktop --- a/applications/tazpanel-pkgs.desktop Fri Jul 24 17:13:16 2015 +0200 +++ b/applications/tazpanel-pkgs.desktop Sat Jul 25 16:50:18 2015 +0300 @@ -8,4 +8,4 @@ TryExec=tazweb Exec=sh -c 'W=$HOME/.config/slitaz/subox.conf;[ -f $W ]||subox -;tazweb root:$(head $W)@127.0.0.1:82/user/pkgs.cgi' Icon=tazpkg -Categories=Settings;System;PackageManager; +Categories=Settings;PackageManager; diff -r e1399e7ca7ff -r f7e9a5b8477b modules/convert --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/convert Sat Jul 25 16:50:18 2015 +0300 @@ -0,0 +1,750 @@ +#!/bin/sh + +# This program is a part of TazPkg. +# /usr/bin/tazpkg-convert: toolset to convert alien package to the tazpkg format + +# Usage: tazpkg-convert alien_package [ target_directory ] + + +PACKAGE_FILE="$1" +TARGET_DIR="$2" +TMP_DIR=$(mktemp -d) +TOP_DIR="$(pwd)" + +. /etc/slitaz/slitaz.conf +. /lib/libtaz.sh +. @@MODULES@@/find-depends + +# Internationalization. +export TEXTDOMAIN='tazpkg' + + +# FIXME: what does this mean? +[ -n "$TARGET_DIR" -a -s "$TARGET_DIR/files.list.lzma" ] && TMPLOCALSTATE="$TARGET_DIR" + + +show_unresolved_lib() { + if [ -s "$TMP_DIR/unresolved" ]; then + echo -e "BUGS=\"$(_n 'No dependency for:')" >> $1 + sort < $TMP_DIR/unresolved | uniq | \ + while read file; do + _ 'WARNING: unknown dependency for %s' "$lib" + echo -n " $file" >> $1 + done + echo "\"" >> $1 + fi +} + + +# convert a .tar.bz2 package to .tazpkg + +convert_upkg() { + mkdir -p $TMP_DIR/fs + tar -xjf "$PACKAGE_FILE" -C $TMP_DIR/fs + if [ -d "$TMP_DIR/fs/var/lib/upkg/packages" ]; then + cd $TMP_DIR + package="$(sed '/^Package:/!d;s/.*: //' fs/var/lib/upkg/packages/*.info)" + version="$(sed '/^Version:/!d;s/.*: //' fs/var/lib/upkg/packages/*.info)" + url='http://www.paldo.org/' + file="$package-$version" + mkdir $file + mv fs $file + maintainer='nobody@slitaz.org' + descrip="$package package from paldo." + cat > $file/receipt <> $file/receipt <> $file/receipt < $file/receipt <> $file/receipt <> $file/receipt < $file/receipt <> $file/receipt <> $file/receipt < $file/description.txt + sed -i 's/^\.$//' $file/description.txt + [ -s $file/description.txt ] || rm -f $file/description.txt + tazpkg pack $file + cd $TOP_DIR + mv $TMP_DIR/$file.tazpkg . + ;; + *) + _ 'Invalid target: %s (expected i386)' "$target" + ;; + esac + rm -rf $TMP_DIR +} + + +# convert a .cards.tar.xz package to .tazpkg + +convert_nutyx() { + mkdir -p $TMP_DIR/fs + busybox tar -xf "$PACKAGE_FILE" -C $TMP_DIR/fs + if [ -f "$TMP_DIR/fs/.META" ]; then + package="$(sed '/^N/!d;s/^.//' fs/.META)" + version="$(sed '/^V/!d;s/^.//' fs/.META)" + descrip="$(sed '/^D/!d;s/^.//' fs/.META)" + file="$package-$version" + mkdir $file + mv fs $file + cat > $file/receipt < $file/receipt < $file/receipt <> $file/receipt </dev/null + . $package*/*.specs + desc="$PETMENUDESCR" + mv $package*/ fs + finish_convert_puppy +} + + +# convert a .sb package to .tazpkg + +convert_sb() { + [ -n "$(which unsquashfs)" ] || tazpkg get-install squashfs + if ! unsquashfs -l "$PACKAGE_FILE" | grep -q squashfs-root/var/log/removed_scripts ; then + _ 'File "%s" does not look like %s package!' "$PACKAGE_FILE" 'Slax' + return 1 + fi + mkdir -p $TMP_DIR + cd $TMP_DIR + unsquashfs "$PACKAGE_FILE" + mv squashfs-root fs + parse_pkgname '' $(cat fs/var/log/packages/* | sed '/PACKAGE NAME:/!d;s/.*: *//') + desc="$(cat fs/var/log/packages/* | sed '/^PACKAGE DESCRIPTION:/,$!d;N;s/.*: //;q')" + cat fs/var/log/packages/* | sed '/^PACKAGE DESCRIPTION:/,/FILE LIST/!d;s/.*://;/^$/d' > $file/description.txt + mv fs $file + cat > $file/receipt <> $file/receipt < $file/receipt <> $file/receipt < $file/description.txt + [ -s "$file/description.txt" ] || rm -f $file/description.txt + rm -rf $file/fs/install + tazpkg pack $file + mv $file.tazpkg $TOP_DIR + else + _ 'File "%s" does not look like %s package!' "$PACKAGE_FILE" 'Slackware' + fi + cd $TOP_DIR + rm -rf $TMP_DIR +} + + +# convert a .deb package to .tazpkg + +convert_deb() { + mkdir -p $TMP_DIR + dpkg-deb -e "$PACKAGE_FILE" $TMP_DIR + package=$(sed '/^ *Package:/!d;s/.*: //' $TMP_DIR/control) + version=$(sed '/^ *Version:/!d;s/.*: //' $TMP_DIR/control) + descrip=$(sed '/^ *Description:/!d;s/.*: //' $TMP_DIR/control) + homepage=$(sed '/^ *Homepage:/!d;s/.*: //' $TMP_DIR/control) + target="$(sed '/^ *Architecture:/!d;s/.*: //' $TMP_DIR/control)" + case "$target" in + i386|all) + file="$package-$version" + mkdir -p $TMP_DIR/$file/fs/ + dpkg-deb -x "$PACKAGE_FILE" $TMP_DIR/$file/fs + cd $TMP_DIR + cat > $file/receipt <> $file/receipt + echo "DEPENDS=\"$(find_depends)\"" >> $file/receipt + [ -s 'conffiles' ] && cat >> $file/receipt < $file/description.txt + sed -i 's/^\.$//' $file/description.txt + [ -s "$file/description.txt" ] || rm -f $file/description.txt + tazpkg pack $file + mv $file.tazpkg $TOP_DIR + ;; + *) + _ 'Invalid target: %s (expected i386)' "$target" + ;; + esac + cd $TOP_DIR + rm -rf $TMP_DIR +} + + +# convert a .rpm package to .tazpkg + +convert_rpm() { + mkdir -p $TMP_DIR + cp "$PACKAGE_FILE" $TMP_DIR + PACKAGE_FILE="$TMP_DIR/$(basename "$PACKAGE_FILE")" + rpm -qip "$PACKAGE_FILE" | awk -v pkg="$(basename "$PACKAGE_FILE")" ' +BEGIN { + goturl=0; + printf "# SliTaz package receipt.\n"; + printf "# generated by tazpkg from rpm package %s\n",pkg; +} +{ + if (/^Name/) { name=$3; printf "PACKAGE=\"%s\"\n",$3; } + if (/^Version/) printf "VERSION=\"%s-",$3; + if (/^Release/) printf "%s\"\n",$3; + if (/^Summary/) printf "SHORT_DESC=\"%s\"\n",substr($0,15); + if (/^URL/) { goturl=1; printf "WEB_SITE=\"%s\"\n",$3; } +} +END { + if (goturl == 0) + printf "WEB_SITE=\"http://rpmfind.net/linux/rpm2html/search.php?query=%s\"\n",name; + printf "CATEGORY=\"misc\"\n"; + printf "MAINTAINER=\"nobody@slitaz.org\"\n"; +} +' > $TMP_DIR/receipt + . $TMP_DIR/receipt + file="$PACKAGE-$VERSION" + mkdir -p $TMP_DIR/$file/fs/ + mv $TMP_DIR/receipt $TMP_DIR/$file + rpm -qip "$PACKAGE_FILE" | awk ' +BEGIN { show=0 } +{ + if (show) print; + if (/^Description/) show=1; +} +' > $TMP_DIR/$file/description.txt + cd $TMP_DIR/$file/fs/ + rpm2cpio "$PACKAGE_FILE" | cpio -idm --quiet + # rpm2cpio can't extract some new RPMs + if [ $? -eq 1 ]; then + if [ ! -e $INSTALLED/p7zip-full/receipt ]; then + boldify "$(_ 'Unable to extract the RPM using standard tools (rpm2cpio).')" + confirm "$(_n 'Do you want to install "%s" package? (y/N)' 'p7zip-full')" + if [ $? -eq 0 ]; then + tazpkg -gi p7zip-full + else + rm -rf $TMP_DIR + exit 1 + fi + fi + # we may already have 7z or may have just installed it in the step above + if [ -e "$INSTALLED/p7zip-full/receipt" ]; then + 7z x -so "$PACKAGE_FILE" | cpio -idm --quiet + fi + fi + cd ../.. + echo "DEPENDS=\"$(find_depends)\"" >> $TMP_DIR/$file/receipt + show_unresolved_lib $TMP_DIR/$file/receipt + tazpkg pack $file + mv $file.tazpkg $TOP_DIR + cd $TOP_DIR + rm -rf $TMP_DIR +} + + +# convert a .xbps package to .tazpkg (http://repo.voidlinux.eu/current/) + +xbpstag() { + sed "/$1<\/key>/!d{n;s/.*>\\(.*\\)<.*/\\1/}" \ + < fs/props.plist | sed \$!d +} + +convert_xbps() { + mkdir -p $TMP_DIR/fs + ( xzcat "$PACKAGE_FILE" || bzcat "$PACKAGE_FILE" || zcat "$PACKAGE_FILE" ) | \ + tar -xf - -C $TMP_DIR/fs + + cd $TMP_DIR + HOST_ARCH="$(xbpstag architecture)" + case "$HOST_ARCH" in + i686) HOST_ARCH='i486';; + *) _ 'Arch "%s" not supported.' "$HOST_ARCH" + HOST_ARCH='';; + esac + + if [ -n "$HOST_ARCH" ]; then + package="$(xbpstag pkgname)" + version="$(xbpstag version)" + file="$package-$version" + mkdir $file + cat > $file/receipt <> $file/receipt < $file/receipt <> $file/receipt </dev/null)" == 'debian-b' ]; then + convert_deb +else + case "$PACKAGE_FILE" in + *.deb|*.udeb) convert_deb;; + *.rpm) convert_rpm;; + *.sb) convert_sb;; + *.sfs) convert_sfs;; + *.pet) convert_pet;; + *.txz|*.tgz) convert_tgz;; + *.cards.tar.xz) convert_nutyx;; + *.apk|*.pkg.tar.gz|*.pkg.tar.xz) convert_arch;; + *.ipk|*.opk) convert_ipk;; + *.spack) convert_spack;; + *.tar.bz2) convert_upkg;; + *.xbps) convert_xbps;; + *.tce|*.tcel|*.tcem) convert_tce;; + *.tcz) convert_tcz;; + *) _ 'Unsupported format';; + esac +fi + +exit 0 diff -r e1399e7ca7ff -r f7e9a5b8477b modules/find-depends --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/find-depends Sat Jul 25 16:50:18 2015 +0300 @@ -0,0 +1,85 @@ +#!/bin/sh +# /usr/lib/tazpkg/tazpkg-find-depends: this program is a part of TazPkg. +# This file contains the functions that are common to tazpkg and tazpkg-convert, +# and sourced by them. + + +# Need by check_depends +TMPLOCALSTATE= + + +# Check for ELF file + +is_elf() +{ + [ "$(dd if="$1" bs=1 skip=1 count=3 2>/dev/null)" == "ELF" ] +} + + +# Print shared library dependencies + +ldd() +{ + LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so "$1" 2>/dev/null +} + + +# search dependencies for files in $TMP_DIR/$file/fs + +find_depends() +{ + DEFAULT_DEPENDS="glibc-base gcc-lib-base" + + [ -n "$TMPLOCALSTATE" ] || TMPLOCALSTATE=$PKGS_DB + [ -f $TMPLOCALSTATE/files.list.lzma ] || tazpkg recharge >/dev/null + for i in $TMPLOCALSTATE/files.list.lzma \ + $TMPLOCALSTATE/undigest/*/files.list.lzma ; do + [ -f $i ] && lzma d $i -so >> $TMP_DIR/files.list + done + + echo "Find depends..." 1>&2 + libs_found="" + find ${1:-$TMP_DIR/$file/fs} -type f | \ + while read chkfile ; do + is_elf "$chkfile" || continue + case "$chkfile" in + *.o|*.ko|*.ko.gz) continue;; + esac + + for lib in $(ldd "$chkfile" | sed '/=>/!d;s/ =>.*//') ; do + case " $libs_found " in + *\ $lib\ *) continue + esac + libs_found="$libs_found $lib" + case "$lib" in + statically|linux-gate.so*|ld-*.so|*/ld-*.so) continue;; + esac + find ${1:-$TMP_DIR/$file/fs} | grep -q /$lib$ && continue + + echo -ne "for $lib \r" 1>&2 + for dep in $(fgrep $lib files.list | cut -d: -f1); do + case " $DEFAULT_DEPENDS " in + *\ $dep\ *) continue 2;; + esac + grep -qs "^$dep$" $TMP_DIR/depends && continue 2 + done + + if [ -n "$dep" ]; then + echo "$dep" >> $TMP_DIR/depends + else + grep -qs ^$lib$ $TMP_DIR/unresolved || + echo "$lib" >> $TMP_DIR/unresolved + fi + done + done + + spc="" + [ -s $TMP_DIR/depends ] && + sort < $TMP_DIR/depends 2>/dev/null | uniq | \ + while read file; do + echo -n "$spc$file" + spc=" " + done +} + + diff -r e1399e7ca7ff -r f7e9a5b8477b modules/help --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/help Sat Jul 25 16:50:18 2015 +0300 @@ -0,0 +1,95 @@ +#!/bin/sh +# TazPkg - Tiny autonomous zone packages manager. +# TazPkg help system + +. /lib/libtaz.sh + +T="${1#-}" +DOC='/usr/share/doc/tazpkg/tazpkg.html' +QUERY="$T" + +if [ -z "$T" ]; then + tazpkg usage; exit 0 +fi + +commands="\ +:usage::help,h::activity,log,a::clean-cache,cc::shell::list,l::list-mirror,lm:\ +:list-config::search,s::search-pkgname,sp::search-file,sf::get,g::install,i:\ +:get-install,gi::install-list,get-install-list::remove,r::reconfigure::link:\ +:set-release::add-flavor,install-flavor::info::desc,d::list-files,lf:\ +:block,b,unblock,u,chblock::check::bugs::depends,rdepends::extract,e::pack:\ +:repack::repack-config::recompress::convert,c::list-suggested::recharge:\ +:upgrade,up::setup-mirror,sm::add-undigest,setup-undigest::list-undigest:\ +:remove-undigest:" + +if [ ! $(echo $commands | grep -e "[:,]$T[:,]") ]; then + try1=$(echo $commands | grep -oe ":[^:]*$T[^:]*:") + if [ -z "$try1" ]; then + _ 'Sorry, no help for "%s"' "$QUERY"; newline; exit 0 + fi + + try2=$(echo "$try1" | tr -d : ) + + trynum=$(echo "$try2" | wc -l) + if [ "$trynum" -ne 1 ]; then + _p '%d help topic available:' '%d help topics available:' "$trynum" \ + "$trynum"; newline + echo "$try2" | sed 's|^| * &|; s| ,| |; s|,|, |g' + exit 0 + else + T="${try2%%,*}" + fi +else + try3=$(echo $commands | grep -oe "[:,]$T[:,]") + case $try3 in + :*) try4="$try3";; + ,*) try4=$(echo $commands | grep -oe ":[^:]*$try3" | cut -d, -f1);; + esac + + T=$(echo $try4 | tr -d ':,') +fi + +title=$(echo $commands | grep -oe ":$T\(,[^:]*\)*:" | tr -d : | sed 's|,|, |g') + + +# style:

+HLP=$(sed "/id=\"$T\"/,/

+ HLP=$(sed "/name=\"$T\"/,/name=/!d; /name=/d; /

/,/<\/pre\>/{s|.*|  &|; s| |·|g}; \ + s|^  $||; s|
||; s|
||; s|  ·#|  #|;" | tr '\n' ' ' | \ + sed '/^[ ]*$/d' | \ + sed 's|[ ][ ]*| |g;' | \ + sed 's|[ ]*
|O\n|g; s|[ ]*
|L\n|g; s|[ ]*||g;' | \ + sed 's|[ ]*
| |g; s|
|\n|g;' | \ + sed 's|

||g; s|

|\n|g' | \ + sed 's|[ ]*

[ ]*||g; s|[ ]*

|\n \n|g; s|  |\n  |g' | \ + sed 's|]*>||g; s|||g; s|·| |g' | \ + sed 's|||g; s|­||g; s|^[ ]*||' | \ + sed '/^$/d' | \ + sed 's||A|g; s||A|g; s||B|g; s||B|g; \ + s||D|g; s||D|g; s||D|g; s||C|g; \ + s|DD|D|g;') + +OPT=$(echo "$PRE" | sed '/O/,/L/!d; /[OL]/d') +OPTLIST=$(optlist "$OPT") + +OPT0=$(echo "$PRE" | tr '\n' '@') +OPTA=$(echo "$OPT" | tr '\n' '@') +OPTB=$(echo "$OPTLIST" | tr '\n' '@') + +PRE2=$(echo "$OPT0" | sed "s|$OPTA|$OPTB|" | tr '@' '\n' | sed '/O/d; s|L||') + +[ ! -z "$TA" ] && T="$T, $TA" + +title '$title' +emsg "$(longline "$PRE2" | sed 's|A||g; s|B||g; s|C||g; s|D||g; ')" +newline diff -r e1399e7ca7ff -r f7e9a5b8477b modules/tazpkg-convert --- a/modules/tazpkg-convert Fri Jul 24 17:13:16 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,750 +0,0 @@ -#!/bin/sh - -# This program is a part of TazPkg. -# /usr/bin/tazpkg-convert: toolset to convert alien package to the tazpkg format - -# Usage: tazpkg-convert alien_package [ target_directory ] - - -PACKAGE_FILE="$1" -TARGET_DIR="$2" -TMP_DIR=$(mktemp -d) -TOP_DIR="$(pwd)" - -. /etc/slitaz/slitaz.conf -. /lib/libtaz.sh -. /usr/lib/tazpkg/tazpkg-find-depends - -# Internationalization. -export TEXTDOMAIN='tazpkg' - - -# FIXME: what does this mean? -[ -n "$TARGET_DIR" -a -s "$TARGET_DIR/files.list.lzma" ] && TMPLOCALSTATE="$TARGET_DIR" - - -show_unresolved_lib() { - if [ -s "$TMP_DIR/unresolved" ]; then - echo -e "BUGS=\"$(_n 'No dependency for:')" >> $1 - sort < $TMP_DIR/unresolved | uniq | \ - while read file; do - _ 'WARNING: unknown dependency for %s' "$lib" - echo -n " $file" >> $1 - done - echo "\"" >> $1 - fi -} - - -# convert a .tar.bz2 package to .tazpkg - -convert_upkg() { - mkdir -p $TMP_DIR/fs - tar -xjf "$PACKAGE_FILE" -C $TMP_DIR/fs - if [ -d "$TMP_DIR/fs/var/lib/upkg/packages" ]; then - cd $TMP_DIR - package="$(sed '/^Package:/!d;s/.*: //' fs/var/lib/upkg/packages/*.info)" - version="$(sed '/^Version:/!d;s/.*: //' fs/var/lib/upkg/packages/*.info)" - url='http://www.paldo.org/' - file="$package-$version" - mkdir $file - mv fs $file - maintainer='nobody@slitaz.org' - descrip="$package package from paldo." - cat > $file/receipt <> $file/receipt <> $file/receipt < $file/receipt <> $file/receipt <> $file/receipt < $file/receipt <> $file/receipt <> $file/receipt < $file/description.txt - sed -i 's/^\.$//' $file/description.txt - [ -s $file/description.txt ] || rm -f $file/description.txt - tazpkg pack $file - cd $TOP_DIR - mv $TMP_DIR/$file.tazpkg . - ;; - *) - _ 'Invalid target: %s (expected i386)' "$target" - ;; - esac - rm -rf $TMP_DIR -} - - -# convert a .cards.tar.xz package to .tazpkg - -convert_nutyx() { - mkdir -p $TMP_DIR/fs - busybox tar -xf "$PACKAGE_FILE" -C $TMP_DIR/fs - if [ -f "$TMP_DIR/fs/.META" ]; then - package="$(sed '/^N/!d;s/^.//' fs/.META)" - version="$(sed '/^V/!d;s/^.//' fs/.META)" - descrip="$(sed '/^D/!d;s/^.//' fs/.META)" - file="$package-$version" - mkdir $file - mv fs $file - cat > $file/receipt < $file/receipt < $file/receipt <> $file/receipt </dev/null - . $package*/*.specs - desc="$PETMENUDESCR" - mv $package*/ fs - finish_convert_puppy -} - - -# convert a .sb package to .tazpkg - -convert_sb() { - [ -n "$(which unsquashfs)" ] || tazpkg get-install squashfs - if ! unsquashfs -l "$PACKAGE_FILE" | grep -q squashfs-root/var/log/removed_scripts ; then - _ 'File "%s" does not look like %s package!' "$PACKAGE_FILE" 'Slax' - return 1 - fi - mkdir -p $TMP_DIR - cd $TMP_DIR - unsquashfs "$PACKAGE_FILE" - mv squashfs-root fs - parse_pkgname '' $(cat fs/var/log/packages/* | sed '/PACKAGE NAME:/!d;s/.*: *//') - desc="$(cat fs/var/log/packages/* | sed '/^PACKAGE DESCRIPTION:/,$!d;N;s/.*: //;q')" - cat fs/var/log/packages/* | sed '/^PACKAGE DESCRIPTION:/,/FILE LIST/!d;s/.*://;/^$/d' > $file/description.txt - mv fs $file - cat > $file/receipt <> $file/receipt < $file/receipt <> $file/receipt < $file/description.txt - [ -s "$file/description.txt" ] || rm -f $file/description.txt - rm -rf $file/fs/install - tazpkg pack $file - mv $file.tazpkg $TOP_DIR - else - _ 'File "%s" does not look like %s package!' "$PACKAGE_FILE" 'Slackware' - fi - cd $TOP_DIR - rm -rf $TMP_DIR -} - - -# convert a .deb package to .tazpkg - -convert_deb() { - mkdir -p $TMP_DIR - dpkg-deb -e "$PACKAGE_FILE" $TMP_DIR - package=$(sed '/^ *Package:/!d;s/.*: //' $TMP_DIR/control) - version=$(sed '/^ *Version:/!d;s/.*: //' $TMP_DIR/control) - descrip=$(sed '/^ *Description:/!d;s/.*: //' $TMP_DIR/control) - homepage=$(sed '/^ *Homepage:/!d;s/.*: //' $TMP_DIR/control) - target="$(sed '/^ *Architecture:/!d;s/.*: //' $TMP_DIR/control)" - case "$target" in - i386|all) - file="$package-$version" - mkdir -p $TMP_DIR/$file/fs/ - dpkg-deb -x "$PACKAGE_FILE" $TMP_DIR/$file/fs - cd $TMP_DIR - cat > $file/receipt <> $file/receipt - echo "DEPENDS=\"$(find_depends)\"" >> $file/receipt - [ -s 'conffiles' ] && cat >> $file/receipt < $file/description.txt - sed -i 's/^\.$//' $file/description.txt - [ -s "$file/description.txt" ] || rm -f $file/description.txt - tazpkg pack $file - mv $file.tazpkg $TOP_DIR - ;; - *) - _ 'Invalid target: %s (expected i386)' "$target" - ;; - esac - cd $TOP_DIR - rm -rf $TMP_DIR -} - - -# convert a .rpm package to .tazpkg - -convert_rpm() { - mkdir -p $TMP_DIR - cp "$PACKAGE_FILE" $TMP_DIR - PACKAGE_FILE="$TMP_DIR/$(basename "$PACKAGE_FILE")" - rpm -qip "$PACKAGE_FILE" | awk -v pkg="$(basename "$PACKAGE_FILE")" ' -BEGIN { - goturl=0; - printf "# SliTaz package receipt.\n"; - printf "# generated by tazpkg from rpm package %s\n",pkg; -} -{ - if (/^Name/) { name=$3; printf "PACKAGE=\"%s\"\n",$3; } - if (/^Version/) printf "VERSION=\"%s-",$3; - if (/^Release/) printf "%s\"\n",$3; - if (/^Summary/) printf "SHORT_DESC=\"%s\"\n",substr($0,15); - if (/^URL/) { goturl=1; printf "WEB_SITE=\"%s\"\n",$3; } -} -END { - if (goturl == 0) - printf "WEB_SITE=\"http://rpmfind.net/linux/rpm2html/search.php?query=%s\"\n",name; - printf "CATEGORY=\"misc\"\n"; - printf "MAINTAINER=\"nobody@slitaz.org\"\n"; -} -' > $TMP_DIR/receipt - . $TMP_DIR/receipt - file="$PACKAGE-$VERSION" - mkdir -p $TMP_DIR/$file/fs/ - mv $TMP_DIR/receipt $TMP_DIR/$file - rpm -qip "$PACKAGE_FILE" | awk ' -BEGIN { show=0 } -{ - if (show) print; - if (/^Description/) show=1; -} -' > $TMP_DIR/$file/description.txt - cd $TMP_DIR/$file/fs/ - rpm2cpio "$PACKAGE_FILE" | cpio -idm --quiet - # rpm2cpio can't extract some new RPMs - if [ $? -eq 1 ]; then - if [ ! -e $INSTALLED/p7zip-full/receipt ]; then - boldify "$(_ 'Unable to extract the RPM using standard tools (rpm2cpio).')" - confirm "$(_n 'Do you want to install "%s" package? (y/N)' 'p7zip-full')" - if [ $? -eq 0 ]; then - tazpkg -gi p7zip-full - else - rm -rf $TMP_DIR - exit 1 - fi - fi - # we may already have 7z or may have just installed it in the step above - if [ -e "$INSTALLED/p7zip-full/receipt" ]; then - 7z x -so "$PACKAGE_FILE" | cpio -idm --quiet - fi - fi - cd ../.. - echo "DEPENDS=\"$(find_depends)\"" >> $TMP_DIR/$file/receipt - show_unresolved_lib $TMP_DIR/$file/receipt - tazpkg pack $file - mv $file.tazpkg $TOP_DIR - cd $TOP_DIR - rm -rf $TMP_DIR -} - - -# convert a .xbps package to .tazpkg (http://repo.voidlinux.eu/current/) - -xbpstag() { - sed "/$1<\/key>/!d{n;s/.*>\\(.*\\)<.*/\\1/}" \ - < fs/props.plist | sed \$!d -} - -convert_xbps() { - mkdir -p $TMP_DIR/fs - ( xzcat "$PACKAGE_FILE" || bzcat "$PACKAGE_FILE" || zcat "$PACKAGE_FILE" ) | \ - tar -xf - -C $TMP_DIR/fs - - cd $TMP_DIR - HOST_ARCH="$(xbpstag architecture)" - case "$HOST_ARCH" in - i686) HOST_ARCH='i486';; - *) _ 'Arch "%s" not supported.' "$HOST_ARCH" - HOST_ARCH='';; - esac - - if [ -n "$HOST_ARCH" ]; then - package="$(xbpstag pkgname)" - version="$(xbpstag version)" - file="$package-$version" - mkdir $file - cat > $file/receipt <> $file/receipt < $file/receipt <> $file/receipt </dev/null)" == 'debian-b' ]; then - convert_deb -else - case "$PACKAGE_FILE" in - *.deb|*.udeb) convert_deb;; - *.rpm) convert_rpm;; - *.sb) convert_sb;; - *.sfs) convert_sfs;; - *.pet) convert_pet;; - *.txz|*.tgz) convert_tgz;; - *.cards.tar.xz) convert_nutyx;; - *.apk|*.pkg.tar.gz|*.pkg.tar.xz) convert_arch;; - *.ipk|*.opk) convert_ipk;; - *.spack) convert_spack;; - *.tar.bz2) convert_upkg;; - *.xbps) convert_xbps;; - *.tce|*.tcel|*.tcem) convert_tce;; - *.tcz) convert_tcz;; - *) _ 'Unsupported format';; - esac -fi - -exit 0 diff -r e1399e7ca7ff -r f7e9a5b8477b modules/tazpkg-find-depends --- a/modules/tazpkg-find-depends Fri Jul 24 17:13:16 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -# /usr/lib/tazpkg/tazpkg-find-depends: this program is a part of TazPkg. -# This file contains the functions that are common to tazpkg and tazpkg-convert, -# and sourced by them. - - -# Need by check_depends -TMPLOCALSTATE= - - -# Check for ELF file - -is_elf() -{ - [ "$(dd if="$1" bs=1 skip=1 count=3 2>/dev/null)" == "ELF" ] -} - - -# Print shared library dependencies - -ldd() -{ - LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so "$1" 2>/dev/null -} - - -# search dependencies for files in $TMP_DIR/$file/fs - -find_depends() -{ - DEFAULT_DEPENDS="glibc-base gcc-lib-base" - - [ -n "$TMPLOCALSTATE" ] || TMPLOCALSTATE=$PKGS_DB - [ -f $TMPLOCALSTATE/files.list.lzma ] || tazpkg recharge >/dev/null - for i in $TMPLOCALSTATE/files.list.lzma \ - $TMPLOCALSTATE/undigest/*/files.list.lzma ; do - [ -f $i ] && lzma d $i -so >> $TMP_DIR/files.list - done - - echo "Find depends..." 1>&2 - libs_found="" - find ${1:-$TMP_DIR/$file/fs} -type f | \ - while read chkfile ; do - is_elf "$chkfile" || continue - case "$chkfile" in - *.o|*.ko|*.ko.gz) continue;; - esac - - for lib in $(ldd "$chkfile" | sed '/=>/!d;s/ =>.*//') ; do - case " $libs_found " in - *\ $lib\ *) continue - esac - libs_found="$libs_found $lib" - case "$lib" in - statically|linux-gate.so*|ld-*.so|*/ld-*.so) continue;; - esac - find ${1:-$TMP_DIR/$file/fs} | grep -q /$lib$ && continue - - echo -ne "for $lib \r" 1>&2 - for dep in $(fgrep $lib files.list | cut -d: -f1); do - case " $DEFAULT_DEPENDS " in - *\ $dep\ *) continue 2;; - esac - grep -qs "^$dep$" $TMP_DIR/depends && continue 2 - done - - if [ -n "$dep" ]; then - echo "$dep" >> $TMP_DIR/depends - else - grep -qs ^$lib$ $TMP_DIR/unresolved || - echo "$lib" >> $TMP_DIR/unresolved - fi - done - done - - spc="" - [ -s $TMP_DIR/depends ] && - sort < $TMP_DIR/depends 2>/dev/null | uniq | \ - while read file; do - echo -n "$spc$file" - spc=" " - done -} - - diff -r e1399e7ca7ff -r f7e9a5b8477b modules/tazpkg-help --- a/modules/tazpkg-help Fri Jul 24 17:13:16 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -#!/bin/sh -# TazPkg - Tiny autonomous zone packages manager. -# TazPkg help system - -. /lib/libtaz.sh - -T="${1#-}" -DOC='/usr/share/doc/tazpkg/tazpkg.html' -QUERY="$T" - -if [ -z "$T" ]; then - tazpkg usage; exit 0 -fi - -commands="\ -:usage::help,h::activity,log,a::clean-cache,cc::shell::list,l::list-mirror,lm:\ -:list-config::search,s::search-pkgname,sp::search-file,sf::get,g::install,i:\ -:get-install,gi::install-list,get-install-list::remove,r::reconfigure::link:\ -:set-release::add-flavor,install-flavor::info::desc,d::list-files,lf:\ -:block,b,unblock,u,chblock::check::bugs::depends,rdepends::extract,e::pack:\ -:repack::repack-config::recompress::convert,c::list-suggested::recharge: -:upgrade,up::setup-mirror,sm::add-undigest,setup-undigest::list-undigest:\ -:remove-undigest:" - -if [ ! $(echo $commands | grep -e "[:,]$T[:,]") ]; then - try1=$(echo $commands | grep -oe ":[^:]*$T[^:]*:") - if [ -z "$try1" ]; then - _ 'Sorry, no help for "%s"' "$QUERY"; newline; exit 0 - fi - - try2=$(echo "$try1" | tr -d : ) - - trynum=$(echo "$try2" | wc -l) - if [ "$trynum" -ne 1 ]; then - _p '%d help topic available:' '%d help topics available:' "$trynum" \ - "$trynum"; newline - echo "$try2" | sed 's|^| * &|; s| ,| |; s|,|, |g' - exit 0 - else - T="${try2%%,*}" - fi -else - try3=$(echo $commands | grep -oe "[:,]$T[:,]") - case $try3 in - :*) try4="$try3";; - ,*) try4=$(echo $commands | grep -oe ":[^:]*$try3" | cut -d, -f1);; - esac - - T=$(echo $try4 | tr -d ':,') -fi - -title=$(echo $commands | grep -oe ":$T\(,[^:]*\)*:" | tr -d : | sed 's|,|, |g') - - -# style:

-HLP=$(sed "/id=\"$T\"/,/

- HLP=$(sed "/name=\"$T\"/,/name=/!d; /name=/d; /

/,/<\/pre\>/{s|.*|  &|; s| |·|g}; \ - s|^  $||; s|
||; s|
||; s|  ·#|  #|;" | tr '\n' ' ' | \ - sed '/^[ ]*$/d' | \ - sed 's|[ ][ ]*| |g;' | \ - sed 's|[ ]*
|O\n|g; s|[ ]*
|L\n|g; s|[ ]*||g;' | \ - sed 's|[ ]*
| |g; s|
|\n|g;' | \ - sed 's|

||g; s|

|\n|g' | \ - sed 's|[ ]*

[ ]*||g; s|[ ]*

|\n \n|g; s|  |\n  |g' | \ - sed 's|]*>||g; s|||g; s|·| |g' | \ - sed 's|||g; s|­||g; s|^[ ]*||' | \ - sed '/^$/d' | \ - sed 's||A|g; s||A|g; s||B|g; s||B|g; \ - s||D|g; s||D|g; s||D|g; s||C|g; \ - s|DD|D|g;') - -OPT=$(echo "$PRE" | sed '/O/,/L/!d; /[OL]/d') -OPTLIST=$(optlist "$OPT") - -OPT0=$(echo "$PRE" | tr '\n' '@') -OPTA=$(echo "$OPT" | tr '\n' '@') -OPTB=$(echo "$OPTLIST" | tr '\n' '@') - -PRE2=$(echo "$OPT0" | sed "s|$OPTA|$OPTB|" | tr '@' '\n' | sed '/O/d; s|L||') - -[ ! -z "$TA" ] && T="$T, $TA" - -title '$title' -emsg "$(longline "$PRE2" | sed 's|A||g; s|B||g; s|C||g; s|D||g; ')" -newline diff -r e1399e7ca7ff -r f7e9a5b8477b tazpkg --- a/tazpkg Fri Jul 24 17:13:16 2015 +0200 +++ b/tazpkg Sat Jul 25 16:50:18 2015 +0300 @@ -3051,7 +3051,7 @@ # convert misc package format to .tazpkg check_for_package_file shift - tazpkg-convert $@ + @@MODULES@@/convert $@ ;; @@ -3116,7 +3116,7 @@ help|-h) # TazPkg help system - shift; tazpkg-help $@ ;; + shift; @@MODULES@@/help $@ ;; '')