You are not logged in.

#1 2012-07-05 23:35:53

DarkSniper
Member
Registered: 2011-04-05
Posts: 74

[Solved] Proper/Preferred Way to Install a Directory into $pkgdir?

I'm wondering if there are any guidelines on installing directories from an unpacked RPM into my $pkgdir. From what I've seen, it's typically frowned upon to use cp/mv, but install doesn't seem to have an option to recursively copy a directory. Is my current PKGBUILD okay, or should I be using a different command in place of "cp -r"? Thanks!

My current PKGBUILD looks like this:

# Contributor: Trevor Turner <turn3r [dot] tr3v0r [at] gmail [dot] com>
_i686rpm=hpasm-7.7.0-115.sles9.i586.rpm
_x86_64rpm=hpasm-7.7.0-115.sles9.x86_64.rpm
pkgname=hpasm
pkgver=7.7.0_115
pkgrel=1
pkgdesc="HP Proliant Server Management Agents and Utilities"
arch=('i686' 'x86_64')
url="ftp://ftp.compaq.com/pub/products/servers/supportsoftware/linux/"
license=('custom')
makedepends=('rpmextract')
source=('hpasmd' 'hpasmd.service')
md5sums=('4efbcaf99d2ad688d5887dd28d48854f' '3249472c2ca273d8c348b8daf0ffd996')

if [ "${CARCH}" = "x86_64" ]; then
  source+=(ftp://ftp.compaq.com/pub/products/servers/supportsoftware/linux/${_x86_64rpm})
  md5sums+=('812416e7ee25690d55389b1df1b549bb')
  noextract=("${_x86_64rpm}")
elif [ "${CARCH}" = "i686" ]; then
  source+=(ftp://ftp.compaq.com/pub/products/servers/supportsoftware/linux/${_i686rpm})
  md5sums+=('420e886d6a66eb6cb3fd0671635519ec')
  noextract=("${_i686rpm}")
fi

package() {
  cd "$srcdir"
  msg2 "Extracting RPM..."
  rpmextract.sh *.rpm
  msg2 "Installing Files..."
  install -dm 755 "${pkgdir}/usr/lib/systemd/system"
  install -dm 755 "${pkgdir}/usr/sbin"
  install -dm 755 "${pkgdir}/etc/rc.d"
  install -Dm 755 "${srcdir}/hpasmd" "${pkgdir}/etc/rc.d/hpasmd"
  install -Dm 755 "${srcdir}/hpasmd.service" "${pkgdir}/usr/lib/systemd/system/hpasmd.service"
  install -Dm 755 "${srcdir}/sbin/bootcfg" "${pkgdir}/usr/sbin/bootcfg"
  install -Dm 755 "${srcdir}/sbin/hpasmcli" "${pkgdir}/usr/sbin/hpasmcli"
  install -Dm 755 "${srcdir}/sbin/hplog" "${pkgdir}/usr/sbin/hplog"
  install -Dm 755 "${srcdir}/sbin/hpuid" "${pkgdir}/usr/sbin/hpuid"
  cp -r "${srcdir}/opt" "${pkgdir}/"
  ln -s "/opt/compaq/hpasmd/bin/hpasmd" "${pkgdir}/usr/sbin/hpasmd"
  ln -s "/opt/compaq/hpasm/addon/libhpasmintrfc.so.1.0" "${pkgdir}/usr/lib/libhpasmintrfc.so.1.0"
  ln -s "libhpasmintrfc.so.1.0" "${pkgdir}/usr/lib/libhpasmintrfc.so.1"
  ln -s "/opt/compaq/hpasm/addon/libhpev.so.1.0" "${pkgdir}/usr/lib/libhpev.so.1.0"
  ln -s "libhpev.so.1.0" "${pkgdir}/usr/lib/libhpev.so.1"
}

Last edited by DarkSniper (2012-07-11 00:20:01)


Failure is not an option... It comes bundled with Windows.

Offline

#2 2012-07-10 17:03:11

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 4,237

Re: [Solved] Proper/Preferred Way to Install a Directory into $pkgdir?

cp -r should be ok .

I've used it in an Aur package that's now in community and it still has that command.


Booting with apg Openrc, NOT systemd.
Automounting : not needed, i prefer pmount
Aur helpers : makepkg + my own local repo === rarely need them

Offline

#3 2012-07-10 18:08:15

Stefan Husmann
Member
From: Germany
Registered: 2007-08-07
Posts: 999

Re: [Solved] Proper/Preferred Way to Install a Directory into $pkgdir?

Yes, it is tolerated.

Offline

#4 2012-07-10 19:03:40

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,688
Website

Re: [Solved] Proper/Preferred Way to Install a Directory into $pkgdir?

cp is tolerated, but make sure that you manually set permissions if necessary.

Otherwise, create your own functions and paste them in sparingly, e.g.

function install_dir()
{
  src_dir_="${1%/}"
  shift
  dst_dir_="${1%/}"
  shift
  src_len_=${#src_dir_}
  find "$src_dir_" -type f -print | while read path_
  do
    rel_path_="${path_:${src_len_}}"
    install "$@" "$path_" "$dst_dir$rel_path_"
  done
}

install_dir "$srcdir/$pkgname-$pkgver/foo/lib" "$pkgdir/lib" -Dm 644

Offline

#5 2012-07-11 00:18:51

DarkSniper
Member
Registered: 2011-04-05
Posts: 74

Re: [Solved] Proper/Preferred Way to Install a Directory into $pkgdir?

Thanks for your replies! I left cp -r in, and added a chmod line to ensure that the permissions are correct (that install_dir function seems really useful if you've got more than one directory though).


Failure is not an option... It comes bundled with Windows.

Offline

Board footer

Powered by FluxBB