You are not logged in.

#1 2010-11-24 19:56:54

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,729
Website

need some help with a split package

Basically, I'd like to have some code in my PKGBUILD that will append some extra info to the package name based on a file the user defined.  This is for kernel26-ck and the file I speak of is the .config he/she makes.  Below is the code that doesn't work and I think it doesn't work because the name of the package is the name of the package_name() {} function and both of of these have to match the pkgname array.  What I want is to have the pkgname array get generated dynamically based on the code below which starts before the make command in the build section.  Advise is appreciated.  Is what I'm asking for possible?

# Contributor: graysky <graysky AT archlinux dot us>
# Contributor: Cray "MP2E" Elliott <MP2E { AT } archlinux.us>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Thomas Baechler <thomas@archlinux.org>
###########################################################################################################
#                                          Patch and Build Options
###########################################################################################################
_BFQ_patches="n"    # add BFQ patches
_makemenucfg="n"    # menuconfig option
_streamline_="n"    # run Steven Rostedt's streamline_config.pl script - see notes below!
_use_current="n"    # use the current kernel's .config file - see notes below!
###########################################################################################################
#                                        More Details and References
###########################################################################################################
## Note all kernels get the ck patch set - there is no option to enable/disable it!
## BFQ
 # read, http://algo.ing.unimo.it/people/paolo/disk_sched/
## MAKEMENUCONFIG OPTION
 # Allow you to select additional kernel options prior to a build via a menuconfig.
## STREAMLINE_CONFIG OPTION
 # Similar to a make localmodconfig but this actually works!
 # WARNING - make CERTAIN that all modules are modprobed BEFORE you begin making the pkg!
 # read, https://bbs.archlinux.org/viewtopic.php?pid=830221#p830221
 # to keep track of which modules are needed for your specific system/hardware, give my module_db script.
 # a try: http://aur.archlinux.org/packages.php?ID=41689
 # Not that if you use my script, this PKGBUILD will auto run the reload_data base for you to probe
 # all the modules you have logged!
## USE CURRENT KERNEL'S .CONFIG
 # Enabling this option will use the .config of the RUNNING kernel rather than the ARCH defaults.
 # Useful when the package gets updated and you already went through the trouble of customizing your
 # config options.  NOT recommended when a new kernel is released, but again, convenient for package bumps.
###########################################################################################################

pkgname='kernel26-ck'
#true && pkgname=("kernel26-ck" "kernel26-ck-headers")
_basekernel=2.6.36
pkgver=${_basekernel}.1
pkgrel=4
arch=('i686' 'x86_64')
license=('GPL2')
url="http://users.on.net/~ckolivas/kernel"
_archpatchversion=3
_ckpatchversion=2
_kernelname=-ck
_patchname="patch-${pkgver}-${_archpatchversion}-ARCH"
_ckpatchname="patch-${_basekernel}-ck${_ckpatchversion}"
_bfqpath="http://algo.ing.unimo.it/people/paolo/disk_sched/patches/2.6.36"
source=(ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$_basekernel.tar.bz2 # kernel source
    ftp://ftp.archlinux.org/other/kernel26/${_patchname}.bz2 # arch patchset
    config config.x86_64 kernel26.preset # configs
    # ck patchset
    http://www.kernel.org/pub/linux/kernel/people/ck/patches/2.6/${_basekernel}/${_basekernel}-ck${_ckpatchversion}/${_ckpatchname}.bz2
    # BFQ patches
    ${_bfqpath}/0001-bfq_iosched-block-prepare_IO_context_code-v1-2.6.36.patch
    ${_bfqpath}/0002-bfq_iosched-block-add-cgroups-kconfig-and-build-bits-for-BFQ-v1-2.6.36.patch
    ${_bfqpath}/0003-bfq_iosched-block-introduce_BFQ-v1-2.6.36.patch)

