Code fixes and cleanup in genpackagelist script
This commit is contained in:
parent
adf409e52b
commit
d7e64d42b9
1 changed files with 96 additions and 97 deletions
193
genpackagelist
193
genpackagelist
|
@ -1,125 +1,124 @@
|
|||
#!/bin/sh
|
||||
# Originally written by Jason Woodward, https://software.jaos.org/
|
||||
# Modified for use in SMLinux
|
||||
#
|
||||
# This script creates PACKAGES.TXT, CHECKSUMS.md5 and .meta files for use with slapt-get
|
||||
# Typical usage: put all the final packages inside a directory. copy genpackagelist to
|
||||
# that directory and then run
|
||||
# "./genpackagelist all"
|
||||
#
|
||||
# This will create PACKAGES.TXT{.gz},
|
||||
# CHECKSUMS.md5{.gz} and all the .meta files. Copy those files to a suitable directory
|
||||
# which will be queried by slapt-get.
|
||||
#!/bin/bash
|
||||
|
||||
function gen_packages_txt {
|
||||
# Originally written by Jason Woodward, https://software.jaos.org/
|
||||
# Modified extensively for use in SMLinux
|
||||
#
|
||||
|
||||
all() {
|
||||
echo "Generating meta files, package lists and md5sum files..."
|
||||
for pkg in $(find . -type f -regex '.*\.[tgblzikx]+$' -print)
|
||||
do
|
||||
gen_meta $pkg
|
||||
done
|
||||
|
||||
# Generate package text files
|
||||
echo '' > PACKAGES.TXT
|
||||
find . -type f -name '*.meta' -exec cat {} \; >> PACKAGES.TXT
|
||||
cat PACKAGES.TXT | gzip -9 -c - > PACKAGES.TXT.gz
|
||||
}
|
||||
|
||||
function gen_md5_checksums {
|
||||
# Generate md5 files
|
||||
echo '' > CHECKSUMS.md5
|
||||
find . -type f -regextype posix-egrep -regex '.*\.[tgblzikx]+$' -exec md5sum {} \; >> CHECKSUMS.md5
|
||||
cat CHECKSUMS.md5 | gzip -9 -c - > CHECKSUMS.md5.gz
|
||||
|
||||
}
|
||||
|
||||
function gen_meta {
|
||||
if [ ! -f $1 ]; then
|
||||
help() {
|
||||
cat << EOF
|
||||
SMLinux package list generator
|
||||
|
||||
This program creates PACKAGES.TXT, CHECKSUMS.md5 and .meta files for use with slapt-get package manager.
|
||||
|
||||
$ ls
|
||||
CHECKSUMS.md5 CHECKSUMS.md5.gz
|
||||
PACKAGES.TXT PACKAGES.TXT.gz
|
||||
packages/
|
||||
|
||||
Typical usage: put all the final packages inside a directory. copy genpackagelist to
|
||||
that directory and then run
|
||||
|
||||
$ ./genpackagelist -a
|
||||
|
||||
This will create PACKAGES.TXT{.gz}, CHECKSUMS.md5{.gz} and <package>.meta files
|
||||
Copy those files to a web server's DOCROOT directory and point slapt-get to it by
|
||||
creating a new SOURCE line in /etc/slapt-get/slapt-get.rc:
|
||||
|
||||
SOURCE=http://example.com/path/to/above/files:CUSTOM
|
||||
|
||||
Then run
|
||||
$ sudo slapt-get -u
|
||||
$ sudo slapt-get -i <package>
|
||||
|
||||
Usage:
|
||||
-a : Generate package lists, checksum and meta files
|
||||
|
||||
-h : Display this message
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
gen_meta() {
|
||||
# Begin subshell
|
||||
(
|
||||
tarball="$1"
|
||||
if [[ ! -f $tarball ]]; then
|
||||
echo "File not found: $1"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [ "`echo $1|grep -E '(.*{1,})\-(.*[\.\-].*[\.\-].*).[tgblzikx]{2,}[ ]{0,}$'`" == "" ]; then
|
||||
if [ "$(echo $tarball|grep -E '(.*{1,})\-(.*[\.\-].*[\.\-].*).[tgblzikx]{2,}[ ]{0,}$')" == "" ]; then
|
||||
return;
|
||||
fi
|
||||
|
||||
PKGEXT=${1##*.}
|
||||
case $PKGEXT in
|
||||
tgz) DECOMPRESS=gzip ;;
|
||||
tbz) DECOMPRESS=bzip2 ;;
|
||||
tlz) DECOMPRESS=lzip ;;
|
||||
txz) DECOMPRESS=xz ;;
|
||||
pkgext=${tarball##*.}
|
||||
case $pkgext in
|
||||
tgz) decompress=gzip ;;
|
||||
tbz) decompress=bzip2 ;;
|
||||
tlz) decompress=lzip ;;
|
||||
txz) decompress=xz ;;
|
||||
esac
|
||||
|
||||
echo "Generating meta files, package lists and md5sum files for $1..."
|
||||
echo "Processing $tarball..."
|
||||
|
||||
# Create a unique temporary directory and untar the package inside it
|
||||
TEMPDIR=$(mktemp -d $1.XXXXXX)
|
||||
tar -xf $1 -C"$TEMPDIR"
|
||||
tempdir=$(mktemp -d $tarball.XXXXXX)
|
||||
tar -xf $tarball -C"$tempdir"
|
||||
|
||||
NAME=$(echo $1 | sed -re "s/(.*\/)(.*.$PKGEXT)$/\2/")
|
||||
LOCATION=$(echo $1 | sed -re "s/(.*)\/(.*.$PKGEXT)$/\1/")
|
||||
SIZE=$(du -bk $1 | awk '{print $1}')
|
||||
USIZE=$(expr $( $DECOMPRESS -dc $1 | wc -c) / 1024)
|
||||
name=$(echo $tarball | sed -re "s/(.*\/)(.*.$pkgext)$/\2/")
|
||||
|
||||
if [ ! -f "$TEMPDIR/install/slack-required" ]; then
|
||||
echo "WARNING: slack-required was not found inside $1"
|
||||
else
|
||||
REQUIRED="$(cat "$TEMPDIR/install/slack-required" | xargs -r -iZ echo -n "Z," | sed -e "s/,$//")"
|
||||
location=$(echo $tarball | sed -re "s/(.*)\/(.*.$pkgext)$/\1/")
|
||||
size=$(du -bk $tarball | awk '{print $1}')
|
||||
usize=$(expr $( $decompress -dc $tarball | wc -c) / 1024)
|
||||
|
||||
# There is only one SMBuild file per package shipped in all SMLinux packages
|
||||
buildfile="$(find $tempdir/share/doc/ -name "*.SMBuild")"
|
||||
source $buildfile
|
||||
#name="$app"
|
||||
|
||||
metafile=${name%$pkgext}meta
|
||||
echo "PACKAGE NAME: $name" > $location/$metafile
|
||||
if [ -n "$dl_url" ]; then
|
||||
echo "PACKAGE MIRROR: $dl_url" >> $location/$metafile
|
||||
fi
|
||||
echo "PACKAGE LOCATION: $location" >> $location/$metafile
|
||||
echo "PACKAGE SIZE (compressed): $size K" >> $location/$metafile
|
||||
echo "PACKAGE SIZE (uncompressed): $usize K" >> $location/$metafile
|
||||
echo "PACKAGE REQUIRED: $requires" >> $location/$metafile
|
||||
|
||||
if [ -f "$TEMPDIR/install/slack-conflicts" ]; then
|
||||
CONFLICTS="$(cat "$TEMPDIR/install/slack-conflicts" | xargs -r -iZ echo -n "Z," | sed -e "s/,$//")"
|
||||
fi
|
||||
|
||||
if [ -f "$TEMPDIR/install/slack-conflicts" ]; then
|
||||
SUGGESTS=$(cat "$TEMPDIR/install/slack-suggests" | xargs -r)
|
||||
fi
|
||||
|
||||
METAFILE=${NAME%$PKGEXT}meta
|
||||
echo "PACKAGE NAME: $NAME" > $LOCATION/$METAFILE
|
||||
if [ -n "$DL_URL" ]; then
|
||||
echo "PACKAGE MIRROR: $DL_URL" >> $LOCATION/$METAFILE
|
||||
fi
|
||||
echo "PACKAGE LOCATION: $LOCATION" >> $LOCATION/$METAFILE
|
||||
echo "PACKAGE SIZE (compressed): $SIZE K" >> $LOCATION/$METAFILE
|
||||
echo "PACKAGE SIZE (uncompressed): $USIZE K" >> $LOCATION/$METAFILE
|
||||
echo "PACKAGE REQUIRED: $REQUIRED" >> $LOCATION/$METAFILE
|
||||
echo "PACKAGE CONFLICTS: $CONFLICTS" >> $LOCATION/$METAFILE
|
||||
echo "PACKAGE SUGGESTS: $SUGGESTS" >> $LOCATION/$METAFILE
|
||||
|
||||
echo "PACKAGE DESCRIPTION:" >> $LOCATION/$METAFILE
|
||||
if [ ! -f "$TEMPDIR/install/slack-desc" ]; then
|
||||
echo "WARNING: slack-desc was not found inside $1. "
|
||||
else
|
||||
cat "$TEMPDIR/install/slack-desc" | grep -E '\w+\:'| grep -v '^#' >> $LOCATION/$METAFILE
|
||||
fi
|
||||
echo "" >> $LOCATION/$METAFILE
|
||||
echo "Done!"
|
||||
rm -rf $TEMPDIR
|
||||
echo "PACKAGE DESCRIPTION: $desc" >> $location/$metafile
|
||||
echo "" >> $location/$metafile
|
||||
echo "...done!"
|
||||
rm -rf $tempdir
|
||||
)
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
pkg)
|
||||
if [ -n "$2" ]; then
|
||||
gen_meta $2
|
||||
else
|
||||
echo "$0 [pkg [file]|all|new|PACKAGESTXT|MD5]"
|
||||
fi
|
||||
;;
|
||||
all)
|
||||
for pkg in `find . -type f -regex '.*\.[tgblzikx]+$' -print`
|
||||
do
|
||||
gen_meta $pkg
|
||||
done
|
||||
$0 PACKAGESTXT
|
||||
$0 MD5
|
||||
;;
|
||||
new)
|
||||
for pkg in `find . -type f -regex '.*\.[tgblzikx]+$' -print`
|
||||
do
|
||||
if [ ! -f ${pkg%${pkg##*.}}meta ]; then
|
||||
gen_meta $pkg
|
||||
fi
|
||||
done
|
||||
;;
|
||||
PACKAGESTXT)
|
||||
gen_packages_txt
|
||||
;;
|
||||
MD5)
|
||||
gen_md5_checksums
|
||||
;;
|
||||
*)
|
||||
echo "$0 [pkg [file]|all|new|PACKAGESTXT|MD5]"
|
||||
;;
|
||||
while getopts ':a' option ; do
|
||||
case "$option" in
|
||||
a) all ;;
|
||||
*) help ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $OPTIND -le 1 ]] ; then
|
||||
help
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue