tazpkg view modules/convert @ rev 950
Minor bug fixes due to the change in the behavior of the dot command in Busybox-1.27; support "release checksum" in modules/mkdb.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Thu Jul 27 13:38:37 2017 +0300 (2017-07-27) |
parents | e4257a4c2eb3 |
children | 9d683c983e2e |
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # convert - TazPkg module
4 # Toolset to convert alien package to the tazpkg format
7 # Usage: tazpkg-convert alien_package [ target_directory ]
10 PACKAGE_FILE="$1"
11 TARGET_DIR="$2"
12 TMP_DIR=$(mktemp -d)
13 TOP_DIR="$(pwd)"
15 . @@MODULES@@/find-depends
17 # Get TazPkg working environment
18 . @@MODULES@@/getenv
21 # FIXME: what does this mean?
22 [ -n "$TARGET_DIR" -a -s "$TARGET_DIR/files.list.lzma" ] && TMPLOCALSTATE="$TARGET_DIR"
25 show_unresolved_lib() {
26 if [ -s "$TMP_DIR/unresolved" ]; then
27 echo -e "BUGS=\"$(_n 'No dependency for:')" >> $1
28 sort < $TMP_DIR/unresolved | uniq | \
29 while read file; do
30 _ 'WARNING: unknown dependency for %s' "$lib"
31 echo -n " $file" >> $1
32 done
33 echo "\"" >> $1
34 fi
35 }
38 # convert a .tar.bz2 package to .tazpkg
40 convert_upkg() {
41 mkdir -p "$TMP_DIR/fs"
42 tar -xjf "$PACKAGE_FILE" -C "$TMP_DIR/fs"
43 if [ -d "$TMP_DIR/fs/var/lib/upkg/packages" ]; then
44 cd "$TMP_DIR"
45 package=$(sed '/^Package:/!d;s/.*: //' fs/var/lib/upkg/packages/*.info)
46 version=$(sed '/^Version:/!d;s/.*: //' fs/var/lib/upkg/packages/*.info)
47 url='http://www.paldo.org/'
48 file="$package-$version"
49 mkdir "$file"
50 mv fs "$file"
51 maintainer='nobody@slitaz.org'
52 descrip="$package package from paldo."
53 cat > "$file/receipt" <<EOT
54 # SliTaz package receipt.
55 # generated by tazpkg from package $(basename "$PACKAGE_FILE")
56 PACKAGE="$package"
57 VERSION="$version"
58 CATEGORY="misc"
59 SHORT_DESC="$descrip"
60 WEB_SITE="$url"
61 MAINTAINER="$maintainer"
62 DEPENDS="$(find_depends .)"
63 EOT
64 [ -s $file/var/lib/upkg/files/*.config.bz2 ] &&
65 cat >> "$file/receipt" <<EOT
66 CONFIG_FILES="$(bzcat $file/var/lib/upkg/files/*.config.bz2)"
67 EOT
68 while read ext func; do
69 [ -s $file/fs/var/lib/upkg/scripts/*.$ext ] || continue
70 cat >> "$file/receipt" <<EOT
72 $func()
73 {
74 $(cat $file/fs/var/lib/upkg/scripts/*.$ext)
75 }
76 EOT
77 done <<EOT
78 prerm pre_remove
79 EOT
81 tazpkg pack "$file"
82 mv "$TMP_DIR/$file.tazpkg" "$TOP_DIR"
83 else
84 _ 'File "%s" does not look like %s package!' "$PACKAGE_FILE" 'upkg'
85 fi
86 cd "$TOP_DIR"
87 rm -rf "$TMP_DIR"
88 }
91 # convert a .spack package to .tazpkg
93 convert_spack() {
94 mkdir -p "$TMP_DIR"
95 ( cd "$TMP_DIR"; cpio -i ) < "$PACKAGE_FILE"
96 cd "$TMP_DIR"
97 package=$(sed '$!d;s/:.*//' about.txt)
98 version=$(basename "$PACKAGE_FILE" | sed "s/$package-\([^-]*\).*/\1/")
99 descrip=$(sed '$!d;s/.*: //' about.txt)
100 url='http://0linux.org/'
101 maintainer='nobody@slitaz.org'
102 file="$package-$version"
103 mkdir -p "$file/fs"
104 xzcat files.xz | ( cd "$file/fs"; cpio -idmu )
105 cat > "$file/receipt" <<EOT
106 # SliTaz package receipt.
107 # generated by tazpkg from package $(basename "$PACKAGE_FILE")
108 PACKAGE="$package"
109 VERSION="$version"
110 CATEGORY="misc"
111 SHORT_DESC="$descrip"
112 WEB_SITE="$url"
113 MAINTAINER="$maintainer"
114 DEPENDS="$(find_depends .)"
115 EOT
116 [ -s 'pre-install.sh' ] && cat >> "$file/receipt" <<EOT
118 pre_install()
119 {
120 cd /
121 $(sed 1d pre-install.sh)
122 }
123 EOT
124 [ -s 'post-install.sh' ] && cat >> "$file/receipt" <<EOT
126 post_install()
127 {
128 cd /
129 $(sed '1,/^}/d' post-install.sh)
130 }
131 EOT
132 tazpkg pack "$file"
133 cd "$TOP_DIR"
134 mv "$TMP_DIR/$file.tazpkg" .
135 rm -rf "$TMP_DIR"
136 }
139 # convert a .ipk package to .tazpkg
141 convert_ipk() {
142 mkdir -p "$TMP_DIR"
143 tar -xOzf "$PACKAGE_FILE" ./control.tar.gz | tar -xzf - -C "$TMP_DIR"
144 package=$( sed '/^Package/!d;s/.*: //' "$TMP_DIR/control")
145 version=$( sed '/^Version/!d;s/.*: //' "$TMP_DIR/control")
146 maintainer=$(sed '/^Maintainer/!d;s/.*: //' "$TMP_DIR/control")
147 target=$( sed '/^Architecture/!d;s/.*: //' "$TMP_DIR/control")
148 descrip=$( sed '/^Description/!d;s/.*: //' "$TMP_DIR/control")
149 homepage=$( sed '/^Homepage/!d;s/.*: //' "$TMP_DIR/control")
150 url='http://openwrt.org/'
151 case "$target" in
152 i386|all)
153 file="$package-$version"
154 mkdir -p "$TMP_DIR/$file/fs"
155 tar -xOzf "$PACKAGE_FILE" ./data.tar.gz | tar -xzf - -C "$TMP_DIR/$file/fs"
156 cd "$TMP_DIR"
157 cat > "$file/receipt" <<EOT
158 # SliTaz package receipt.
159 # generated by tazpkg from package $(basename "$PACKAGE_FILE")
160 PACKAGE="$package"
161 VERSION="$version"
162 CATEGORY="misc"
163 SHORT_DESC="$descrip"
164 WEB_SITE="${homepage:-$url}"
165 MAINTAINER="$maintainer"
166 DEPENDS="$(find_depends .)"
167 EOT
168 show_unresolved_lib "$file/receipt"
169 [ -s 'conffiles' ] && cat >> "$file/receipt" <<EOT
170 CONFIG_FILES=$(cat conffiles)
171 EOT
172 show_unresolved_lib "$file/receipt"
173 while read script func; do
174 [ -s "$script" ] && cat >> "$file/receipt" <<EOT
176 $func()
177 {
178 $(cat "$script")
179 }
180 EOT
181 done <<EOT
182 preinst pre_install
183 postinst post_install
184 prerm pre_remove
185 postrm post_remove
186 EOT
187 awk '
188 {
189 if (/^ / && show)
190 print substr($0,2);
191 else
192 show=0;
193 if (/^Description/)
194 show=1;
195 }' < "$TMP_DIR/control" > "$file/description.txt"
196 sed -i 's/^\.$//' "$file/description.txt"
197 [ -s "$file/description.txt" ] || rm -f "$file/description.txt"
198 tazpkg pack "$file"
199 cd "$TOP_DIR"
200 mv "$TMP_DIR/$file.tazpkg" .
201 ;;
202 *)
203 _ 'Invalid target: %s (expected i386)' "$target"
204 ;;
205 esac
206 rm -rf "$TMP_DIR"
207 }
210 # convert a .cards.tar.xz package to .tazpkg
212 convert_nutyx() {
213 mkdir -p "$TMP_DIR/fs"
214 tar -xf "$PACKAGE_FILE" -C "$TMP_DIR/fs"
215 if [ -f "$TMP_DIR/fs/.META" ]; then
216 package=$(sed '/^N/!d;s/^.//' fs/.META)
217 version=$(sed '/^V/!d;s/^.//' fs/.META)
218 descrip=$(sed '/^D/!d;s/^.//' fs/.META)
219 file="$package-$version"
220 mkdir "$file"
221 mv fs "$file"
222 cat > "$file/receipt" <<EOT
223 # SliTaz package receipt.
224 # generated by tazpkg from NuTyX package $(basename "$PACKAGE_FILE")
225 PACKAGE="$package"
226 VERSION="$version"
227 CATEGORY="misc"
228 SHORT_DESC="$descrip"
229 WEB_SITE="http://www.nutyx.org/"
230 MAINTAINER="nobody@slitaz.org"
231 DEPENDS="$(find_depends .)"
232 EOT
233 show_unresolved_lib "$file/receipt"
234 rm -f $file/fs/.[A-Z]*
235 tazpkg pack "$file"
236 mv "$file.tazpkg" "$TOP_DIR"
237 else
238 _ 'File "%s" does not look like %s package!' "$PACKAGE_FILE" 'NuTyX'
239 fi
240 cd "$TOP_DIR"
241 rm -rf "$TMP_DIR"
242 }
245 # convert a .pkg.tar.gz/.pkg.tar.xz/.apk package to .tazpkg
247 convert_arch() {
248 mkdir -p "$TMP_DIR/fs"
249 tar -xf "$PACKAGE_FILE" -C "$TMP_DIR/fs"
250 if [ -f "$TMP_DIR/fs/.PKGINFO" ]; then
251 cd "$TMP_DIR"
252 package=$( sed '/^pkgname/!d;s/.*= //' fs/.PKGINFO)
253 version=$( sed '/^pkgver/!d;s/.*= //' fs/.PKGINFO)
254 descrip=$( sed '/^pkgdesc/!d;s/.*= //' fs/.PKGINFO)
255 url=$( sed '/^url/!d;s/.*= //' fs/.PKGINFO)
256 maintainer=$(sed '/^packager/!d;s/.*= //' fs/.PKGINFO)
257 file="$package-$version"
258 mkdir "$file"
259 mv fs "$file"
260 cat > "$file/receipt" <<EOT
261 # SliTaz package receipt.
262 # generated by tazpkg from Archlinux package $(basename "$PACKAGE_FILE")
263 PACKAGE="$package"
264 VERSION="$version"
265 CATEGORY="misc"
266 SHORT_DESC="$descrip"
267 WEB_SITE="$url"
268 MAINTAINER="$maintainer"
269 DEPENDS="$(find_depends .)"
270 EOT
271 show_unresolved_lib "$file/receipt"
272 rm -f $file/fs/.[A-Z]*
273 tazpkg pack "$file"
274 mv "$file.tazpkg" "$TOP_DIR"
275 else
276 _ 'File "%s" does not look like %s package!' "$PACKAGE_FILE" 'Archlinux/Alpine'
277 fi
278 cd "$TOP_DIR"
279 rm -rf "$TMP_DIR"
280 }
283 # get package and version from PACKAGE_FILE
285 parse_pkgname() {
286 debug "parse_pkgname('$1', '$2')"
287 package=$(basename "${2:-$PACKAGE_FILE}" "$1")
288 IFS='-'
289 set -- "$package"
290 unset IFS
291 package="$1"
292 version="$2"
293 if [ -z "$version" ]; then
294 package=${1%%-[0-9\.]*}
295 version=${1#$package-}
296 fi
297 file="$package-$version"
298 mkdir "$file"
299 debug " package='$package' version='$version' file='$file'"
300 }
303 finish_convert_puppy() {
304 rm -f fs/*.specs
305 mkdir "$file"; mv fs "$file"
306 cat > "$file/receipt" <<EOT
307 # SliTaz package receipt.
308 # generated by tazpkg from puppy package $(basename "$PACKAGE_FILE")
309 PACKAGE="$package"
310 VERSION="$version"
311 CATEGORY="misc"
312 SHORT_DESC="$desc"
313 WEB_SITE="http://puppylinux.org/"
314 MAINTAINER="nobody@slitaz.org"
315 DEPENDS="$(find_depends .)"
316 EOT
317 show_unresolved_lib "$file/receipt"
318 for i in install uninstall; do
319 if [ -f "$file/fs/p$i.sh" ]; then
320 SEPARATOR="EOT$RANDOM"
321 cat >> "$file/receipt" <<EOT
323 post_$i()
324 {
325 chroot \$1/ sh - <<$SEPARATOR
326 cd /
327 $(sed -e 's/\\/\\\\/g' -e 's/\$/\\$/g' < "$file/fs/p$i.sh" ; rm -f "$file/fs/p$i.sh")
328 $SEPARATOR
329 }
330 EOT
331 fi
332 done
333 sed -i 's/post_uninstall/post_remove/' "$file/receipt"
334 tazpkg pack "$file"
335 mv "$file.tazpkg" "$TOP_DIR"
336 cd "$TOP_DIR"
337 rm -rf "$TMP_DIR"
338 }
341 # convert a .sfs package to .tazpkg
343 convert_sfs() {
344 [ -n "$(which unsquashfs)" ] || tazpkg get-install squashfs
345 if ! unsquashfs -l "$PACKAGE_FILE" | grep -q squashfs-root/pet.specs$ ; then
346 _ 'File "%s" does not look like %s package!' "$PACKAGE_FILE" 'Puppy'
347 return 1
348 fi
349 mkdir -p "$TMP_DIR"
350 cd "$TMP_DIR"
351 parse_pkgname .sfs
352 unsquashfs "$PACKAGE_FILE"
353 mv squashfs-root fs
354 set -- $(cat fs/pet.specs)
355 desc="$10"
356 finish_convert_puppy
357 }
360 # convert a .pet package to .tazpkg
362 convert_pet() {
363 debug "convert_pet()"
364 mkdir -p "$TMP_DIR"
365 cd "$TMP_DIR"
366 parse_pkgname .pet
367 busybox tar -xzf "$PACKAGE_FILE"
369 # Get package description
370 PET_SPECS="$(find $TMP_DIR -maxdepth 2 -type f -name 'pet.specs')"
371 if [ -e "$PET_SPECS" ]; then
372 debug "pet.specs with '|'"
373 desc="$(awk -F'|' '{print $10}' $PET_SPECS)"
374 else
375 PET_SPECS="$(find $TMP_DIR -maxdepth 2 -type f -name '*.pet.specs')"
376 if [ -e "$PET_SPECS" ]; then
377 desc="$(. "$PET_SPECS"; echo "$PETMENUDESCR")"
378 else
379 DESKTOP="$(find $TMP_DIR -type f -name '*.desktop' | head -n1)"
380 if [ -n "$DESKTOP" ]; then
381 desc="$(awk -F'=' '($1=="Name"){print $2}' $DESKTOP)"
382 fi
383 fi
384 fi
385 [ -z "$desc" ] && desc="$package"
386 debug "desc='$desc'"
387 mv $package*/ fs
388 finish_convert_puppy
389 }
392 # convert a .sb package to .tazpkg
394 convert_sb() {
395 [ -n "$(which unsquashfs)" ] || tazpkg get-install squashfs
396 if ! unsquashfs -l "$PACKAGE_FILE" | grep -q squashfs-root/var/log/removed_scripts ; then
397 _ 'File "%s" does not look like %s package!' "$PACKAGE_FILE" 'Slax'
398 return 1
399 fi
400 mkdir -p "$TMP_DIR"
401 cd "$TMP_DIR"
402 unsquashfs "$PACKAGE_FILE"
403 mv squashfs-root fs
404 parse_pkgname '' $(cat fs/var/log/packages/* | sed '/PACKAGE NAME:/!d;s/.*: *//')
405 desc="$(cat fs/var/log/packages/* | sed '/^PACKAGE DESCRIPTION:/,$!d;N;s/.*: //;q')"
406 cat fs/var/log/packages/* | sed '/^PACKAGE DESCRIPTION:/,/FILE LIST/!d;s/.*://;/^$/d' > "$file/description.txt"
407 mv fs "$file"
408 cat > "$file/receipt" <<EOT
409 # SliTaz package receipt.
410 # generated by tazpkg from slax package $(basename "$PACKAGE_FILE")
411 PACKAGE="$package"
412 VERSION="$version"
413 CATEGORY="misc"
414 SHORT_DESC="$desc"
415 WEB_SITE="http://www.slax.org/"
416 MAINTAINER="nobody@slitaz.org"
417 DEPENDS="$(find_depends .)"
418 EOT
419 show_unresolved_lib "$file/receipt"
420 [ -f $file/fs/var/log/scripts/$package* ] && cat >> "$file/receipt" <<EOM
422 post_install()
423 {
424 chroot \$1/ sh - << EOT
425 cd /
426 $(cat $file/fs/var/log/scripts/$package* | sed -e 's/\\/\\\\/g' | sed -e 's/\$/\\$/g')
427 EOT
428 }
429 EOM
430 tazpkg pack "$file"
431 mv "$file.tazpkg" "$TOP_DIR"
432 cd "$TOP_DIR"
433 rm -rf "$TMP_DIR"
434 }
437 # convert a .tgz package to .tazpkg
439 convert_tgz() {
440 parse_pkgname
441 mkdir -p "$TMP_DIR/$file/fs"
442 case "$PACKAGE_FILE" in
443 *.txz) tar -xJf "$PACKAGE_FILE" -C "$TMP_DIR/$file/fs" ;;
444 *.tgz) tar -xzf "$PACKAGE_FILE" -C "$TMP_DIR/$file/fs" ;;
445 esac
446 cd "$TMP_DIR"
447 if [ -d "$file/fs/install" ]; then
448 descrip=$(sed "/^$package/!d;s/.*(\\(.*\\)).*/\\1/;q" \
449 "$file/fs/install/slack-desc")
450 cat > "$file/receipt" <<EOT
451 # SliTaz package receipt.
452 # generated by tazpkg from slackware package $(basename "$PACKAGE_FILE")
453 PACKAGE="$package"
454 VERSION="$version"
455 CATEGORY="misc"
456 SHORT_DESC="$descrip"
457 WEB_SITE="http://www.slackware.com/packages/"
458 MAINTAINER="nobody@slitaz.org"
459 DEPENDS="$(find_depends .)"
460 EOT
461 show_unresolved_lib "$file/receipt"
462 [ -f "$file/fs/install/doinst.sh" ] && cat >> "$file/receipt" <<EOM
464 post_install()
465 {
466 chroot \$1/ sh - << EOT
467 cd /
468 $(sed -e 's/\\/\\\\/g' -e 's/\$/\\$/g' < "$file/fs/install/doinst.sh")
469 EOT
470 }
471 EOM
472 sed "/^$package/:d;s/^$package://" \
473 "$file/fs/install/slack-desc" > "$file/description.txt"
474 [ -s "$file/description.txt" ] || rm -f "$file/description.txt"
475 rm -rf "$file/fs/install"
476 tazpkg pack "$file"
477 mv "$file.tazpkg" "$TOP_DIR"
478 else
479 _ 'File "%s" does not look like %s package!' "$PACKAGE_FILE" 'Slackware'
480 fi
481 cd "$TOP_DIR"
482 rm -rf "$TMP_DIR"
483 }
486 # convert a .deb package to .tazpkg
488 convert_deb() {
489 mkdir -p "$TMP_DIR"
490 dpkg-deb -e "$PACKAGE_FILE" "$TMP_DIR"
491 package=$( sed '/^ *Package:/!d;s/.*: //' "$TMP_DIR/control")
492 version=$( sed '/^ *Version:/!d;s/.*: //' "$TMP_DIR/control")
493 descrip=$( sed '/^ *Description:/!d;s/.*: //' "$TMP_DIR/control")
494 homepage=$(sed '/^ *Homepage:/!d;s/.*: //' "$TMP_DIR/control")
495 target=$( sed '/^ *Architecture:/!d;s/.*: //' "$TMP_DIR/control")
496 case "$target" in
497 i386|all)
498 file="$package-$version"
499 mkdir -p "$TMP_DIR/$file/fs/"
500 dpkg-deb -x "$PACKAGE_FILE" "$TMP_DIR/$file/fs"
501 cd "$TMP_DIR"
502 cat > "$file/receipt" <<EOT
503 # SliTaz package receipt.
504 # generated by tazpkg from debian package $(basename "$PACKAGE_FILE")
505 PACKAGE="$package"
506 VERSION="$version"
507 CATEGORY="misc"
508 SHORT_DESC="$descrip"
509 WEB_SITE="${homepage:-http://packages.debian.org/search?keywords=$package}"
510 MAINTAINER="nobody@slitaz.org"
511 EOT
512 LICENSE=$(grep /usr/share/common-licenses/ \
513 "$PACKAGE_FILE" $TMP_DIR/$file/fs/usr/share/doc/*/copyright | \
514 sed 's|.*common-licenses/\([-\.A-Za-z0-9]*\).*|\1|;s|[-\.]$||;q')
515 [ -n "$LICENSE" ] && echo "LICENSE=\"$LICENSE\"" >> "$file/receipt"
516 echo "DEPENDS=\"$(find_depends .)\"" >> "$file/receipt"
517 [ -s 'conffiles' ] && cat >> "$file/receipt" <<EOT
518 CONFIG_FILES="$(cat conffiles)"
519 EOT
520 show_unresolved_lib "$file/receipt"
521 awk '
522 {
523 if (/^ / && show)
524 print substr($0,2);
525 else
526 show=0;
527 if (/^Description/)
528 show=1;
529 }' < "$TMP_DIR/control" > "$file/description.txt"
530 sed -i 's/^\.$//' "$file/description.txt"
531 [ -s "$file/description.txt" ] || rm -f "$file/description.txt"
532 tazpkg pack "$file"
533 mv "$file.tazpkg" "$TOP_DIR"
534 ;;
535 *)
536 _ 'Invalid target: %s (expected i386)' "$target"
537 ;;
538 esac
539 cd "$TOP_DIR"
540 rm -rf "$TMP_DIR"
541 }
544 # convert a .rpm package to .tazpkg
546 convert_rpm() {
547 mkdir -p "$TMP_DIR"
548 cp "$PACKAGE_FILE" "$TMP_DIR"
549 PACKAGE_FILE="$TMP_DIR/$(basename "$PACKAGE_FILE")"
550 rpm -qip "$PACKAGE_FILE" | awk -v pkg="$(basename "$PACKAGE_FILE")" '
551 BEGIN {
552 goturl=0;
553 printf "# SliTaz package receipt.\n";
554 printf "# generated by tazpkg from rpm package %s\n", pkg;
555 }
556 {
557 if (/^Name/) { name=$3; printf "PACKAGE=\"%s\"\n", $3; }
558 if (/^Version/) printf "VERSION=\"%s-", $3;
559 if (/^Release/) printf "%s\"\n", $3;
560 if (/^Summary/) printf "SHORT_DESC=\"%s\"\n", substr($0, 15);
561 if (/^URL/) { goturl=1; printf "WEB_SITE=\"%s\"\n", $3; }
562 }
563 END {
564 if (goturl == 0)
565 printf "WEB_SITE=\"http://rpmfind.net/linux/rpm2html/search.php?query=%s\"\n",name;
566 printf "CATEGORY=\"misc\"\n";
567 printf "MAINTAINER=\"nobody@slitaz.org\"\n";
568 }
569 ' > "$TMP_DIR/receipt"
570 . "$TMP_DIR/receipt"
571 file="$PACKAGE-$VERSION"
572 mkdir -p "$TMP_DIR/$file/fs/"
573 mv "$TMP_DIR/receipt" "$TMP_DIR/$file"
574 rpm -qip "$PACKAGE_FILE" | awk '
575 BEGIN { show=0 }
576 {
577 if (show) print;
578 if (/^Description/) show=1;
579 }
580 ' > "$TMP_DIR/$file/description.txt"
581 cd "$TMP_DIR/$file/fs/"
582 rpm2cpio "$PACKAGE_FILE" | cpio -idm --quiet
583 # rpm2cpio can't extract some new RPMs
584 if [ $? -eq 1 ]; then
585 if [ ! -e "$INSTALLED/p7zip-full/receipt" ]; then
586 boldify "$(_ 'Unable to extract the RPM using standard tools (rpm2cpio).')"
587 confirm "$(_n 'Do you want to install "%s" package? (y/N)' 'p7zip-full')"
588 if [ $? -eq 0 ]; then
589 tazpkg -gi p7zip-full
590 else
591 rm -rf "$TMP_DIR"
592 exit 1
593 fi
594 fi
595 # we may already have 7z or may have just installed it in the step above
596 if [ -e "$INSTALLED/p7zip-full/receipt" ]; then
597 7z x -so "$PACKAGE_FILE" | cpio -idm --quiet
598 fi
599 fi
600 cd ../..
601 echo "DEPENDS=\"$(find_depends .)\"" >> "$TMP_DIR/$file/receipt"
602 show_unresolved_lib "$TMP_DIR/$file/receipt"
603 tazpkg pack "$file"
604 mv "$file.tazpkg" "$TOP_DIR"
605 cd "$TOP_DIR"
606 rm -rf "$TMP_DIR"
607 }
610 # convert a .xbps package to .tazpkg (http://repo.voidlinux.eu/current/)
612 xbpstag() {
613 sed "/<key>$1<\/key>/!d{n;s/.*>\\(.*\\)<.*/\\1/}" \
614 < fs/props.plist | sed \$!d
615 }
617 convert_xbps() {
618 mkdir -p "$TMP_DIR/fs"
619 ( xzcat "$PACKAGE_FILE" || bzcat "$PACKAGE_FILE" || zcat "$PACKAGE_FILE" ) | \
620 tar -xf - -C "$TMP_DIR/fs"
622 cd "$TMP_DIR"
623 HOST_ARCH=$(xbpstag architecture)
624 case "$HOST_ARCH" in
625 i686) HOST_ARCH='i486';;
626 *) _ 'Arch "%s" not supported.' "$HOST_ARCH"
627 HOST_ARCH='';;
628 esac
630 if [ -n "$HOST_ARCH" ]; then
631 package=$(xbpstag pkgname)
632 version=$(xbpstag version)
633 file="$package-$version"
634 mkdir "$file"
635 cat > "$file/receipt" <<EOT
636 # SliTaz package receipt.
637 # generated by tazpkg from package $(basename "$PACKAGE_FILE")
638 PACKAGE="$package"
639 VERSION="$version"
640 CATEGORY="misc"
641 SHORT_DESC="$(xbpstag short_desc)"
642 WEB_SITE="$(xbpstag homepage)"
643 MAINTAINER="$(xbpstag maintainer | sed 's/>/>/;s/</</')"
644 LICENSE="$(xbpstag license | sed 's/-//g')"
645 HOST_ARCH="$HOST_ARCH"
646 CONFIG_FILES="$(sed '/<key>conf_files<\/key>/,/<key>/!d;/array>/d;/<key>/d;s/.*>\(.*\)<.*/\1/' fs/props.plist)"
648 DEPENDS="$(find_depends .)"
650 EOT
651 while read script func ; do
652 [ -s "fs/$script" ] && cat >> "$file/receipt" <<EOT
653 xbps_$func()
654 {
655 set +e
656 $(cat "fs/$script")
657 }
659 pre_$func()
660 {
661 xbps_$func pre $package $version yes /etc/xbps.conf $HOST_ARCH
662 }
664 post_$func()
665 {
666 xbps_$func post $package $version yes /etc/xbps.conf $HOST_ARCH
667 }
669 EOT
670 rm -f "fs/$script"
671 done <<EOT
672 INSTALL install
673 REMOVE remove
674 EOT
675 rm -f fs/*.plist
676 mv fs "$package-$version"
677 tazpkg pack "$package-$version"
678 mv "$package-$version.tazpkg" "$TOP_DIR"
679 fi
680 cd "$TOP_DIR"
681 rm -rf "$TMP_DIR"
682 }
685 finish_convert_tinycore() {
686 cat > "$file/receipt" <<EOT
687 # SliTaz package receipt.
688 # generated by tazpkg from tinycore package $(basename "$PACKAGE_FILE")
689 PACKAGE="$package"
690 VERSION="$version"
691 CATEGORY="misc"
692 SHORT_DESC="tinycore package $(basename "$PACKAGE_FILE")"
693 WEB_SITE="http://tinycorelinux.net/"
694 MAINTAINER="nobody@slitaz.org"
695 DEPENDS="$(find_depends .)"
696 EOT
697 show_unresolved_lib "$file/receipt"
698 script="$file/fs/usr/local/tce.installed/$PACKAGE"
699 [ -f "$script" ] && cat >> "$file/receipt" <<EOM
701 post_install()
702 {
703 chroot \$1/ sh - << EOT
704 cd /
705 $(sed -e 's/\\/\\\\/g' -e 's/\$/\\$/g' < $script)
706 EOT
707 }
708 EOM
709 [ -d "$file/fs/usr/local/tce.installed" ] &&
710 rm -rf "$file/fs/usr/local/tce.installed"
711 tazpkg pack "$file"
712 mv "$file.tazpkg" "$TOP_DIR"
713 cd "$TOP_DIR"
714 rm -rf "$TMP_DIR"
715 }
718 # convert a .tce package to .tazpkg
720 convert_tce() {
721 if ! tar -tzf "$PACKAGE_FILE" | grep -q ^usr/local ; then
722 _ 'File "%s" does not look like %s package!' "$PACKAGE_FILE" 'Tinycore'
723 return 1
724 fi
725 mkdir -p "$TMP_DIR"
726 cd "$TMP_DIR"
727 case "$PACKAGE_FILE" in
728 *.tcel) parse_pkgname .tcel ;;
729 *.tcem) parse_pkgname .tcem ;;
730 *) parse_pkgname .tce ;;
731 esac
732 mkdir -p "$file/fs"
733 tar -xzf "$PACKAGE_FILE" -C "$file/fs"
734 finish_convert_tinycore
735 }
738 # convert a .tcz package to .tazpkg
740 convert_tcz() {
741 [ -n "$(which unsquashfs)" ] || tazpkg get-install squashfs
742 if ! unsquashfs -l "$PACKAGE_FILE" | grep -q squashfs-root/ ; then
743 _ 'File "%s" does not look like %s package!' "$PACKAGE_FILE" 'Tinycore'
744 return 1
745 fi
746 mkdir -p "$TMP_DIR"
747 cd "$TMP_DIR"
748 parse_pkgname .tcz
749 unsquashfs "$PACKAGE_FILE"
750 mv squashfs-root "$file/fs"
751 finish_convert_tinycore
752 }
756 PACKAGE_FILE="$(realpath "$PACKAGE_FILE")"
757 debug "PACKAGE_FILE='$PACKAGE_FILE'"
758 if [ "$(dd if="$PACKAGE_FILE" bs=8 count=1 skip=1 2>/dev/null)" == 'debian-b' ]; then
759 convert_deb
760 else
761 case "$PACKAGE_FILE" in
762 *.deb|*.udeb) convert_deb;;
763 *.rpm) convert_rpm;;
764 *.sb) convert_sb;;
765 *.sfs) convert_sfs;;
766 *.pet) convert_pet;;
767 *.txz|*.tgz) convert_tgz;;
768 *.cards.tar.xz) convert_nutyx;;
769 *.apk|*.pkg.tar.gz|*.pkg.tar.xz) convert_arch;;
770 *.ipk|*.opk) convert_ipk;;
771 *.spack) convert_spack;;
772 *.tar.bz2) convert_upkg;;
773 *.xbps) convert_xbps;;
774 *.tce|*.tcel|*.tcem) convert_tce;;
775 *.tcz) convert_tcz;;
776 *) _ 'Unsupported format';;
777 esac
778 fi
780 exit 0