From 7c7b424ad06d0794499a192d00d3cb4e09a11bb2 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 25 Nov 2020 21:52:48 -0500 Subject: mkslackinfo: try to intuit correct build command --- mkslackinfo | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 83 insertions(+), 8 deletions(-) diff --git a/mkslackinfo b/mkslackinfo index c4d99ce..0f37b49 100755 --- a/mkslackinfo +++ b/mkslackinfo @@ -17,6 +17,79 @@ sub usage { die "usage: $SELF url [homepage] [version]\n"; } +sub get_build_command { + %buildcmds = { + 'autoconf' => <<'EOF', +CFLAGS="$SLKCFLAGS" \ +CXXFLAGS="$SLKCFLAGS" \ +./configure \ + --prefix=/usr \ + --libdir=/usr/lib${LIBDIRSUFFIX} \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --mandir=/usr/man \ + --docdir=/usr/doc/$PRGNAM-$VERSION \ + --build=$ARCH-slackware-linux + +make +make install-strip DESTDIR=$PKG +EOF + 'cmake' => <<'EOF', +mkdir -p build +cd build + cmake \ + -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \ + -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DLIB_SUFFIX=${LIBDIRSUFFIX} \ + -DMAN_INSTALL_DIR=/usr/man \ + -DCMAKE_BUILD_TYPE=Release .. + make + make install DESTDIR=$PKG +cd .. +EOF + 'python' => <<'EOF', +python setup.py install --root=$PKG +EOF + 'perl' => <<'EOF', +perl Makefile.PL \ + PREFIX=/usr \ + INSTALLDIRS=vendor \ + INSTALLVENDORMAN3DIR=/usr/man/man3 +make +make test +make install DESTDIR=$PKG +EOF + }; + + my $cmd = $buildcmd{autoconf}; + # if it ain't a tar file, just return the default + return $cmd unless $tar; + + my ($file, $tar) = @_; + + # look only at the 2nd level dir (e.g. foo-1.2.3/configure.ac) + open my $f, "tar tf $file --wildcards */* |" or return $cmd; + while(<$f>) { + chomp; + if(/^\bconfigure\.(ac|in)$/) { + $cmd = $buildcmd{autoconf}; + last; + } elsif(/\bCMakeLists\.txt$/) { + $cmd = $buildcmd{cmake}; + last; + } elsif(/\bsetup\.py$/) { + $cmd = $buildcmd{python}; + last; + } elsif(/\bMakefile\.PL$/) { + $cmd = $buildcmd{python}; + last; + } + } + close $f; + return $cmd; +} + $url = shift || &usage; # Take package name from the current dir @@ -35,6 +108,9 @@ if($file =~ /\.zip$/i) { $extract = "7za x \$CWD/\$PRGNAM-\$VERSION.rar"; } elsif($file =~ /(\.tar(?:$|\..*)|\.t[bxg]z)/i) { $extract = "tar xvf \$CWD/\$PRGNAM-\$VERSION$1"; + $tar = 1; +} else { + $extract = "EXTRACT"; } $homepage = shift; @@ -63,6 +139,7 @@ if(!$version) { if(not -e "$package.SlackBuild") { warn "$package.SlackBuild does not exist, creating from template\n"; + $buildcmd = get_build_command($file, $tar); open my $build, ">$package.SlackBuild" or die $!; while() { s/__NAME__/$name/g; @@ -70,6 +147,7 @@ if(not -e "$package.SlackBuild") { s/__PRGNAM__/$package/g; s/__VERSION__/$version/g; s/__EXTRACT__/$extract/g; + s/__BUILD__/$buildcmd/g; print $build "$_"; } close $build; @@ -132,7 +210,7 @@ TAG=${TAG:-_SBo} if [ -z "$ARCH" ]; then case "$( uname -m )" in - i?86) ARCH=i486 ;; + i?86) ARCH=i586 ;; arm*) ARCH=arm ;; *) ARCH=$( uname -m ) ;; esac @@ -143,8 +221,8 @@ TMP=${TMP:-/tmp/SBo} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} -if [ "$ARCH" = "i486" ]; then - SLKCFLAGS="-O2 -march=i486 -mtune=i686" +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" @@ -166,11 +244,8 @@ rm -rf $PRGNAM-$VERSION __EXTRACT__ cd $PRGNAM-$VERSION chown -R root:root . -find -L . \ - \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ - -o -perm 511 \) -exec chmod 755 {} \; -o \ - \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ - -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; +find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \ + \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+ CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ -- cgit v1.2.3