You are not logged in.

#1 2012-02-23 03:13:56

cjpembo
Member
Registered: 2008-08-06
Posts: 105

[REQUEST - READY FOR SUBMISSION TO AUR] Critique my smlnj PKGBUILD

The existing SML-NJ compiler package, 'smlnj', is out-dated and no maintainer info was given.  So I created my own PKGBUILD.  My version seems easier to maintain.  The smlnj source code comes with a build script;  so I use it.  The previous unknown packager chose to basically rewrite the build script in the PKGFILE.  My version of the PKGFILE builds fine - in fact, I used it to compile a larger piece of software (openmodelica).  I checked my package and PKGBUILD with namcap and I have a few questions:

Output from namcap:

.....
smlnj E: File (usr/lib32/smlnj/lib/smlnj/cm/.cm/x86-unix/cm.cm) is owned by 501:utmp
smlnj E: File (usr/lib32/smlnj/lib/smlnj/cm/.cm/x86-unix/tools.cm) is owned by 501:utmp
smlnj E: File (usr/lib32/smlnj/lib/smlnj/basis/.cm/x86-unix/basis.cm) is owned by 501:utmp
smlnj E: File (usr/lib32/smlnj/lib/smlnj/MLRISC/.cm/x86-unix/ALPHA.cm) is owned by 501:utmp
smlnj E: File (usr/lib32/smlnj/lib/smlnj/MLRISC/.cm/x86-unix/AMD64.cm) is owned by 501:utmp
smlnj E: File (usr/lib32/smlnj/lib/smlnj/MLRISC/.cm/x86-unix/Control.cm) is owned by 501:utmp
smlnj E: File (usr/lib32/smlnj/lib/smlnj/MLRISC/.cm/x86-unix/Graphs.cm) is owned by 501:utmp
smlnj E: File (usr/lib32/smlnj/lib/smlnj/MLRISC/.cm/x86-unix/HPPA.cm) is owned by 501:utmp
.....

Many files have the permissions listed above.  I never altered any permissions.  Any recommendations?

SMLNJ is a 32-bit program so I changed the install directory to /usr/lib32/smlnj on 64-bit systems and left it at /usr/lib/smlnj on 32-bit systems.  Is this appropriate?

If it looks like I made a mistake installing SML-NJ where I did: SML-NJ expects to be installed to /where_ever_you_specify/lib/smlnj/{bin,lib} with SMLNJ_HOME=/where_ever_you_specify/lib/smlnj/bin.  That is why the directory structure is laid out like you see above.

I have code in the PKGBUILD that sets different options based on '$CARCH'.  I test for 'i686' or 'x86_64'.  Should I also test for 'any' and just assume that means 'x86_64' ?

Here is a copy of the PKGBUILD.  I've only tested it on a 64-bit system.

# Previous Maintainer: Casper the Friendly Ghost
# Maintainer: Chris Pemberton <cjpembo@gmail.com>

pkgname=smlnj
pkgver=110.74
pkgrel=1

pkgdesc="Standard ML of New Jersey is a compiler for the Standard ML '97 programming language"

arch=(i686 x86_64)

if test "$CARCH" == i686; then
  LIBn=lib
fi

if test "$CARCH" == x86_64; then
  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~ N O T I C E ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  msg "SML-NJ is 32-bit only and must self-compile in a 32-bit environment"
  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~ N O T I C E ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  sleep 4
  makedepends=('gcc-multilib')
  depends=('lib32-glibc')
  LIBn=lib32
fi

url="http://www.smlnj.org/"
license=("BSD")

groups=()
checkdepends=()
optdepends=()

provides=('sml')

conflicts=()
replaces=()
backup=()

options=(!makeflags) # multi-threaded make breaks the build

