stages: 2/01-busybox: update .config
[dragora.git] / packages / makeTags
blob1e3b00946b3fc0c9ceec8cca6407fa2b534abffa
1 #! /bin/sh -
3 # Gets information from packages to create a checklist for
4 # the installer of Dragora (also know as "tagfiles")
6 # Copyright (c) 2019 Matias Fonzo, <selk@dragora.org>.
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
20 getSize()
22 lzip_output="$(plzip -tvvv $1 2>&1)"
24 # To obtain the uncompressed, compressed size
25 echo $lzip_output | awk '{ print $8 $10 }' | \
26 while IFS=, read -r decompressed compressed
28 echo "Decompressed size $(( $decompressed / 1024 ))K, Compressed size $(( ${compressed%.} / 1024 ))K"
29 done
31 unset lzip_output
34 echo "Deleting any previous (.tmp) tagfile ..."
35 find . -type f -name 'tagfile*' -exec rm -f '{}' +
37 set -e
38 umask 022
40 # Search all .tlz packages
41 for meta in $(find . -type f -name '*.tlz')
43 # Ignore some package names
44 case $meta in
45 *_pass?*)
46 echo " ${meta}: Ignored."
47 continue;
49 esac
50 if test ! -e "${meta}.txt"
51 then
52 echo "Error ${meta##*/} does not have a meta tag file." 1>&2
53 exit 99;
56 meta="${meta}.txt"
57 directory=$(dirname -- "$meta")
58 category="${directory##*/}"
60 # Determine output level for those series with sub-directories
61 case $directory in
62 */modules/* | */xorg/*)
63 output_level=../
64 parent_level="$(dirname -- $directory)"
65 parent_level="$(basename -- $parent_level)"
66 parent_level=${parent_level}_
68 esac
70 echo "Extracting information from $meta ..."
71 . $meta
73 cd -- "$directory"
74 echo " Adding information to ${output_level}tagfile-${parent_level}${category}.tmp"
75 echo "${pkgname}:${blurb}:ON:Version ${pkgversion} - $(getSize $(basename -- "${meta%.txt}"))" \
76 >> "${output_level}tagfile-${parent_level}${category}.tmp"
78 unset output_level parent_level
79 done
81 echo "Removing temporal tagfile(s) and sorting the final ones ..."
82 for tagfile in ./*/*/tagfile*.tmp
84 LC_COLLATE=C sort -- "$tagfile" > "${tagfile%.tmp}"
85 rm -f -- "$tagfile"; # Delete temporary tagfile.
86 done
88 echo "All done."