build() {
  # Patch source with -ARCH patches
  # See http://projects.archlinux.org/linux-2.6-ARCH.git/
  msg "Patching source with-ARCH patches"
  cd ${srcdir}/linux-$_basekernel
  patch -Np1 -i ${srcdir}/${_patchname}

  # Patch source for BFQ patches
  if [ ${_BFQ_patches} = "y" ]; then
  msg "Patching source with BFQ patches"
   for p in $(ls ${srcdir}/*-bfq_*); do
    patch -Np1 -i $p
   done
  fi

  # Patch source with ck
  # Fix double name in EXTRAVERSION
  sed -i -re "s/^(.EXTRAVERSION).*$/\1 = /" ${srcdir}/${_ckpatchname}

  # Add -ck base patch set
  msg "Patching source with ck1 patch set"
  patch -Np1 -i ${srcdir}/${_ckpatchname}

  msg "Running make mrproper to clean source tree"
  make mrproper

  if [ "$CARCH" = "x86_64" ]; then
    cat ../config.x86_64 >./.config
  else
    cat ../config >./.config
  fi

  # use current kernel's config
  # code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
  if [ ${_use_current} = "y" ]; then
   if [[ -s /proc/config.gz ]]; then
    msg "Extracting config from /proc/config.gz..."
    modprobe configs
    zcat /proc/config.gz > ./.config
   else
    warning "You kernel was not compiled with IKCONFIG_PROC!"
    warning "You cannot read the current config!"
    warning "Aborting!"
    exit 0
   fi
  fi

  if [ "${_kernelname}" != "" ]; then
   sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
  fi

  msg "Running make prepare for you to enable patched options of your choosing"
  make prepare

  # If user patched to BFQ and enabled it in the prev step, set it as default io scheduler
  if [ ${_BFQ_patches} = "y" ]; then
    sed -i s'/CONFIG_DEFAULT_CFQ=y/# CONFIG_DEFAULT_CFQ is not set/g' ./.config
    sed -i s'/# CONFIG_DEFAULT_BFQ is not set/CONFIG_DEFAULT_BFQ=y/g' ./.config
    sed -i s'/CONFIG_DEFAULT_IOSCHED="cfq"/CONFIG_DEFAULT_IOSCHED="bfq"/g' ./.config
  fi

  if [ $_streamline_ = "y" ]; then
  msg "If you have modprobe_db installed, running reload_database now"
  if [ -e /usr/bin/reload_database ]; then
   /usr/bin/reload_database
  fi
  msg "Running Steven Rostedt's streamline_config script now "
  chmod +x ./scripts/kconfig/streamline_config.pl
  ./scripts/kconfig/streamline_config.pl > config_strip
  cp config_strip .config
  msg "An error about ksource in line 118 blah blah is NORMAL as are the one you will get for each"
  msg "module you have probed that is not in the kernel itself like nvidia for example!"
  fi

  if [ $_makemenucfg = "y" ]; then
  msg "Running make menuconfig"
  make menuconfig
  fi

  # This allows building cpu-optimized packages with according package names.
  # Useful for repo maintainers.
  CPU=`egrep "MK8=y|MCORE2=y|MPSC=y|MATOM=y|MPENTIUMII=y|MPENTIUMIII=y|MPENTIUMM=y|MPENTIUM4=y|MK7=y|CONFIG_GENERIC_CPU=y|CONFIG_X86_GENERIC=y|M686=y" ./.config`
  CPU=`sed -e "s/CONFIG_M\(.*\)=y/\1/" <<<$CPU`
  case $CPU in
    CORE2)
        _pn="-core2"
        _pd=" Intel Core2 optimized."
        ;;
    K8)
        _pn="-k8"
        _pd="AMD K8 optimized."
        ;;
    PSC)
        _pn="-psc"
        _pd="Intel Pentium4/D/Xeon optimized."
        ;;
    ATOM)
        _pn="-atom"
        _pd="Intel Atom optimized."
        ;;
    K7)
        _pn="-k7"
        _pd="AMD K7 optimized."
        ;;
    PENTIUMII)
        _pn="-p2"
        _pd="Intel Pentium2 optimized."
        ;;
    PENTIUMIII)
        _pn="-p3"
        _pd="Intel Pentium3 optimized."
        ;;
    PENTIUMM)
        _pn="-pm"
        _pd="Intel Pentium-M optimized."
        ;;
    PENTIUM4)
        _pn="-p4"
        _pd="Intel Pentium4 optimized."
        ;;
    default)
        ;;
  esac
  # save to a file for reacall in subsequent sections
  echo "_pn=\"${_pn}\"" > vars
  echo "_pd=\"${_pd}\"" >> vars

  msg "Running make bzImage and modules"
  make bzImage modules
}

package_kernel26-ck() {
. ${srcdir}/linux-$_basekernel/vars
pkgname="kernel26-ck${_pn}"
pkgdesc="ARCH kernel with Con Kolivas' patchset using the Brain Fuck Scheduler (BFS). Budget Fair Queueing (BFQ) I/O scheduler optional.${_pd}"
backup=(etc/mkinitcpio.d/kernel26.preset)
depends=('coreutils' 'linux-firmware' 'module-init-tools' 'mkinitcpio>=0.5.20')
install=kernel26.install
optdepends=('crda: to set the correct wireless channels of your country' \
'nvidia-ck-stable: NVIDIA drivers for kernel26-ck' \
'nvidia-beta-ck: NVIDIA beta drivers for kernel26-ck' \
'modprobed_db: Keeps track of EVERY kernel module that has ever been probed - useful for those of us who make localmodconfig')
  KARCH=x86
  cd ${srcdir}/linux-$_basekernel
  #get kernel version
  _kernver="$(make kernelrelease)"
  mkdir -p ${pkgdir}/{lib/modules,lib/firmware,boot}
  msg "Running make modules_install"
  make INSTALL_MOD_PATH=${pkgdir} modules_install
  cp System.map ${pkgdir}/boot/System.map26${_kernelname}
  cp arch/$KARCH/boot/bzImage ${pkgdir}/boot/vmlinuz26${_kernelname}

  # add vmlinux
  install -m644 -D vmlinux ${pkgdir}/usr/src/linux-${_kernver}/vmlinux

  # install fallback mkinitcpio.conf file and preset file for kernel
  install -m644 -D ${srcdir}/kernel26.preset ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset

  # set correct depmod command for install
  sed \
    -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
    -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
    -i $startdir/kernel26.install
  sed \
    -e "s|source .*|source /etc/mkinitcpio.d/kernel26${_kernelname}.kver|g" \
    -e "s|default_image=.*|default_image=\"/boot/${pkgname}.img\"|g" \
    -e "s|fallback_image=.*|fallback_image=\"/boot/${pkgname}-fallback.img\"|g" \
    -i ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset

  echo -e "# DO NOT EDIT THIS FILE\nALL_kver='${_kernver}'" > ${pkgdir}/etc/mkinitcpio.d/${pkgname}.kver

  # remove build and source links
  rm -f ${pkgdir}/lib/modules/${_kernver}/{source,build}

  # remove the firmware
  rm -rf ${pkgdir}/lib/firmware
}

package_kernel26-ck-headers () {
. ${srcdir}/linux-$_basekernel/vars
pkgname="kernel26-ck${_pn}-headers"
pkgdesc="Header files and scripts to build modules for kernel26-ck.${_pd}"
provides=("kernel26-ck${_pn}-headers=${pkgver}")

  mkdir -p ${pkgdir}/lib/modules/${_kernver}
  cd ${pkgdir}/lib/modules/${_kernver}
  ln -sf ../../../usr/src/linux-${_kernver} build
  cd ${srcdir}/linux-$_basekernel
  install -D -m644 Makefile \
    ${pkgdir}/usr/src/linux-${_kernver}/Makefile
  install -D -m644 kernel/Makefile \
    ${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile
  install -D -m644 .config \
    ${pkgdir}/usr/src/linux-${_kernver}/.config
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include

  for i in acpi asm-generic config generated linux math-emu media net pcmcia scsi sound trace video; do
    cp -a include/$i ${pkgdir}/usr/src/linux-${_kernver}/include/
  done

  # copy arch includes for external modules
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/x86
  cp -a arch/x86/include ${pkgdir}/usr/src/linux-${_kernver}/arch/x86/

  # copy files necessary for later builds, like nvidia and vmware
  cp Module.symvers ${pkgdir}/usr/src/linux-${_kernver}
  cp -a scripts ${pkgdir}/usr/src/linux-${_kernver}

  # fix permissions on scripts dir
  chmod og-w -R ${pkgdir}/usr/src/linux-${_kernver}/scripts
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions

  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel

  cp arch/$KARCH/Makefile ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
  if [ "$CARCH" = "i686" ]; then
    cp arch/$KARCH/Makefile_32.cpu ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
  fi
  cp arch/$KARCH/kernel/asm-offsets.s ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel/

  # add headers for lirc package
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video
  cp drivers/media/video/*.h  ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/
  # need to remove zc0301 from the array with 2.26.36
  for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102 usbvideo; do
   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
   cp -a drivers/media/video/$i/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
  done
  # add docbook makefile
  install -D -m644 Documentation/DocBook/Makefile \
    ${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile
  # add dm headers
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
  cp drivers/md/*.h  ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
  # add inotify.h
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/linux
  cp include/linux/inotify.h ${pkgdir}/usr/src/linux-${_kernver}/include/linux/
  # add wireless headers
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
  cp net/mac80211/*.h ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
  # add dvb headers for external modules
  # in reference to:
  # http://bugs.archlinux.org/task/9912
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core
  cp drivers/media/dvb/dvb-core/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/
  # add dvb headers for external modules
  # in reference to:
  # http://bugs.archlinux.org/task/11194
  if [ -d ${srcdir}/linux-$_basekernel/include/config/dvb ]; then
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
  cp include/config/dvb/*.h ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
  fi
  # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
  # in reference to:
  # http://bugs.archlinux.org/task/13146
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
  cp drivers/media/dvb/frontends/lgdt330x.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
  cp drivers/media/video/msp3400-driver.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
  # add dvb headers
  # in reference to:
  # http://bugs.archlinux.org/task/20402
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb
  cp drivers/media/dvb/dvb-usb/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends
  cp drivers/media/dvb/frontends/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners
  cp drivers/media/common/tuners/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/
  # add xfs and shmem for aufs building
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/mm
  cp fs/xfs/xfs_sb.h ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h
  # add headers for virtualbox
  # in reference to:
  # http://bugs.archlinux.org/task/14568
  cp -a include/drm $pkgdir/usr/src/linux-${_kernver}/include/
  # add headers for broadcom wl
  # in reference to:
  # http://bugs.archlinux.org/task/14568
  cp -a include/trace $pkgdir/usr/src/linux-${_kernver}/include/
  # copy in Kconfig files
  for i in `find . -name "Kconfig*"`; do
   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
   cp $i ${pkgdir}/usr/src/linux-${_kernver}/$i
  done

  chown -R root.root ${pkgdir}/usr/src/linux-${_kernver}
  find ${pkgdir}/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
  # remove unneeded architectures
  rm -rf ${pkgdir}/usr/src/linux-${_kernver}/arch/{alpha,arm,arm26,avr32,blackfin,cris,frv,h8300,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,parisc,powerpc,ppc,s390,sh,sh64,sparc,sparc64,um,v850,xtensa}
}

# Global pkgdesc and depends are here so that they will be picked up by AUR
pkgdesc="ARCH kernel with Con Kolivas' patchset using the Brain Fuck Scheduler (BFS).  Budget Fair Queueing (BFQ) I/O scheduler optional."
depends=('coreutils' 'linux-firmware' 'module-init-tools' 'mkinitcpio>=0.5.20')
sha256sums=('15a076d1a435a6bf8e92834eba4b390b4ec094ce06d47f89d071ca9e5788ce04'
            '96ed15bd64ae90163f81996ee31c3db6c7433d8af156e546ca7b36bedec1728b'
            '1b9abff4752d4a294716b05ae17b981e2e5aaae1b51d19613e6b4bac0aea989d'
            'd1b8757e99ee6cbeacf0b4185236c654440d5d945458b94948fd2cc4af0a881d'
            '7ead13bbe2fdfc5308ddc3a0484d66f8150f78bbdbc59643e0b52bb9e776b5da'
            '092e17164f453bdca8bd50e4fd71c074755740252bd8ad5c3eb6d2d51e78a104'
            'f5c42a2ec2869a756e53fabada51a25dcb9de13861f367463e9ec4da8bf0b86a'
            'f3f52953a2ccc07af3f23c7252e08e61580ec4b165934c089351ddd719c3e41f'
            'cca4eea16278e302c2f7649a145e4d5ceb5ff2ece25fea3988eca82290b0c633')

Last edited by graysky (2010-11-24 20:09:31)

Offline

#2 2010-11-24 21:47:25

nous
Member
From: Across the Universe
Registered: 2006-08-18
Posts: 323
Website

Re: need some help with a split package

graysky wrote:

Basically, I'd like to have some code in my PKGBUILD that will append some extra info to the package name based on a file the user defined.  This is for kernel26-ck and the file I speak of is the .config he/she makes.  Below is the code that doesn't work and I think it doesn't work because the name of the package is the name of the package_name() {} function and both of of these have to match the pkgname array.  What I want is to have the pkgname array get generated dynamically based on the code below which starts before the make command in the build section.  Advise is appreciated.  Is what I'm asking for possible?

I had a few runs with your PKGBUILD without success. The CPU variables are correctly read from the temporary vars file and incorporated in $pkgname and $pkgdesc of each package_*() function, but makepkg won't apply them on the packages it creates. It's probably because of the way makepkg handles split-package PKGBUILDs as I explained in my email and I couldn't find a way around that in the short time I had in my hands. I had a hell of a time accomplishing that in my own kernel26-pf PKGBUILD, but I think... wait. I edited a local copy of /usr/bin/makepkg and it seemed to work:

% diff -u /usr/bin/makepkg ./makepkg 
--- /usr/bin/makepkg    2010-09-04 04:03:56.000000000 +0300
+++ ./makepkg    2010-11-24 23:30:02.073000083 +0200
@@ -996,11 +996,7 @@
     cd "$pkgdir"
     msg "$(gettext "Creating package...")"
 
-    if [[ -z $1 ]]; then
         nameofpkg="$pkgname"
-    else
-        nameofpkg="$1"
-    fi
 
     if [[ $arch = "any" ]]; then
         PKGARCH="any"
% ls -l *.xz
-rw-r--r-- 1 gram users  572 Nov 24 23:36 kernel26-ck-headers-k8-2.6.36.1-4-x86_64.pkg.tar.xz
-rw-r--r-- 1 gram users 2652 Nov 24 23:36 kernel26-ck-k8-2.6.36.1-4-x86_64.pkg.tar.xz

Ignore the file sizes, you don't actually expect me to compile the whole kernel tree each time I test your PKGBUILD, do you? And, yes, the package descriptions are in accord with the filenames.
So, just comment out those 4 lines from makepkg and test thoroughly, because I need some sleep. If it really works, then those lines might not be necessary for split package building and you could ask the developers to remove them.

Last edited by nous (2010-11-24 21:49:47)

Offline

#3 2010-11-24 22:46:48

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,653
Website

Re: need some help with a split package

I believe that yoor .PKGINFO files within those packages will have the same pkgname if you do that...

Online

#4 2010-11-24 22:55:02

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,729
Website

Re: need some help with a split package

@nous - thanks very much for the time you put into this.  I modified makepkg as you suggested and tested it.

1/2 a success: the first package (kernel26-ck) built and was named successfully per your code (kernel26-ck-core2-2.6.36.1-4-x86_64.pkg.tar.xz) but the second package didn't build (kernel26-ck-headers).

@Allan - here is the .PKGINFO - looks like the changes were accepted smile

# Generated by makepkg 3.4.1
# using fakeroot version 1.14.4
# Wed Nov 24 22:53:02 UTC 2010
pkgname = kernel26-ck-core2
pkgbase = kernel26-ck
pkgver = 2.6.36.1-4
pkgdesc = ARCH kernel with Con Kolivas' patchset using the Brain Fuck Scheduler (BFS). Budget Fair Queueing (BFQ) I/O scheduler optional. Intel Core2 optimized.
url = http://users.on.net/~ckolivas/kernel
builddate = 1290639182
packager = Unknown Packager
size = 19116032
arch = x86_64
license = GPL2
depend = coreutils
depend = linux-firmware
depend = module-init-tools
depend = mkinitcpio>=0.5.20
optdepend = crda: to set the correct wireless channels of your country
optdepend = nvidia-ck-stable: NVIDIA drivers for kernel26-ck
optdepend = nvidia-beta-ck: NVIDIA beta drivers for kernel26-ck
optdepend = modprobed_db: Keeps track of EVERY kernel module that has ever been probed - useful for those of us who make localmodconfig
backup = etc/mkinitcpio.d/kernel26.preset
makepkgopt = strip
makepkgopt = docs
makepkgopt = libtool
makepkgopt = emptydirs
makepkgopt = zipman
makepkgopt = purge

Last edited by graysky (2010-11-24 22:57:45)

Offline

#5 2010-11-24 22:55:51

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,653
Website

Re: need some help with a split package

What about in the -headers package?

Online

#6 2010-11-24 22:58:22

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,729
Website

Re: need some help with a split package

Allan wrote:

What about in the -headers package?

That package never got built sad  I'm playing around with the PKGBUILD now to see if I can get it to build both.

Offline

#7 2010-11-24 23:03:46

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,729
Website

Re: need some help with a split package

Got it!

Allan wrote:

What about in the -headers package?

Yep, headers package is good too!

# Generated by makepkg 3.4.1
# using fakeroot version 1.14.4
# Wed Nov 24 23:06:36 UTC 2010
pkgname = kernel26-ck-headers-core2
pkgbase = kernel26-ck
pkgver = 2.6.36.1-4
pkgdesc = Header files and scripts to build modules for kernel26-ck. Intel Core2 optimized.
url = http://users.on.net/~ckolivas/kernel
builddate = 1290639996
packager = Unknown Packager
size = 31174656
arch = x86_64
license = GPL2
depend = coreutils
depend = linux-firmware
depend = module-init-tools
depend = mkinitcpio>=0.5.20
provides = kernel26-ck-headers-core2=2.6.36.1
makepkgopt = strip
makepkgopt = docs
makepkgopt = libtool
makepkgopt = emptydirs
makepkgopt = zipman
makepkgopt = purge

PKGBUILD built using the modified makepkg suggested by nous.

# Contributor: graysky <graysky AT archlinux dot us>
# Contributor: Cray "MP2E" Elliott <MP2E { AT } archlinux.us>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Thomas Baechler <thomas@archlinux.org>
###########################################################################################################
#                                          Patch and Build Options
###########################################################################################################
_BFQ_patches="n"    # add BFQ patches
_makemenucfg="n"    # menuconfig option
_streamline_="n"    # run Steven Rostedt's streamline_config.pl script - see notes below!
_use_current="n"    # use the current kernel's .config file - see notes below!
###########################################################################################################
#                                        More Details and References
###########################################################################################################
## Note all kernels get the ck patch set - there is no option to enable/disable it!
## BFQ
 # read, http://algo.ing.unimo.it/people/paolo/disk_sched/
## MAKEMENUCONFIG OPTION
 # Allow you to select additional kernel options prior to a build via a menuconfig.
## STREAMLINE_CONFIG OPTION
 # Similar to a make localmodconfig but this actually works!
 # WARNING - make CERTAIN that all modules are modprobed BEFORE you begin making the pkg!
 # read, https://bbs.archlinux.org/viewtopic.php?pid=830221#p830221
 # to keep track of which modules are needed for your specific system/hardware, give my module_db script.
 # a try: http://aur.archlinux.org/packages.php?ID=41689
 # Not that if you use my script, this PKGBUILD will auto run the reload_data base for you to probe
 # all the modules you have logged!
## USE CURRENT KERNEL'S .CONFIG
 # Enabling this option will use the .config of the RUNNING kernel rather than the ARCH defaults.
 # Useful when the package gets updated and you already went through the trouble of customizing your
 # config options.  NOT recommended when a new kernel is released, but again, convenient for package bumps.
###########################################################################################################

pkgname='kernel26-ck'
true && pkgname=("kernel26-ck" "kernel26-ck-headers")
_basekernel=2.6.36
pkgver=${_basekernel}.1
pkgrel=4
arch=('i686' 'x86_64')
license=('GPL2')
url="http://users.on.net/~ckolivas/kernel"
_archpatchversion=3
_ckpatchversion=2
_kernelname=-ck
_patchname="patch-${pkgver}-${_archpatchversion}-ARCH"
_ckpatchname="patch-${_basekernel}-ck${_ckpatchversion}"
_bfqpath="http://algo.ing.unimo.it/people/paolo/disk_sched/patches/2.6.36"
source=(ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$_basekernel.tar.bz2 # kernel source
    ftp://ftp.archlinux.org/other/kernel26/${_patchname}.bz2 # arch patchset
    config config.x86_64 kernel26.preset # configs
    # ck patchset
    http://www.kernel.org/pub/linux/kernel/people/ck/patches/2.6/${_basekernel}/${_basekernel}-ck${_ckpatchversion}/${_ckpatchname}.bz2
    # BFQ patches
    ${_bfqpath}/0001-bfq_iosched-block-prepare_IO_context_code-v1-2.6.36.patch
    ${_bfqpath}/0002-bfq_iosched-block-add-cgroups-kconfig-and-build-bits-for-BFQ-v1-2.6.36.patch
    ${_bfqpath}/0003-bfq_iosched-block-introduce_BFQ-v1-2.6.36.patch)

build() {
  # Patch source with -ARCH patches
  # See http://projects.archlinux.org/linux-2.6-ARCH.git/
  msg "Patching source with-ARCH patches"
  cd ${srcdir}/linux-$_basekernel
  patch -Np1 -i ${srcdir}/${_patchname}

  # Patch source for BFQ patches
  if [ ${_BFQ_patches} = "y" ]; then
  msg "Patching source with BFQ patches"
   for p in $(ls ${srcdir}/*-bfq_*); do
    patch -Np1 -i $p
   done
  fi

  # Patch source with ck
  # Fix double name in EXTRAVERSION
  sed -i -re "s/^(.EXTRAVERSION).*$/\1 = /" ${srcdir}/${_ckpatchname}

  # Add -ck base patch set
  msg "Patching source with ck1 patch set"
  patch -Np1 -i ${srcdir}/${_ckpatchname}

  msg "Running make mrproper to clean source tree"
  make mrproper

  if [ "$CARCH" = "x86_64" ]; then
    cat ../config.x86_64 >./.config
  else
    cat ../config >./.config
  fi

  # use current kernel's config
  # code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
  if [ ${_use_current} = "y" ]; then
   if [[ -s /proc/config.gz ]]; then
    msg "Extracting config from /proc/config.gz..."
    modprobe configs
    zcat /proc/config.gz > ./.config
   else
    warning "You kernel was not compiled with IKCONFIG_PROC!"
    warning "You cannot read the current config!"
    warning "Aborting!"
    exit 0
   fi
  fi

  if [ "${_kernelname}" != "" ]; then
   sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
  fi

  msg "Running make prepare for you to enable patched options of your choosing"
  make prepare

  # If user patched to BFQ and enabled it in the prev step, set it as default io scheduler
  if [ ${_BFQ_patches} = "y" ]; then
    sed -i s'/CONFIG_DEFAULT_CFQ=y/# CONFIG_DEFAULT_CFQ is not set/g' ./.config
    sed -i s'/# CONFIG_DEFAULT_BFQ is not set/CONFIG_DEFAULT_BFQ=y/g' ./.config
    sed -i s'/CONFIG_DEFAULT_IOSCHED="cfq"/CONFIG_DEFAULT_IOSCHED="bfq"/g' ./.config
  fi

  if [ $_streamline_ = "y" ]; then
  msg "If you have modprobe_db installed, running reload_database now"
  if [ -e /usr/bin/reload_database ]; then
   /usr/bin/reload_database
  fi
  msg "Running Steven Rostedt's streamline_config script now "
  chmod +x ./scripts/kconfig/streamline_config.pl
  ./scripts/kconfig/streamline_config.pl > config_strip
  cp config_strip .config
  msg "An error about ksource in line 118 blah blah is NORMAL as are the one you will get for each"
  msg "module you have probed that is not in the kernel itself like nvidia for example!"
  fi

  if [ $_makemenucfg = "y" ]; then
  msg "Running make menuconfig"
  make menuconfig
  fi

  # This allows building cpu-optimized packages with according package names.
  # Useful for repo maintainers.
  # Code by nous.
  CPU=`egrep "MK8=y|MCORE2=y|MPSC=y|MATOM=y|MPENTIUMII=y|MPENTIUMIII=y|MPENTIUMM=y|MPENTIUM4=y|MK7=y|CONFIG_GENERIC_CPU=y|CONFIG_X86_GENERIC=y|M686=y" ./.config`
  CPU=`sed -e "s/CONFIG_M\(.*\)=y/\1/" <<<$CPU`
  case $CPU in
    CORE2)
        _pn="-core2"
        _pd=" Intel Core2 optimized."
        ;;
    K8)
        _pn="-k8"
        _pd="AMD K8 optimized."
        ;;
    PSC)
        _pn="-psc"
        _pd="Intel Pentium4/D/Xeon optimized."
        ;;
    ATOM)
        _pn="-atom"
        _pd="Intel Atom optimized."
        ;;
    K7)
        _pn="-k7"
        _pd="AMD K7 optimized."
        ;;
    PENTIUMII)
        _pn="-p2"
        _pd="Intel Pentium2 optimized."
        ;;
    PENTIUMIII)
        _pn="-p3"
        _pd="Intel Pentium3 optimized."
        ;;
    PENTIUMM)
        _pn="-pm"
        _pd="Intel Pentium-M optimized."
        ;;
    PENTIUM4)
        _pn="-p4"
        _pd="Intel Pentium4 optimized."
        ;;
    default)
        ;;
  esac
  # save to a file for reacall in subsequent sections
  echo "_pn=\"${_pn}\"" > vars
  echo "_pd=\"${_pd}\"" >> vars

  msg "Running make bzImage and modules"
  make bzImage modules
}

package_kernel26-ck() {
. ${srcdir}/linux-$_basekernel/vars
pkgname="kernel26-ck${_pn}"
pkgdesc="ARCH kernel with Con Kolivas' patchset using the Brain Fuck Scheduler (BFS). Budget Fair Queueing (BFQ) I/O scheduler optional.${_pd}"
backup=(etc/mkinitcpio.d/kernel26.preset)
depends=('coreutils' 'linux-firmware' 'module-init-tools' 'mkinitcpio>=0.5.20')
install=kernel26.install
optdepends=('crda: to set the correct wireless channels of your country' \
'nvidia-ck-stable: NVIDIA drivers for kernel26-ck' \
'nvidia-beta-ck: NVIDIA beta drivers for kernel26-ck' \
'modprobed_db: Keeps track of EVERY kernel module that has ever been probed - useful for those of us who make localmodconfig')
  KARCH=x86
  cd ${srcdir}/linux-$_basekernel
  #get kernel version
  _kernver="$(make kernelrelease)"
  mkdir -p ${pkgdir}/{lib/modules,lib/firmware,boot}
  msg "Running make modules_install"
  make INSTALL_MOD_PATH=${pkgdir} modules_install
  cp System.map ${pkgdir}/boot/System.map26${_kernelname}
  cp arch/$KARCH/boot/bzImage ${pkgdir}/boot/vmlinuz26${_kernelname}

  # add vmlinux
  install -m644 -D vmlinux ${pkgdir}/usr/src/linux-${_kernver}/vmlinux

  # install fallback mkinitcpio.conf file and preset file for kernel
  install -m644 -D ${srcdir}/kernel26.preset ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset

  # set correct depmod command for install
  sed \
    -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
    -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
    -i $startdir/kernel26.install
  sed \
    -e "s|source .*|source /etc/mkinitcpio.d/kernel26${_kernelname}.kver|g" \
    -e "s|default_image=.*|default_image=\"/boot/${pkgname}.img\"|g" \
    -e "s|fallback_image=.*|fallback_image=\"/boot/${pkgname}-fallback.img\"|g" \
    -i ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset

  echo -e "# DO NOT EDIT THIS FILE\nALL_kver='${_kernver}'" > ${pkgdir}/etc/mkinitcpio.d/${pkgname}.kver

  # remove build and source links
  rm -f ${pkgdir}/lib/modules/${_kernver}/{source,build}

  # remove the firmware
  rm -rf ${pkgdir}/lib/firmware
}

package_kernel26-ck-headers () {
. ${srcdir}/linux-$_basekernel/vars
pkgname="kernel26-ck-headers${_pn}"
pkgdesc="Header files and scripts to build modules for kernel26-ck.${_pd}"
provides=("kernel26-ck-headers${_pn}=${pkgver}")

  mkdir -p ${pkgdir}/lib/modules/${_kernver}
  cd ${pkgdir}/lib/modules/${_kernver}
  ln -sf ../../../usr/src/linux-${_kernver} build
  cd ${srcdir}/linux-$_basekernel
  install -D -m644 Makefile \
    ${pkgdir}/usr/src/linux-${_kernver}/Makefile
  install -D -m644 kernel/Makefile \
    ${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile
  install -D -m644 .config \
    ${pkgdir}/usr/src/linux-${_kernver}/.config
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include

  for i in acpi asm-generic config generated linux math-emu media net pcmcia scsi sound trace video; do
    cp -a include/$i ${pkgdir}/usr/src/linux-${_kernver}/include/
  done

  # copy arch includes for external modules
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/x86
  cp -a arch/x86/include ${pkgdir}/usr/src/linux-${_kernver}/arch/x86/

  # copy files necessary for later builds, like nvidia and vmware
  cp Module.symvers ${pkgdir}/usr/src/linux-${_kernver}
  cp -a scripts ${pkgdir}/usr/src/linux-${_kernver}

  # fix permissions on scripts dir
  chmod og-w -R ${pkgdir}/usr/src/linux-${_kernver}/scripts
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions

  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel

  cp arch/$KARCH/Makefile ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
  if [ "$CARCH" = "i686" ]; then
    cp arch/$KARCH/Makefile_32.cpu ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
  fi
  cp arch/$KARCH/kernel/asm-offsets.s ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel/

  # add headers for lirc package
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video
  cp drivers/media/video/*.h  ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/
  # need to remove zc0301 from the array with 2.26.36
  for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102 usbvideo; do
   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
   cp -a drivers/media/video/$i/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
  done
  # add docbook makefile
  install -D -m644 Documentation/DocBook/Makefile \
    ${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile
  # add dm headers
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
  cp drivers/md/*.h  ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
  # add inotify.h
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/linux
  cp include/linux/inotify.h ${pkgdir}/usr/src/linux-${_kernver}/include/linux/
  # add wireless headers
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
  cp net/mac80211/*.h ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
  # add dvb headers for external modules
  # in reference to:
  # http://bugs.archlinux.org/task/9912
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core
  cp drivers/media/dvb/dvb-core/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/
  # add dvb headers for external modules
  # in reference to:
  # http://bugs.archlinux.org/task/11194
  if [ -d ${srcdir}/linux-$_basekernel/include/config/dvb ]; then
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
  cp include/config/dvb/*.h ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
  fi
  # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
  # in reference to:
  # http://bugs.archlinux.org/task/13146
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
  cp drivers/media/dvb/frontends/lgdt330x.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
  cp drivers/media/video/msp3400-driver.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
  # add dvb headers
  # in reference to:
  # http://bugs.archlinux.org/task/20402
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb
  cp drivers/media/dvb/dvb-usb/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends
  cp drivers/media/dvb/frontends/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners
  cp drivers/media/common/tuners/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/
  # add xfs and shmem for aufs building
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/mm
  cp fs/xfs/xfs_sb.h ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h
  # add headers for virtualbox
  # in reference to:
  # http://bugs.archlinux.org/task/14568
  cp -a include/drm $pkgdir/usr/src/linux-${_kernver}/include/
  # add headers for broadcom wl
  # in reference to:
  # http://bugs.archlinux.org/task/14568
  cp -a include/trace $pkgdir/usr/src/linux-${_kernver}/include/
  # copy in Kconfig files
  for i in `find . -name "Kconfig*"`; do
   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
   cp $i ${pkgdir}/usr/src/linux-${_kernver}/$i
  done

  chown -R root.root ${pkgdir}/usr/src/linux-${_kernver}
  find ${pkgdir}/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
  # remove unneeded architectures
  rm -rf ${pkgdir}/usr/src/linux-${_kernver}/arch/{alpha,arm,arm26,avr32,blackfin,cris,frv,h8300,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,parisc,powerpc,ppc,s390,sh,sh64,sparc,sparc64,um,v850,xtensa}
}

# Global pkgdesc and depends are here so that they will be picked up by AUR
pkgdesc="ARCH kernel with Con Kolivas' patchset using the Brain Fuck Scheduler (BFS).  Budget Fair Queueing (BFQ) I/O scheduler optional."
depends=('coreutils' 'linux-firmware' 'module-init-tools' 'mkinitcpio>=0.5.20')
sha256sums=('15a076d1a435a6bf8e92834eba4b390b4ec094ce06d47f89d071ca9e5788ce04'
            '96ed15bd64ae90163f81996ee31c3db6c7433d8af156e546ca7b36bedec1728b'
            '1b9abff4752d4a294716b05ae17b981e2e5aaae1b51d19613e6b4bac0aea989d'
            'd1b8757e99ee6cbeacf0b4185236c654440d5d945458b94948fd2cc4af0a881d'
            '7ead13bbe2fdfc5308ddc3a0484d66f8150f78bbdbc59643e0b52bb9e776b5da'
            '092e17164f453bdca8bd50e4fd71c074755740252bd8ad5c3eb6d2d51e78a104'
            'f5c42a2ec2869a756e53fabada51a25dcb9de13861f367463e9ec4da8bf0b86a'
            'f3f52953a2ccc07af3f23c7252e08e61580ec4b165934c089351ddd719c3e41f'
            'cca4eea16278e302c2f7649a145e4d5ceb5ff2ece25fea3988eca82290b0c633')

@Allan - can you see any other potential down sides of implementing the patch suggested by nous?  What about dependency issues?  For example, nvidia-ck depends on kernel26-ck, not kernel26-ck-core2.  Perhaps circumvent this with a provides=('kernel26-ck-headers') for headers and provides=('kernel26-ck') for the main package?

Last edited by graysky (2010-11-24 23:08:02)

Offline

#8 2010-11-24 23:16:15

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,653
Website

Re: need some help with a split package

Ah... I see...   In your package_ () function you have:

pkgname="kernel26-ck-headers${_pn}"

That is why the adjustments to makepkg are not breaking things tongue   With those changes all other split packages you use will also have to define pkgname in their package() functions...

Online

#9 2010-11-24 23:20:21

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,653
Website

Re: need some help with a split package

This is how I would do it....

for _pn in core2 k8....  do

package_kernel26-$_pn() {
...
}
package_kernel26-headers-$_pn() {
...
}

done

So just loop over the possible processors and redefine the package function for each of them.

Online

#10 2010-11-24 23:25:48

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,729
Website

Re: need some help with a split package

I tried having a variable in the package function name before I looped in nous on this and it didn't build.  My presumption was that the name of the function must match the packagenames in the arrays.... also, the $_pn is defined AFTER the build starts so it's like a chicken/egg thing smile

The goal isn't to build packages for all possible CPUs... just to build both packages for the user's specific system.

$ makepkg -src
/dev/shm/kernel26-ck/PKGBUILD: line 236: `package_kernel26-ck${_pn}': not a valid identifier
/dev/shm/kernel26-ck/PKGBUILD: line 349: `package_kernel26-ck-headers${_pn}': not a valid identifier
==> ERROR: missing package function for split package 'kernel26-ck'

Last edited by graysky (2010-11-24 23:30:46)

Offline

#11 2010-11-24 23:31:52

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,653
Website

Re: need some help with a split package

The looping itself works...  there are official packages that do that.

I think you would just have to set the pkgname variable in your build() function once you have decided what you are building.

Online

#12 2010-11-24 23:34:09

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,729
Website

Re: need some help with a split package

Allan wrote:

The looping itself works...  there are official packages that do that.

I think you would just have to set the pkgname variable in your build() function once you have decided what you are building.

Can that happen from within the PKGBUILD?  In otherwords, the source has to be extracted and semi-processed before it generates a .config for building.  The pkgname will depend on what is in that .config file which is why I don't think that can happen since makepkg will source the PKGBUILD prior to starting the build.  Plus, for split packages, makepkg will check to see if there are corresponding package functions for what is defined outside of the build array.  Does that make sense and do I have this right?

Last edited by graysky (2010-11-25 00:01:31)

Offline

#13 2010-11-25 00:28:37

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,653
Website

Re: need some help with a split package

Hmm...  I will have a play with an small example and see what I can come up with.

Online

#14 2010-11-25 06:32:26

nous
Member
From: Across the Universe
Registered: 2006-08-18
Posts: 323
Website

Re: need some help with a split package

graysky wrote:

also, the $_pn is defined AFTER the build starts so it's like a chicken/egg thing smile

BTW, I tested the 'export' bash built-in and it seems to advertise correctly $_pn and $_pd outside build(), ergo you could get rid of the temporary vars file.

Offline

#15 2010-11-25 06:40:19

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,729
Website

Re: need some help with a split package

Thanks for the tip, nous.  Might be a mute point if the issue in post #12 keeps it from working though...

Offline

#16 2010-11-25 06:49:04

nous
Member
From: Across the Universe
Registered: 2006-08-18
Posts: 323
Website

Re: need some help with a split package

graysky wrote:

Thanks for the tip, nous.  Might be a mute point if the issue in post #12 keeps it from working though...

From what I glanced through makepkg last night, it's rather impossible to do what you want without some tweaking of makepkg itself (the chicken-egg thing you mentioned). But if all you wanna do is create binaries for some unofficial repo, then that shouldn't be a problem.

Last edited by nous (2010-11-25 06:50:35)

Offline

#17 2011-01-09 22:32:26

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,729
Website

Re: need some help with a split package

Allan wrote:

This is how I would do it....

for _pn in core2 k8....  do

package_kernel26-$_pn() {
...
}
package_kernel26-headers-$_pn() {
...
}

done

So just loop over the possible processors and redefine the package function for each of them.

I finally got around to trying this and setup the PKGBUILD as you suggested (with the for loop).  I can't build it though; makepkg is angry that my functions contain a variable.  Any thoughts?

$ makepkg -src
/dev/shm/kernel26-ck/PKGBUILD: line 65: `package_kernel26-ck-$_pt': not a valid identifier
/dev/shm/kernel26-ck/PKGBUILD: line 65: `package_kernel26-ck-headers-$_pt': not a valid identifier
/dev/shm/kernel26-ck/PKGBUILD: line 65: `package_kernel26-ck-$_pt': not a valid identifier
/dev/shm/kernel26-ck/PKGBUILD: line 65: `package_kernel26-ck-headers-$_pt': not a valid identifier
/dev/shm/kernel26-ck/PKGBUILD: line 65: `package_kernel26-ck-$_pt': not a valid identifier
/dev/shm/kernel26-ck/PKGBUILD: line 65: `package_kernel26-ck-headers-$_pt': not a valid identifier
==> ERROR: missing package function for split package 'kernel26-ck'

Here is the draft PKGBUILD note that the for loop starts at line 65:
http://pastebin.com/m3g8JpWV

Last edited by graysky (2011-01-09 22:33:45)

Offline

#18 2011-01-09 23:44:44

nous
Member
From: Across the Universe
Registered: 2006-08-18
Posts: 323
Website

Re: need some help with a split package

graysky wrote:

I finally got around to trying this and setup the PKGBUILD as you suggested (with the for loop).  I can't build it though; makepkg is angry that my functions contain a variable.  Any thoughts?

$ makepkg -src
/dev/shm/kernel26-ck/PKGBUILD: line 65: `package_kernel26-ck-$_pt': not a valid identifier
/dev/shm/kernel26-ck/PKGBUILD: line 65: `package_kernel26-ck-headers-$_pt': not a valid identifier
/dev/shm/kernel26-ck/PKGBUILD: line 65: `package_kernel26-ck-$_pt': not a valid identifier
/dev/shm/kernel26-ck/PKGBUILD: line 65: `package_kernel26-ck-headers-$_pt': not a valid identifier
/dev/shm/kernel26-ck/PKGBUILD: line 65: `package_kernel26-ck-$_pt': not a valid identifier
/dev/shm/kernel26-ck/PKGBUILD: line 65: `package_kernel26-ck-headers-$_pt': not a valid identifier
==> ERROR: missing package function for split package 'kernel26-ck'

Here is the draft PKGBUILD note that the for loop starts at line 65:
http://pastebin.com/m3g8JpWV

I gave your PKGBUILD a try, but makepkg just doesn't like dynamic package() functions. A few points:
  1. you have to define all package names in your true && pkgname=(...)
  2. you loop $_pt but you append $_pn
  3. unless I'm mistaken, the headers are exactly the same for all architectures, so why package() separate ones?

As I've posted elsewhere, it's not possible to pass variables to split package(), because of the way the run_package() function of makepkg is written. This is how far I got with your original PKGBUILD: http://pastebin.com/QAEpqBNK

Offline

#19 2011-01-10 00:25:06

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,729
Website

Re: need some help with a split package

Thanks, nous.  Good points you make.  I found that if I comment out the line 41 it actually runs (compiling now).

EDIT: ack, it only got through one iteration.  F*ck it.

Last edited by graysky (2011-01-10 00:43:34)

Offline

#20 2011-01-10 13:33:10

nous
Member
From: Across the Universe
Registered: 2006-08-18
Posts: 323
Website

Re: need some help with a split package

Write a wrapper bash script that sed's the PKGBUILD itself. Off the top of my head, it could be like

#!/bin/bash

echo "Building generic -ck"
makepkg  # for the first generic run

for pkgarch in core2 k8 atom; do
   echo "Building -ck-$pkgarch"
   export $pkgarch
   sed -i s/-ck/-ck-$pkgarch/g PKGBUILD
  makepkg -e
done

The export built-in is used to pass $pkgarch to the child process, so you should modify the PKGBUILD to catch it  and in turn modify the .config.

Offline

#21 2011-01-12 21:51:21

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,729
Website

Re: need some help with a split package

@nous - this is a stroke of genius.  Let me see what I can do with your code.  Thanks!

Offline

#22 2011-01-16 09:50:19

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,729
Website

Re: need some help with a split package

@nous - I got it.  Thank you again for your wrapper script idea.  I can post the code if you wish (it is NOT elegant)!

Offline

#23 2011-01-16 11:56:42

nous
Member
From: Across the Universe
Registered: 2006-08-18
Posts: 323
Website

Re: need some help with a split package

graysky wrote:

@nous - I got it.  Thank you again for your wrapper script idea.  I can post the code if you wish (it is NOT elegant)!

By all means, this is what code police is for!

Offline

#24 2011-01-16 12:02:19

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,729
Website

Re: need some help with a split package

nous wrote:
graysky wrote:

@nous - I got it.  Thank you again for your wrapper script idea.  I can post the code if you wish (it is NOT elegant)!

By all means, this is what code police is for!

Cool.  I uploaded it to my github.  Again, not very elegant code but it gets the job done for me.
https://github.com/graysky2/bin

Offline

#25 2011-01-16 12:14:43

nous
Member
From: Across the Universe
Registered: 2006-08-18
Posts: 323
Website

Re: need some help with a split package

graysky wrote:
nous wrote:
graysky wrote:

@nous - I got it.  Thank you again for your wrapper script idea.  I can post the code if you wish (it is NOT elegant)!

By all means, this is what code police is for!

Cool.  I uploaded it to my github.  Again, not very elegant code but it gets the job done for me.
https://github.com/graysky2/bin

It's very decent, really. <Sith mode>Now, I'll tell you a little secret: I was looking for someone to write this wrapper script because so far I was compiling my kernel26-pf packages one by one. Rise now, Lord Skyous.</Sith mode>

Good work!

Offline

Board footer

Powered by FluxBB