source=(http://smlnj.cs.uchicago.edu/dist/working/$pkgver/config.tgz)

md5sums=('9c4f80eb53240b583eb96d8f8c556cf8') # re-generate with makepkg -g >> PKGBUILD

build() {
  SMLNJ_DEST="$pkgdir/usr/$LIBn/smlnj"
  SMLNJ_REALDEST="/usr/$LIBn/smlnj"
  unset SMLNJ_HOME
  mkdir -p $SMLNJ_DEST
  cd $srcdir
  ./config/install.sh
  cp -Rp bin $SMLNJ_DEST
  cp -Rp lib $SMLNJ_DEST
  mkdir -p $pkgdir/etc/profile.d
  echo -e "export SMLNJ_HOME=/usr/$LIBn/smlnj \nexport PATH=\$PATH:/usr/$LIBn/smlnj/bin" > $pkgdir/etc/profile.d/smlnj.sh
  chmod +x $pkgdir/etc/profile.d/smlnj.sh

  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~ N O T I C E ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  msg "         The SML-NJ executables are NOT installed in /usr/bin"
  msg ""
  msg "                  You MUST define SMLNJ_HOME"
  msg ""
  msg "  (ie: 'WARNING: Package contains reference to \$srcdir' message)"
  msg ""
  msg " '/etc/profile.d/smlnj.sh' will update your PATH and set SMLNJ_HOME"
  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  sleep 4
}

Last edited by cjpembo (2012-02-28 23:06:00)

Offline

#2 2012-02-23 20:59:59

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,922

Re: [REQUEST - READY FOR SUBMISSION TO AUR] Critique my smlnj PKGBUILD

If you need to use custom variables in a PKGBUILD, it's is common practice to have their name start with an _ (underscore) .
this way it's easy to discern between vars internal to a pkgbuild and external vars.

"Any" is used for packages that don't have architecture specific files in them, basically there is no system with "any" as $CARCH .


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2012-02-23 21:40:12

cjpembo
Member
Registered: 2008-08-06
Posts: 105

Re: [REQUEST - READY FOR SUBMISSION TO AUR] Critique my smlnj PKGBUILD

Thanks for your input.

I can change the 'LIBn' variable to '_LIBn', but 'SMLNJ_DEST', 'SMLNJ_REALDEST', and 'SMLNJ_HOME' are environment variables hard-coded into the sources and cannot be altered.

If you have a little time, and you're on a 32-bit machine, could you please try a 'makepkg PKGFILE' and let me know if it builds?  It only takes two minutes.  No need to install it.  If not, I plan to install a bare 32-bit archlinux in virtualbox and do all of my testing in that going forward.  It will be easier to check for any missing dependencies that way.

Here's the PKGBUILD with the variable name changes:

# Previous Maintainer: Casper the Friendly Ghost
# Maintainer: Chris Pemberton <cjpembo@gmail.com>

pkgname=smlnj
pkgver=110.74
pkgrel=1

pkgdesc="Standard ML of New Jersey is a compiler for the Standard ML '97 programming language"

arch=(i686 x86_64)

if test "$CARCH" == i686; then
  _LIBn=lib
fi

if test "$CARCH" == x86_64; then
  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~ N O T I C E ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  msg "SML-NJ is 32-bit only and must self-compile in a 32-bit environment"
  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~ N O T I C E ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  sleep 4
  makedepends=('gcc-multilib')
  depends=('lib32-glibc')
  _LIBn=lib32
fi

url="http://www.smlnj.org/"
license=("BSD")

groups=()
checkdepends=()
optdepends=()

provides=('sml')

conflicts=()
replaces=()
backup=()

options=(!makeflags) # multi-threaded make breaks the build

source=(http://smlnj.cs.uchicago.edu/dist/working/$pkgver/config.tgz)

md5sums=('9c4f80eb53240b583eb96d8f8c556cf8') # re-generate with makepkg -g >> PKGBUILD

build() {
  SMLNJ_DEST="$pkgdir/usr/$_LIBn/smlnj"
  SMLNJ_REALDEST="/usr/$_LIBn/smlnj"
  unset SMLNJ_HOME
  mkdir -p $SMLNJ_DEST
  cd $srcdir
  ./config/install.sh
  cp -Rp bin $SMLNJ_DEST
  cp -Rp lib $SMLNJ_DEST
  mkdir -p $pkgdir/etc/profile.d
  echo -e "export SMLNJ_HOME=/usr/$_LIBn/smlnj \nexport PATH=\$PATH:/usr/$_LIBn/smlnj/bin" > $pkgdir/etc/profile.d/smlnj.sh
  chmod +x $pkgdir/etc/profile.d/smlnj.sh

  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~ N O T I C E ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  msg "         The SML-NJ executables are NOT installed in /usr/bin"
  msg ""
  msg "                  You MUST define SMLNJ_HOME"
  msg ""
  msg "  (ie: 'WARNING: Package contains reference to \$srcdir' message)"
  msg ""
  msg " '/etc/profile.d/smlnj.sh' will update your PATH and set SMLNJ_HOME"
  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  sleep 4
}

Thanks

Offline

#4 2012-02-28 23:05:06

cjpembo
Member
Registered: 2008-08-06
Posts: 105

Re: [REQUEST - READY FOR SUBMISSION TO AUR] Critique my smlnj PKGBUILD

This final version of my PKGBUILD has been built in both 32 and 64-bit archlinux environments.  Works great.  If any TU would like to replace our existing (out-dated) smlnj PKGBUILD, that would be most helpful.

# Previous Maintainer: Casper the Friendly Ghost
# Maintainer: Chris Pemberton <cjpembo@gmail.com>

pkgname=smlnj
pkgver=110.74
pkgrel=1

pkgdesc="Standard ML of New Jersey is a compiler for the Standard ML '97 programming language"

arch=(i686 x86_64)

if test "$CARCH" == i686; then
   _LIBn=lib
fi

if test "$CARCH" == x86_64; then
  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~ N O T I C E ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  msg "SML-NJ is 32-bit only and must self-compile in a 32-bit environment"
  msg ""
  msg "           Packages from the 'multilib' repo are required"
  msg ""
  msg "          'multilib' repo is enabled via '/etc/pacman.conf' "
  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~ N O T I C E ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  sleep 4
  makedepends=('gcc-multilib')
  depends=('lib32-glibc')
  _LIBn=lib32
fi

url="http://www.smlnj.org/"
license=("BSD")

groups=()
checkdepends=()
optdepends=()

provides=('sml')

conflicts=()
replaces=()
backup=()

options=(!makeflags) # multi-threaded make breaks the build

source=(http://smlnj.cs.uchicago.edu/dist/working/$pkgver/config.tgz)

md5sums=('9c4f80eb53240b583eb96d8f8c556cf8') # re-generate with makepkg -g >> PKGBUILD

build() {
  SMLNJ_DEST="$pkgdir/usr/$_LIBn/smlnj"
  SMLNJ_REALDEST="/usr/$_LIBn/smlnj"
  unset SMLNJ_HOME
  mkdir -p $SMLNJ_DEST
  cd $srcdir
  ./config/install.sh
  cp -Rp bin $SMLNJ_DEST
  cp -Rp lib $SMLNJ_DEST
  mkdir -p $pkgdir/etc/profile.d
  echo -e "export SMLNJ_HOME=/usr/$_LIBn/smlnj \nexport PATH=\$PATH:/usr/$_LIBn/smlnj/bin" > $pkgdir/etc/profile.d/smlnj.sh
  chmod +x $pkgdir/etc/profile.d/smlnj.sh

  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~ N O T I C E ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  msg "         The SML-NJ executables are NOT installed in /usr/bin"
  msg ""
  msg "                  You MUST define SMLNJ_HOME"
  msg ""
  msg "  (ie: 'WARNING: Package contains reference to \$srcdir' message)"
  msg ""
  msg " '/etc/profile.d/smlnj.sh' will update your PATH and set SMLNJ_HOME"
  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  sleep 4
}

Offline

#5 2012-05-29 02:30:56

caltry
Member
Registered: 2012-05-19
Posts: 1

Re: [REQUEST - READY FOR SUBMISSION TO AUR] Critique my smlnj PKGBUILD

I like this PKGBUILD; it's something I'd like to see in the AUR as a replacement for the current one.

cjpembo wrote:
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~ N O T I C E ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  msg "SML-NJ is 32-bit only and must self-compile in a 32-bit environment"
  msg ""
  msg "           Packages from the 'multilib' repo are required"
  msg ""
  msg "          'multilib' repo is enabled via '/etc/pacman.conf' "
  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~ N O T I C E ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"

This was a really valuable hint, I'm glad you added it!

cjpembo wrote:
provides=('sml')

This also provides: heap2exec, ml-build, ml-lex, ml-nlffigen, ml-yacc, ml-antlr, ml-burg, ml-makedepend, ml-ulex.

cjpembo wrote:
options=(!makeflags) # multi-threaded make breaks the build

Why disable all makeflags, rather than specifically disabling parallel builds?

options=()
MAKEFLAGS="$MAKEFLAGS -j1"
cjpembo wrote:
source=(http://smlnj.cs.uchicago.edu/dist/working/$pkgver/config.tgz)

I think that fetching just config.tgz works for now, but because 'config/install.sh' fetches additional files it doesn't work well with (i) mirrors (ii) verifying md5sums (iii) (eventual) package-signing. Not a big deal now, but something that may come up when trying to get a TU to put it in 'community'.

cjpembo wrote:
  SMLNJ_DEST="$pkgdir/usr/$_LIBn/smlnj"
  SMLNJ_REALDEST="/usr/$_LIBn/smlnj"
  unset SMLNJ_HOME
  mkdir -p $SMLNJ_DEST
  cd $srcdir
  ./config/install.sh
  cp -Rp bin $SMLNJ_DEST
  cp -Rp lib $SMLNJ_DEST
  mkdir -p $pkgdir/etc/profile.d
  echo -e "export SMLNJ_HOME=/usr/$_LIBn/smlnj \nexport PATH=\$PATH:/usr/$_LIBn/smlnj/bin" > $pkgdir/etc/profile.d/smlnj.sh
  chmod +x $pkgdir/etc/profile.d/smlnj.sh

  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~ N O T I C E ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  msg "         The SML-NJ executables are NOT installed in /usr/bin"
  msg ""
  msg "                  You MUST define SMLNJ_HOME"
  msg ""
  msg "  (ie: 'WARNING: Package contains reference to \$srcdir' message)"
  msg ""
  msg " '/etc/profile.d/smlnj.sh' will update your PATH and set SMLNJ_HOME"
  msg ""
  msg "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  msg ""
  sleep 4
}

I like to avoid altering my global configuration and environmental variables when installing a package. Unfortunately, it looks like SML/NJ really depends on the structure created by their 'config/install.sh' script. sad

One way to work around this to write a small shell script that's shared between all of the executables, which sets SMLNJ_HOME. So that after installation /usr/bin looks like this:

/usr/bin $ for NAME in /path/to/smlnj/bin/*;do ls -l $NAME; done
sml:           symbolic link to `smlnj-wrapper'
heap2exec:     symbolic link to `smlnj-wrapper'
ml-build:      symbolic link to `smlnj-wrapper'
ml-lex:        symbolic link to `smlnj-wrapper'
ml-nlffigen:   symbolic link to `smlnj-wrapper'
ml-yacc:       symbolic link to `smlnj-wrapper'
ml-antlr:      symbolic link to `smlnj-wrapper'
ml-burg:       symbolic link to `smlnj-wrapper'
ml-makedepend: symbolic link to `smlnj-wrapper'
ml-ulex:       symbolic link to `smlnj-wrapper'

/usr/bin $ cat smlnj-wrapper
#!/bin/sh
SMLNJ_HOME=/path/to/smlnj /path/to/smlnj/bin/$(basename $0) $*

It makes the PKGBUILD more complicated, but keeps SML/NJ's configuration from leaking out and doesn't require extra steps from the users. I'm curious how others feel about this approach.

Thanks for your contribution!

Offline

Board footer

Powered by FluxBB