makedist.sh, functions.inc.sh: update to current production

This commit is contained in:
Silvan Calarco 2022-05-21 18:32:58 +02:00
parent 7b90c215ee
commit feda208e18
2 changed files with 54 additions and 27 deletions

View File

@ -76,6 +76,23 @@ function add_additional_defs_file() {
rm -f ${tmpfile}
}
function create_devices() {
echo "Creating devices in /dev..."
#mkdir -p $MOUNTDIR/dev
(cd $MOUNTDIR/dev
ln -sf /proc/self/fd fd
ln -sf /proc/self/fd/0 stdin
ln -sf /proc/self/fd/1 stdout
ln -sf /proc/self/fd/2 stderr
ln -sf /proc/kcore core
mkdir shm pts
mknod --mode=0600 initctl p
mknod -m666 null c 1 3
mknod -m600 console c 5 1
mknod -m444 urandom c 1 9
)
}
function initialize_root_dir() {
echo "Mounting tmpfs on MOUNTDIR (size=$MOUNTDIR_TMPFS_SIZE)..."
[ "$MOUNTDIR" == "" -o "$MOUNTDIR" == "/" ] && {
@ -95,10 +112,32 @@ function initialize_root_dir() {
mkdir $MOUNTDIR/proc
mount -o bind /proc $MOUNTDIR/proc
mkdir $MOUNTDIR/dev
mount none -t tmpfs $MOUNTDIR/dev
mkdir $MOUNTDIR/run
mount -o bind /run $MOUNTDIR/run
mkdir $MOUNTDIR/sys
mount -o bind /sys $MOUNTDIR/sys
create_devices
# / to /usr symlinks
mkdir -p $MOUNTDIR/usr/{bin,sbin,lib}
ln -s usr/bin $MOUNTDIR/bin
ln -s usr/sbin $MOUNTDIR/sbin
ln -s usr/lib $MOUNTDIR/lib
if [ "${arch}" = "x86_64" -o "${arch}" = "aarch64" ]; then
mkdir -p $MOUNTDIR/usr/lib64
ln -s usr/lib64 $MOUNTDIR/lib64
fi
#[ $MEDIA = "raw" ] && create_raw_filesystem $LOCALSTATEDIR/$MEDIA_NAME $MEDIA_SIZE 1024k $ROOTFS
[ $MEDIA = "raw" ] && create_raw_disk_image $MEDIA_SIZE 1024k
trap "[ $LOOPDEV ] && losetup -d $LOOPDEV; [ -e $MOUNTDIR/proc/version ] && umount $MOUNTDIR/proc; chroot $MOUNTDIR /usr/bin/gpgconf --kill gpg-agent 2>/dev/null; [ \"$MOUNTDIR_TMPFS\" ] && umount $MOUNTDIR_TMPFS" 0 HUP INT QUIT ABRT KILL TERM
trap "[ $LOOPDEV ] && losetup -d $LOOPDEV; chroot $MOUNTDIR /usr/bin/gpgconf --kill gpg-agent 2>/dev/null; [ -e $MOUNTDIR/proc/version ] && umount $MOUNTDIR/proc; [ -e $MOUNTDIR/dev/null ] && umount $MOUNTDIR/dev; [ -e $MOUNTDIR/run/systemd ] && umount $MOUNTDIR/run; [ -e $MOUNTDIR/sys/kernel ] && umount $MOUNTDIR/sys; [ \"$MOUNTDIR_TMPFS\" ] && umount $MOUNTDIR_TMPFS" 0 HUP INT QUIT ABRT KILL TERM
}
function create_rpm_database() {
@ -237,7 +276,7 @@ function get_rpm_version() {
set_rpm_dirs
find $RPM_DIRS -maxdepth 1 -regex ".*/${1}-[^-]*-[^-]*" | \
grep -m 1 "" | \
sed "s|.*/${1}-\([^-]*\)-[^-]*|\1|"
sed "s|.*/${1}-\([^-]*-[0-9]*\)[^-]*|\1|"
#find $RPMDIR -regex ".*/${1//+/\\+}-[^-]*-[^-]*" | sed "s|.*/${1//+/\\+}-\([^-]*\)-[^-]*|\1|"
#find $NOARCHDIR -regex ".*/${1//+/\\+}-[^-]*-[^-]*" | sed "s|.*/${1//+/\\+}-\([^-]*\)-[^-]*|\1|"
}
@ -563,7 +602,7 @@ function install_rpms_by_target() {
resolve_pkg_deps "$INSTALLED" "$2"
TOINSTALL="$PKGS_RESOLVED"
RESOLVE_PKG_DEPS_NOERROR=1
if [ "$INSTALL_DEVEL_PACKAGES" ]; then
for p in $TOINSTALL; do
@ -1044,7 +1083,14 @@ function produce_media() {
[ "$1" ] && MEDIUM_FILENAME=$1 || MEDIUM_FILENAME=`medium_name`
[ -e $MOUNTDIR/proc/version ] && umount $MOUNTDIR/proc
[ -e $MOUNTDIR/proc/version ] && {
# Kill any process running in chroot
[ "$MOUNTDIR" != "/" -a "$MOUNTDIR" != "" ] && lsof -t $MOUNTDIR | while read line; do kill -9 $line; done
umount $MOUNTDIR/proc
umount $MOUNTDIR/dev
umount $MOUNTDIR/run
umount $MOUNTDIR/sys
}
TARGETSIZE=`du -sh $MOUNTDIR | sed "s|[[:space:]].*||"`
echo "Uncompressed occupacy size is: ${TARGETSIZE}"
@ -1107,12 +1153,10 @@ function produce_media() {
;;
iso-grub|ISO-GRUB)
echo "Producing ISO-GRUB image $MEDIUM_FILENAME..."
grub_mkisofs_arguments="-volid $MAKEDIST_TARGET -volset $PLATFORM -publisher mambaSoft -preparer makedist -quiet" \
grub-mkrescue --output=$LOCALSTATEDIR/$MEDIUM_FILENAME $MOUNTDIR &> /dev/null
[ $? ] && {
grub-mkrescue -o $LOCALSTATEDIR/$MEDIUM_FILENAME $MOUNTDIR -- -volid ${MAKEDIST_TARGET}_${PLATFORM} &> /dev/null
[ $? -ne 0 ] && {
echo "Error $? returned by grub-mkrescue; command line was:
grub_mkisofs_arguments=\"-volid $MAKEDIST_TARGET -volset $PLATFORM -publisher mambaSoft -preparer makedist -quiet\" \
grub-mkrescue --output=$LOCALSTATEDIR/$MEDIUM_FILENAME $MOUNTDIR"
grub-mkrescue -o $LOCALSTATEDIR/$MEDIUM_FILENAME $MOUNTDIR -- -volid ${MAKEDIST_TARGET}_${PLATFORM}"
}
;;
raw|RAW)

View File

@ -307,23 +307,6 @@ function create_raw_disk_image() {
losetup $LOOPDEV $LOOPDEVIMGFILE
}
function create_devices() {
echo "Creating devices in /dev..."
mkdir -p $MOUNTDIR/dev
(cd $MOUNTDIR/dev
ln -sf /proc/self/fd fd
ln -sf /proc/self/fd/0 stdin
ln -sf /proc/self/fd/1 stdout
ln -sf /proc/self/fd/2 stderr
ln -sf /proc/kcore core
mkdir shm pts
mknod --mode=0600 initctl p
mknod -m666 null c 1 3
mknod -m600 console c 5 1
mknod -m444 urandom c 1 9
)
}
function create_fstab() {
# create the /etc/fstab file
#
@ -398,7 +381,7 @@ function rootfs_post_operations() {
# remove unuseful files
echo " + Removing unuseful files..."
#rm -rf usr/share/{man,info,tmp} dev tmp var
rm -rf $MOUNTDIR/usr/share/tmp $MOUNTDIR/dev/ $MOUNTDIR/var/log/* \
rm -rf $MOUNTDIR/usr/share/tmp $MOUNTDIR/var/log/* \
$MOUNTDIR/tmp/*
echo " + Making absolute relative links to /etc and /var... "