Added genpacklist, a script that extracts package info for use in slapt-get program
Removed redundant code in bldpkg
This commit is contained in:
parent
15e8567f19
commit
adf409e52b
2 changed files with 139 additions and 17 deletions
31
bldpkg
31
bldpkg
|
@ -56,8 +56,7 @@ sourcebuildfile() {
|
|||
source "$buildfile"
|
||||
else
|
||||
# We expect a filename as part of -f argument
|
||||
echo "[ERROR] No build file to source from! If you used -f argument, make sure it is"
|
||||
echo "[ERROR] the first argument pointing to a build file before any other argument."
|
||||
echo "[ERROR] No build file to source from!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
@ -73,7 +72,7 @@ setbuildfile() {
|
|||
|
||||
# Function to invoke bash shell's -x mode for troubleshooting
|
||||
tracemode() {
|
||||
set -x
|
||||
set -xv
|
||||
}
|
||||
|
||||
# Function to enable building of packages with debug symbols using -g3 argument
|
||||
|
@ -94,13 +93,12 @@ displaysummary() {
|
|||
|
||||
# Function to set number of make jobs, overrides those in bldpkg.conf
|
||||
setcputhreads() {
|
||||
cputhreads0="$OPTARG"
|
||||
cputhreads="$OPTARG"
|
||||
# Validate if the argument is a number. If not, throw an error and exit.
|
||||
if ! echo "$cputhreads0" | egrep -q '^[0-9]+$' ; then
|
||||
if ! echo "$cputhreads" | egrep -q '^[0-9]+$' ; then
|
||||
echo "[ERROR] Invalid CPU job number. Please try again."
|
||||
exit 1
|
||||
fi
|
||||
cputhreads="$cputhreads0"
|
||||
}
|
||||
|
||||
# Generate sha512sums in the build file
|
||||
|
@ -802,7 +800,7 @@ mkandenterbuilddir() {
|
|||
rm -rf "$pkg"
|
||||
|
||||
# Now create all essential build-related directories
|
||||
mkdir -p "$tmp" "$pkg" "$pkgdocs" "$pkgdest"
|
||||
mkdir -p "$tmp" "$pkg/install" "$pkgdocs" "$pkgdest"
|
||||
|
||||
echo "[INFO] Leaving source directory $srcdir"
|
||||
echo "[INFO] Entering build directory $tmp"
|
||||
|
@ -926,7 +924,6 @@ mkfinalpkg() {
|
|||
done
|
||||
|
||||
echo "[INFO] Copying post-install files..."
|
||||
mkdir -p "$pkg/install"
|
||||
|
||||
[[ -e $srcdir/doinst.sh ]] && cp "$srcdir/doinst.sh" "$pkg/install/"
|
||||
|
||||
|
@ -1011,10 +1008,10 @@ EOF
|
|||
SECONDS=0
|
||||
|
||||
# Store package location inside this variable:
|
||||
packlocation="$pkgdest/$app-$version-$arch-$build.$pkgext"
|
||||
newpkglocation="$pkgdest/$app-$version-$arch-$build.$pkgext"
|
||||
|
||||
# Finally create the package
|
||||
/bin/makepkg -l y -c n "$packlocation"
|
||||
/bin/makepkg -l y -c n "$newpkglocation"
|
||||
pkgstatus=$?
|
||||
|
||||
echo "[INFO] Leaving staging directory $pkg"
|
||||
|
@ -1191,7 +1188,7 @@ prepbuildoutput() {
|
|||
bldstatus="$(echo -e "$colourg"'Successful! :-D' "$colourd")"
|
||||
|
||||
# Determine the compressed size
|
||||
packsize="$(du -bk "$packlocation" | awk '{print $1}')"
|
||||
packsize="$(du -bk "$newpkglocation" | awk '{print $1}')"
|
||||
|
||||
# Determine the uncompressed size
|
||||
packusize="$(echo $packusize1)"
|
||||
|
@ -1326,10 +1323,10 @@ EOF
|
|||
promptuser() {
|
||||
|
||||
# Extract package at the end of a build if autoextract is set to 1
|
||||
if [[ $autoextract = 1 ]] && [[ -z $autobuild ]] && [[ -n $packlocation ]] ; then
|
||||
if [[ $autoextract = 1 ]] && [[ -z $autobuild ]] && [[ -n $newpkglocation ]] ; then
|
||||
echo "[INFO] Extracting package installer inside $srcdir/test..."
|
||||
mkdir -p "$srcdir/test"
|
||||
tar xvf "$packlocation" -C "$srcdir/test"
|
||||
tar xvf "$newpkglocation" -C "$srcdir/test"
|
||||
echo ""
|
||||
echo "[INFO] '"$app"' package installer file successfully extracted"
|
||||
fi
|
||||
|
@ -1337,7 +1334,7 @@ promptuser() {
|
|||
# Prompt the user at the end of a build whether to extract contents of a newly-built installer into a subdirectory
|
||||
# called "test" inside the package source directory the build was manually initiated from. Has no effect on
|
||||
# autobuilds since they are simply installed right away.
|
||||
if [[ $extractprompt = 1 ]] && [[ -z $autobuild ]] && [[ -n $packlocation ]] ; then
|
||||
if [[ $extractprompt = 1 ]] && [[ -z $autobuild ]] && [[ -n $newpkglocation ]] ; then
|
||||
while true ; do
|
||||
echo
|
||||
echo "[NOTIFY] '"$app"' has been built and extractprompt is enabled in"
|
||||
|
@ -1351,7 +1348,7 @@ promptuser() {
|
|||
case $yn in
|
||||
[Yy]* ) echo "[INFO] Wise choice :-) ";
|
||||
mkdir -p "$srcdir/test"
|
||||
tar xvf "$packlocation" -C "$srcdir/test"
|
||||
tar xvf "$newpkglocation" -C "$srcdir/test"
|
||||
echo ""
|
||||
echo "[INFO] '"$app"' package installer file successfully extracted"
|
||||
break;;
|
||||
|
@ -1362,7 +1359,7 @@ promptuser() {
|
|||
|
||||
# Prompt the user at the end of a successful build whether to install the newly created package. Has no effect on
|
||||
# autobuilds because packages there are installed automatically.
|
||||
if [[ $installprompt = 1 ]] && [[ -z $autobuild ]] && [[ -n $packlocation ]] ; then
|
||||
if [[ $installprompt = 1 ]] && [[ -z $autobuild ]] && [[ -n $newpkglocation ]] ; then
|
||||
while true ; do
|
||||
echo
|
||||
echo "[NOTIFY] '"$app"' successfully built and installprompt is enabled in the bldpkg.conf file."
|
||||
|
@ -1370,7 +1367,7 @@ promptuser() {
|
|||
read -r -p "[NOTIFY] Would you like to install/upgrade it? (y/N) " yn
|
||||
case $yn in
|
||||
[Yy]* ) echo "[INFO] Wise choice :-) "
|
||||
upgradepkg --install-new "$packlocation"
|
||||
upgradepkg --install-new "$newpkglocation"
|
||||
break;;
|
||||
*) echo "[INFO] Nope? Alright." ; exit 0 ;;
|
||||
esac
|
||||
|
|
125
genpackagelist
Executable file
125
genpackagelist
Executable file
|
@ -0,0 +1,125 @@
|
|||
#!/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.
|
||||
|
||||
function gen_packages_txt {
|
||||
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 {
|
||||
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
|
||||
echo "File not found: $1"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [ "`echo $1|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 ;;
|
||||
esac
|
||||
|
||||
echo "Generating meta files, package lists and md5sum files for $1..."
|
||||
|
||||
# Create a unique temporary directory and untar the package inside it
|
||||
TEMPDIR=$(mktemp -d $1.XXXXXX)
|
||||
tar -xf $1 -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)
|
||||
|
||||
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/,$//")"
|
||||
fi
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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]"
|
||||
;;
|
||||
esac
|
Loading…
Reference in a new issue