Explorar el Código

Package headers to go along with linux-spudd; stolen from linux-clear

Donald Carr hace 4 años
padre
commit
c38e3d8767
Se han modificado 1 ficheros con 87 adiciones y 4 borrados
  1. 87 4
      PKGBUILD

+ 87 - 4
PKGBUILD

@@ -12,17 +12,17 @@ arch=("x86_64" "aarch64" "armv7h")
 license=("GPL2.1")
 log_path="${PWD}/$(date +"%Y-%m-%d-%H%M").log"
 _kernel_src_dir=/opt/src/OSS/linux
-pkgname() {
+pkgbase() {
     oldpath=${PWD}
     cd $_kernel_src_dir
     postfix="spudd-$(git rev-parse --abbrev-ref HEAD)"
     if [[ -f testing ]]; then
         postfix=${postfix}-testing
     fi
-    pkgname=linux-${postfix}
+    pkgbase=linux-${postfix}
     cd ${oldpath}
 }
-pkgname
+pkgbase
 
 if [ -z "${LOCAL_PI_VER}" ]; then
     install=spudd.install
@@ -60,7 +60,90 @@ build() {
   fi
 }
 
-package() {
+_package-headers() {
+    pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
+
+    cd $_kernel_src_dir
+    local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
+
+    echo "Installing build files..."
+    install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
+        vmlinux
+    install -Dt "$builddir/kernel" -m644 kernel/Makefile
+    install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
+    cp -t "$builddir" -a scripts
+
+    # add objtool for external module building and enabled VALIDATION_STACK option
+    install -Dt "$builddir/tools/objtool" tools/objtool/objtool
+
+    # add xfs and shmem for aufs building
+    mkdir -p "$builddir"/{fs/xfs,mm}
+
+    echo "Installing headers..."
+    cp -t "$builddir" -a include
+    cp -t "$builddir/arch/x86" -a arch/x86/include
+    install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
+
+    install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
+    install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
+
+    # http://bugs.archlinux.org/task/13146
+    install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
+
+    # http://bugs.archlinux.org/task/20402
+    install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
+    install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
+    install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
+
+    echo "Installing KConfig files..."
+    find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
+
+    echo "Removing unneeded architectures..."
+    local arch
+    for arch in "$builddir"/arch/*/; do
+        [[ $arch = */x86/ ]] && continue
+        echo "Removing $(basename "$arch")"
+        rm -r "$arch"
+    done
+
+    echo "Removing documentation..."
+    rm -r "$builddir/Documentation"
+
+    echo "Removing broken symlinks..."
+    find -L "$builddir" -type l -printf 'Removing %P\n' -delete
+
+    echo "Removing loose objects..."
+    find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
+
+    echo "Stripping build tools..."
+    local file
+    while read -rd '' file; do
+        case "$(file -bi "$file")" in
+            application/x-sharedlib\;*)      # Libraries (.so)
+                strip -v $STRIP_SHARED "$file" ;;
+            application/x-archive\;*)        # Libraries (.a)
+                strip -v $STRIP_STATIC "$file" ;;
+            application/x-executable\;*)     # Binaries
+                strip -v $STRIP_BINARIES "$file" ;;
+            application/x-pie-executable\;*) # Relocatable binaries
+                strip -v $STRIP_SHARED "$file" ;;
+        esac
+    done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
+
+    echo "Adding symlink..."
+    mkdir -p "$pkgdir/usr/src"
+    ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
+}
+
+pkgname=("$pkgbase" "$pkgbase-headers")
+for _p in "${pkgname[@]}"; do
+  eval "package_$_p() {
+    $(declare -f "_package${_p#$pkgbase}")
+    _package${_p#$pkgbase}
+  }"
+done
+
+_package() {
   prepare
   boot_dir="${pkgdir}/boot"
   dtb_dir="${boot_dir}/dtbs"