~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/scripts/package/builddeb

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /scripts/package/builddeb (Version linux-6.12-rc7) and /scripts/package/builddeb (Version linux-4.18.20)


  1 #!/bin/sh                                           1 #!/bin/sh
  2 #                                                   2 #
  3 # builddeb 1.3                                      3 # builddeb 1.3
  4 # Copyright 2003 Wichert Akkerman <wichert@wigg      4 # Copyright 2003 Wichert Akkerman <wichert@wiggy.net>
  5 #                                                   5 #
  6 # Simple script to generate a deb package for       6 # Simple script to generate a deb package for a Linux kernel. All the
  7 # complexity of what to do with a kernel after      7 # complexity of what to do with a kernel after it is installed or removed
  8 # is left to other scripts and packages: they       8 # is left to other scripts and packages: they can install scripts in the
  9 # /etc/kernel/{pre,post}{inst,rm}.d/ directori      9 # /etc/kernel/{pre,post}{inst,rm}.d/ directories (or an alternative location
 10 # specified in KDEB_HOOKDIR) that will be call     10 # specified in KDEB_HOOKDIR) that will be called on package install and
 11 # removal.                                         11 # removal.
 12                                                    12 
 13 set -eu                                        !!  13 set -e
 14                                                    14 
 15 is_enabled() {                                 !!  15 create_package() {
 16         grep -q "^$1=y" include/config/auto.co !!  16         local pname="$1" pdir="$2"
 17 }                                              << 
 18                                                    17 
 19 if_enabled_echo() {                            !!  18         mkdir -m 755 -p "$pdir/DEBIAN"
 20         if is_enabled "$1"; then               !!  19         mkdir -p "$pdir/usr/share/doc/$pname"
 21                 echo -n "$2"                   !!  20         cp debian/copyright "$pdir/usr/share/doc/$pname/"
 22         elif [ $# -ge 3 ]; then                !!  21         cp debian/changelog "$pdir/usr/share/doc/$pname/changelog.Debian"
 23                 echo -n "$3"                   !!  22         gzip -9 "$pdir/usr/share/doc/$pname/changelog.Debian"
 24         fi                                     !!  23         sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \
 25 }                                              !!  24                 | xargs -r0 md5sum > DEBIAN/md5sums"
                                                   >>  25 
                                                   >>  26         # Fix ownership and permissions
                                                   >>  27         chown -R root:root "$pdir"
                                                   >>  28         chmod -R go-w "$pdir"
                                                   >>  29         # in case we are in a restrictive umask environment like 0077
                                                   >>  30         chmod -R a+rX "$pdir"
                                                   >>  31 
                                                   >>  32         # Create the package
                                                   >>  33         dpkg-gencontrol -p$pname -P"$pdir"
                                                   >>  34         dpkg --build "$pdir" ..
                                                   >>  35 }
                                                   >>  36 
                                                   >>  37 version=$KERNELRELEASE
                                                   >>  38 tmpdir="$objtree/debian/tmp"
                                                   >>  39 kernel_headers_dir="$objtree/debian/hdrtmp"
                                                   >>  40 libc_headers_dir="$objtree/debian/headertmp"
                                                   >>  41 dbg_dir="$objtree/debian/dbgtmp"
                                                   >>  42 packagename=linux-image-$version
                                                   >>  43 kernel_headers_packagename=linux-headers-$version
                                                   >>  44 libc_headers_packagename=linux-libc-dev
                                                   >>  45 dbg_packagename=$packagename-dbg
                                                   >>  46 
                                                   >>  47 if [ "$ARCH" = "um" ] ; then
                                                   >>  48         packagename=user-mode-linux-$version
                                                   >>  49 fi
                                                   >>  50 
                                                   >>  51 # Not all arches have the same installed path in debian
                                                   >>  52 # XXX: have each arch Makefile export a variable of the canonical image install
                                                   >>  53 # path instead
                                                   >>  54 case $ARCH in
                                                   >>  55 um)
                                                   >>  56         installed_image_path="usr/bin/linux-$version"
                                                   >>  57         ;;
                                                   >>  58 parisc|mips|powerpc)
                                                   >>  59         installed_image_path="boot/vmlinux-$version"
                                                   >>  60         ;;
                                                   >>  61 *)
                                                   >>  62         installed_image_path="boot/vmlinuz-$version"
                                                   >>  63 esac
                                                   >>  64 
                                                   >>  65 BUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)"
 26                                                    66 
 27 install_linux_image () {                       !!  67 # Setup the directory structure
 28         pname=$1                               !!  68 rm -rf "$tmpdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" $objtree/debian/files
 29         pdir=debian/$1                         !!  69 mkdir -m 755 -p "$tmpdir/DEBIAN"
                                                   >>  70 mkdir -p "$tmpdir/lib" "$tmpdir/boot"
                                                   >>  71 mkdir -p "$kernel_headers_dir/lib/modules/$version/"
                                                   >>  72 
                                                   >>  73 # Build and install the kernel
                                                   >>  74 if [ "$ARCH" = "um" ] ; then
                                                   >>  75         mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" "$tmpdir/usr/share/doc/$packagename"
                                                   >>  76         $MAKE linux
                                                   >>  77         cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map"
                                                   >>  78         cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config"
                                                   >>  79         gzip "$tmpdir/usr/share/doc/$packagename/config"
                                                   >>  80 else
                                                   >>  81         cp System.map "$tmpdir/boot/System.map-$version"
                                                   >>  82         cp $KCONFIG_CONFIG "$tmpdir/boot/config-$version"
                                                   >>  83 fi
                                                   >>  84 cp "$($MAKE -s image_name)" "$tmpdir/$installed_image_path"
 30                                                    85 
                                                   >>  86 if grep -q "^CONFIG_OF=y" $KCONFIG_CONFIG ; then
 31         # Only some architectures with OF supp     87         # Only some architectures with OF support have this target
 32         if is_enabled CONFIG_OF_EARLY_FLATTREE !!  88         if grep -q dtbs_install "${srctree}/arch/$SRCARCH/Makefile"; then
 33                 ${MAKE} -f ${srctree}/Makefile !!  89                 $MAKE KBUILD_SRC= INSTALL_DTBS_PATH="$tmpdir/usr/lib/$packagename" dtbs_install
 34         fi                                         90         fi
                                                   >>  91 fi
 35                                                    92 
 36         ${MAKE} -f ${srctree}/Makefile INSTALL !!  93 if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then
 37         rm -f "${pdir}/lib/modules/${KERNELREL !!  94         INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_install
 38                                                !!  95         rm -f "$tmpdir/lib/modules/$version/build"
 39         # Install the kernel                   !!  96         rm -f "$tmpdir/lib/modules/$version/source"
 40         if [ "${ARCH}" = um ] ; then           !!  97         if [ "$ARCH" = "um" ] ; then
 41                 mkdir -p "${pdir}/usr/lib/uml/ !!  98                 mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/"
 42                 mv "${pdir}/lib/modules/${KERN !!  99                 rmdir "$tmpdir/lib/modules/$version"
 43                 mkdir -p "${pdir}/usr/bin" "${ << 
 44                 cp System.map "${pdir}/usr/lib << 
 45                 cp ${KCONFIG_CONFIG} "${pdir}/ << 
 46                 gzip "${pdir}/usr/share/doc/${ << 
 47         else                                   << 
 48                 mkdir -p "${pdir}/boot"        << 
 49                 cp System.map "${pdir}/boot/Sy << 
 50                 cp ${KCONFIG_CONFIG} "${pdir}/ << 
 51         fi                                        100         fi
                                                   >> 101         if [ -n "$BUILD_DEBUG" ] ; then
                                                   >> 102                 for module in $(find $tmpdir/lib/modules/ -name *.ko -printf '%P\n'); do
                                                   >> 103                         module=lib/modules/$module
                                                   >> 104                         mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module)
                                                   >> 105                         # only keep debug symbols in the debug file
                                                   >> 106                         $OBJCOPY --only-keep-debug $tmpdir/$module $dbg_dir/usr/lib/debug/$module
                                                   >> 107                         # strip original module from debug symbols
                                                   >> 108                         $OBJCOPY --strip-debug $tmpdir/$module
                                                   >> 109                         # then add a link to those
                                                   >> 110                         $OBJCOPY --add-gnu-debuglink=$dbg_dir/usr/lib/debug/$module $tmpdir/$module
                                                   >> 111                 done
                                                   >> 112 
                                                   >> 113                 # resign stripped modules
                                                   >> 114                 MODULE_SIG_ALL="$(grep -s '^CONFIG_MODULE_SIG_ALL=y' $KCONFIG_CONFIG || true)"
                                                   >> 115                 if [ -n "$MODULE_SIG_ALL" ]; then
                                                   >> 116                         INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_sign
                                                   >> 117                 fi
                                                   >> 118         fi
                                                   >> 119 fi
 52                                                   120 
 53         # Not all arches have the same install !! 121 if [ "$ARCH" != "um" ]; then
 54         # XXX: have each arch Makefile export  !! 122         $MAKE headers_check KBUILD_SRC=
 55         # path instead                         !! 123         $MAKE headers_install KBUILD_SRC= INSTALL_HDR_PATH="$libc_headers_dir/usr"
 56         case "${SRCARCH}" in                   !! 124 fi
 57         um)                                    !! 125 
 58                 installed_image_path="usr/bin/ !! 126 # Install the maintainer scripts
 59         parisc|mips|powerpc)                   !! 127 # Note: hook scripts under /etc/kernel are also executed by official Debian
 60                 installed_image_path="boot/vml !! 128 # kernel packages, as well as kernel packages built using make-kpkg.
 61         *)                                     !! 129 # make-kpkg sets $INITRD to indicate whether an initramfs is wanted, and
 62                 installed_image_path="boot/vml !! 130 # so do we; recent versions of dracut and initramfs-tools will obey this.
 63         esac                                   !! 131 debhookdir=${KDEB_HOOKDIR:-/etc/kernel}
 64         cp "$(${MAKE} -s -f ${srctree}/Makefil !! 132 if grep -q '^CONFIG_BLK_DEV_INITRD=y' $KCONFIG_CONFIG; then
 65                                                !! 133         want_initrd=Yes
 66         # Install the maintainer scripts       !! 134 else
 67         # Note: hook scripts under /etc/kernel !! 135         want_initrd=No
 68         # kernel packages, as well as kernel p !! 136 fi
 69         # make-kpkg sets $INITRD to indicate w !! 137 for script in postinst postrm preinst prerm ; do
 70         # so do we; recent versions of dracut  !! 138         mkdir -p "$tmpdir$debhookdir/$script.d"
 71         debhookdir=${KDEB_HOOKDIR:-/etc/kernel !! 139         cat <<EOF > "$tmpdir/DEBIAN/$script"
 72         for script in postinst postrm preinst  !! 140 #!/bin/sh
 73                 mkdir -p "${pdir}${debhookdir} !! 141 
 74                                                !! 142 set -e
 75                 mkdir -p "${pdir}/DEBIAN"      !! 143 
 76                 cat <<-EOF > "${pdir}/DEBIAN/$ !! 144 # Pass maintainer script parameters to hook scripts
 77                 #!/bin/sh                      !! 145 export DEB_MAINT_PARAMS="\$*"
 78                                                !! 146 
 79                 set -e                         !! 147 # Tell initramfs builder whether it's wanted
 80                                                !! 148 export INITRD=$want_initrd
 81                 # Pass maintainer script param !! 149 
 82                 export DEB_MAINT_PARAMS="\$*"  !! 150 test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d
 83                                                !! 151 exit 0
 84                 # Tell initramfs builder wheth !! 152 EOF
 85                 export INITRD=$(if_enabled_ech !! 153         chmod 755 "$tmpdir/DEBIAN/$script"
 86                                                !! 154 done
 87                 test -d ${debhookdir}/${script !! 155 
 88                 exit 0                         !! 156 # Build kernel header package
 89                 EOF                            !! 157 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles"
 90                 chmod 755 "${pdir}/DEBIAN/${sc !! 158 (cd $srctree; find arch/*/include include scripts -type f -o -type l) >> "$objtree/debian/hdrsrcfiles"
 91         done                                   !! 159 (cd $srctree; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles"
 92 }                                              !! 160 (cd $srctree; find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles"
 93                                                !! 161 if grep -q '^CONFIG_STACK_VALIDATION=y' $KCONFIG_CONFIG ; then
 94 install_linux_image_dbg () {                   !! 162         (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles"
 95         pdir=debian/$1                         !! 163 fi
                                                   >> 164 (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles"
                                                   >> 165 if grep -q '^CONFIG_GCC_PLUGINS=y' $KCONFIG_CONFIG ; then
                                                   >> 166         (cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles"
                                                   >> 167 fi
                                                   >> 168 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
                                                   >> 169 mkdir -p "$destdir"
                                                   >> 170 (cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -)
                                                   >> 171 (cd $objtree; tar -c -f - -T -) < "$objtree/debian/hdrobjfiles" | (cd $destdir; tar -xf -)
                                                   >> 172 (cd $objtree; cp $KCONFIG_CONFIG $destdir/.config) # copy .config manually to be where it's expected to be
                                                   >> 173 ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build"
                                                   >> 174 rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles"
                                                   >> 175 
                                                   >> 176 if [ "$ARCH" != "um" ]; then
                                                   >> 177         create_package "$kernel_headers_packagename" "$kernel_headers_dir"
                                                   >> 178         create_package "$libc_headers_packagename" "$libc_headers_dir"
                                                   >> 179 fi
 96                                                   180 
 97         # Parse modules.order directly because !! 181 create_package "$packagename" "$tmpdir"
 98         # compress modules, and then run unnee << 
 99         while read -r mod; do                  << 
100                 mod="${mod%.o}.ko"             << 
101                 dbg="${pdir}/usr/lib/debug/lib << 
102                 buildid=$("${READELF}" -n "${m << 
103                 link="${pdir}/usr/lib/debug/.b << 
104                                                << 
105                 mkdir -p "${dbg%/*}" "${link%/ << 
106                 "${OBJCOPY}" --only-keep-debug << 
107                 ln -sf --relative "${dbg}" "${ << 
108         done < modules.order                   << 
109                                                   182 
                                                   >> 183 if [ -n "$BUILD_DEBUG" ] ; then
110         # Build debug package                     184         # Build debug package
111         # Different tools want the image in di    185         # Different tools want the image in different locations
112         # perf                                    186         # perf
113         mkdir -p ${pdir}/usr/lib/debug/lib/mod !! 187         mkdir -p $dbg_dir/usr/lib/debug/lib/modules/$version/
114         cp vmlinux ${pdir}/usr/lib/debug/lib/m !! 188         cp vmlinux $dbg_dir/usr/lib/debug/lib/modules/$version/
115         # systemtap                               189         # systemtap
116         mkdir -p ${pdir}/usr/lib/debug/boot/   !! 190         mkdir -p $dbg_dir/usr/lib/debug/boot/
117         ln -s ../lib/modules/${KERNELRELEASE}/ !! 191         ln -s ../lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/boot/vmlinux-$version
118         # kdump-tools                             192         # kdump-tools
119         ln -s lib/modules/${KERNELRELEASE}/vml !! 193         ln -s lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/vmlinux-$version
120 }                                              !! 194         create_package "$dbg_packagename" "$dbg_dir"
                                                   >> 195 fi
121                                                   196 
122 install_kernel_headers () {                    !! 197 exit 0
123         pdir=debian/$1                         << 
124         version=${1#linux-headers-}            << 
125                                                << 
126         CC="${DEB_HOST_GNU_TYPE}-gcc" "${srctr << 
127                                                << 
128         mkdir -p $pdir/lib/modules/$version/   << 
129         ln -s /usr/src/linux-headers-$version  << 
130 }                                              << 
131                                                << 
132 install_libc_headers () {                      << 
133         pdir=debian/$1                         << 
134                                                << 
135         $MAKE -f $srctree/Makefile headers_ins << 
136                                                << 
137         # move asm headers to /usr/include/<li << 
138         # used by Debian-based distros (to sup << 
139         mkdir "$pdir/usr/include/${DEB_HOST_MU << 
140         mv "$pdir/usr/include/asm" "$pdir/usr/ << 
141 }                                              << 
142                                                << 
143 package=$1                                     << 
144                                                << 
145 case "${package}" in                           << 
146 *-dbg)                                         << 
147         install_linux_image_dbg "${package}";; << 
148 linux-image-*|user-mode-linux-*)               << 
149         install_linux_image "${package}";;     << 
150 linux-libc-dev)                                << 
151         install_libc_headers "${package}";;    << 
152 linux-headers-*)                               << 
153         install_kernel_headers "${package}";;  << 
154 esac                                           << 
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php