diff --git a/gen_determineargs.sh b/gen_determineargs.sh index ac0a43a..dea0d0f 100755 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -4,6 +4,7 @@ get_KV() { if [ "${KERNEL_SOURCES}" = '0' -a -e "${KERNCACHE}" ] then + mkdir -p ${TEMP} /bin/tar -xj -C ${TEMP} -f ${KERNCACHE} kerncache.config if [ -e ${TEMP}/kerncache.config ] then @@ -11,7 +12,7 @@ get_KV() { PAT=`grep ^PATCHLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'` SUB=`grep ^SUBLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'` EXV=`grep ^EXTRAVERSION\ \= ${TEMP}/kerncache.config | sed -e "s/EXTRAVERSION =//" -e "s/ //g"` - LOV=`grep ^CONFIG_LOCALVERSION\= ${TEMP}/kerncache.config | sed -e "s/CONFIG_LOCALVERSION=\"\(.*\)\"/\1/"` + LOV=`grep ^CONFIG_LOCALVERSION\ \= ${TEMP}/kerncache.config | sed -e "s/CONFIG_LOCALVERSION =//" -e "s/ //g"` KV=${VER}.${PAT}.${SUB}${EXV}${LOV} else gen_die "Could not find kerncache.config in the kernel cache! Exiting." @@ -59,8 +60,8 @@ get_KV() { KV=${VER}.${PAT}.${SUB}${EXV}${LOV} else determine_config_file - LCV=`grep ^CONFIG_LOCALVERSION= "${KERNEL_CONFIG}" | sed -r -e "s/.*=\"(.*)\"/\1/"` - KV=${VER}.${PAT}.${SUB}${EXV}${LCV} + LOV=`grep ^CONFIG_LOCALVERSION= "${KERNEL_CONFIG}" | sed -r -e "s/.*=\"(.*)\"/\1/"` + KV=${VER}.${PAT}.${SUB}${EXV}${LOV} fi fi } diff --git a/gen_initramfs.sh b/gen_initramfs.sh index bd22bfd..a323ba2 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -273,7 +273,7 @@ append_iscsi(){ append_lvm(){ if [ -d "${TEMP}/initramfs-lvm-temp" ] then - rm -r "${TEMP}/initramfs-lvm-temp/" + rm -rf "${TEMP}/initramfs-lvm-temp/" fi cd ${TEMP} mkdir -p "${TEMP}/initramfs-lvm-temp"/{bin,sbin} @@ -305,7 +305,7 @@ append_lvm(){ find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \ || gen_die "compressing lvm cpio" cd "${TEMP}" - rm -r "${TEMP}/initramfs-lvm-temp/" + rm -rf "${TEMP}/initramfs-lvm-temp/" } append_mdadm(){ @@ -690,25 +690,33 @@ append_ld_so_conf() { # but we need to generate a valid ld.so.conf. So we extract the # current CPIO archive, run ldconfig -r against it and append the # last bits. - local tmp_dir_ext="${tmp_dir}/extracted" - mkdir -p "${tmp_dir_ext}" - mkdir -p "${tmp_dir}/etc" - cd "${tmp_dir_ext}" || gen_die "cannot cd into ${tmp_dir_ext}" - cpio -id --quiet < "${CPIO}" || gen_die "cannot re-extract ${CPIO}" - - cd "${tmp_dir}" || gen_die "cannot cd into ${tmp_dir}" - ldconfig -r "${tmp_dir_ext}" || \ - gen_die "cannot run ldconfig on ${tmp_dir_ext}" - cp -a "${tmp_dir_ext}/etc/ld.so.cache" "${tmp_dir}/etc/ld.so.cache" || \ - gen_die "cannot copy ld.so.cache" - rm -rf "${tmp_dir_ext}" + # + # We only do this if we are "root", because "ldconfig -r" requires + # root privileges to chroot. If we are not root we don't generate the + # ld.so.cache here, but expect that ldconfig would regenerate it when the + # machine boots. + if [[ $(id -u) == 0 && -z ${FAKED_MODE:-} ]]; then + local tmp_dir_ext="${tmp_dir}/extracted" + mkdir -p "${tmp_dir_ext}" + mkdir -p "${tmp_dir}/etc" + cd "${tmp_dir_ext}" || gen_die "cannot cd into ${tmp_dir_ext}" + cpio -id --quiet < "${CPIO}" || gen_die "cannot re-extract ${CPIO}" + + cd "${tmp_dir}" || gen_die "cannot cd into ${tmp_dir}" + ldconfig -r "${tmp_dir_ext}" || \ + gen_die "cannot run ldconfig on ${tmp_dir_ext}" + cp -a "${tmp_dir_ext}/etc/ld.so.cache" "${tmp_dir}/etc/ld.so.cache" || \ + gen_die "cannot copy ld.so.cache" + rm -rf "${tmp_dir_ext}" + + cd "${tmp_dir}" || gen_die "cannot cd into ${tmp_dir}" + log_future_cpio_content + find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \ + || gen_die "compressing ld.so.cache cpio" + cd "$(dirname "${tmp_dir}")" + rm -rf "${tmp_dir}" + fi - cd "${tmp_dir}" || gen_die "cannot cd into ${tmp_dir}" - log_future_cpio_content - find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \ - || gen_die "compressing ld.so.cache cpio" - cd "$(dirname "${tmp_dir}")" - rm -rf "${tmp_dir}" } print_list() diff --git a/gen_package.sh b/gen_package.sh index 1970a85..0dae3c0 100755 --- a/gen_package.sh +++ b/gen_package.sh @@ -95,6 +95,7 @@ gen_kerncache() echo "PATCHLEVEL = ${PAT}" >> "${TEMP}/kerncache/kerncache.config" echo "SUBLEVEL = ${SUB}" >> "${TEMP}/kerncache/kerncache.config" echo "EXTRAVERSION = ${EXV}" >> "${TEMP}/kerncache/kerncache.config" + echo "CONFIG_LOCALVERSION = ${LOV}" >> "${TEMP}/kerncache/kerncache.config" mkdir -p "${TEMP}/kerncache/lib/modules/" @@ -143,7 +144,7 @@ gen_kerncache_extract_modules() gen_kerncache_extract_config() { - if [ -e "${KERNCACHE}" ] + if [ -e "${KERNCACHE}" -a "${SAVE_CONFIG}" = '1' ] then print_info 1 'Extracting kerncache config to /etc/kernels' mkdir -p /etc/kernels @@ -155,7 +156,7 @@ gen_kerncache_extract_config() gen_kerncache_is_valid() { KERNCACHE_IS_VALID=0 - if [ "${NO_KERNEL_SOURCES}" = '1' ] + if [ "${KERNEL_SOURCES}" = '0' ] then BUILD_KERNEL=0