Skip to content

Commit

Permalink
Release v6.25 (#2950)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaIng authored Jul 3, 2019
2 parents 1590547 + 359ac70 commit 6c6dd50
Show file tree
Hide file tree
Showing 44 changed files with 5,277 additions and 4,749 deletions.
10 changes: 0 additions & 10 deletions .conf/desktop/apps/dietpi-process_tool.desktop

This file was deleted.

10 changes: 10 additions & 0 deletions .conf/desktop/apps/dietpi-services.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
Version=2.0
Name=DietPi-Services
Type=Application
Comment=Control system services and apply process tool tweaks
Terminal=true
Exec=/DietPi/dietpi/dietpi-services
Icon=/var/lib/dietpi/dietpi-software/installed/desktop/icons/dietpi-icon.png
Categories=ConsoleOnly;System;
GenericName=DietPi-Services
6 changes: 6 additions & 0 deletions .conf/dps_129/lighttpd.ompd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$HTTP["url"] =~ "^/ompd($|/)" {

# https://github.com/MichaIng/DietPi/issues/2156#issuecomment-497512475
server.stream-response-body = 1

}
9 changes: 9 additions & 0 deletions .conf/dps_176/mycroft.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"data_dir": "$G_FP_DIETPI_USERDATA/mycroft-data",
// As DietPi uses plain ALSA, default paplay is not available
"play_wav_cmdline": "aplay %1",
// Default DietPi asound.conf requires listener sample rate 48000 (default: 16000) is most cases
"listener": {
"sample_rate": 48000
}
}
260 changes: 260 additions & 0 deletions .meta/dietpi-imager
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
#!/bin/bash
{
#////////////////////////////////////
# DietPi Image creation/finalise Script
#
#////////////////////////////////////
# Created by Daniel Knight / [email protected] / dietpi.com
# Updated by MichaIng / [email protected] / dietpi.com
#
#////////////////////////////////////
# - Reads disk to image | or use existing .img file
# - Resizes RootFS partition
# - Hashes and 7z's the final image ready for release.
#////////////////////////////////////

# Import DietPi-Globals ---------------------------------------------------------------
. /DietPi/dietpi/func/dietpi-globals
G_PROGRAM_NAME='DietPi-Imager'
G_CHECK_ROOT_USER
G_CHECK_ROOTFS_RW
G_INIT
# Import DietPi-Globals ---------------------------------------------------------------

FP_SOURCE=''
FP_LOOPBACK=''
FP_ROOT_DEV=''
ROOT_PARTITION_INDEX=''
OUTPUT_IMG_NAME=''
OUTPUT_7Z_NAME=''
GPT=0
DIETPI_VERSION='v6.25'

Delete_Loopback(){

[[ $FP_LOOPBACK ]] && G_RUN_CMD losetup -d $FP_LOOPBACK

}

Exit_On_Fail(){

Delete_Loopback
exit 1

}

Menu_Main(){

G_WHIP_MENU_ARRAY=(

'Drive' ': Save a drive/disk contents to an image, that you can work with'
'Image' ': Use an existing image file (.img) to work with'

)

G_WHIP_MENU 'Please select an option:' || Exit_On_Fail
if [[ $G_WHIP_RETURNED_VALUE == 'Drive' ]]; then

# Detect drives and list for selection
G_WHIP_MENU_ARRAY=($(lsblk -npo NAME,SIZE | grep '^/'))
if [[ ! $G_WHIP_MENU_ARRAY ]] || ! G_WHIP_MENU 'Please select the drive you wish to save as an image:'; then

Exit_On_Fail

fi
FP_SOURCE='/root/dietpi-imager_tmp.img'
dd if=$G_WHIP_RETURNED_VALUE of=$FP_SOURCE bs=4K status=progress || Exit_On_Fail

elif [[ $G_WHIP_RETURNED_VALUE == 'Image' ]]; then

/DietPi/dietpi/dietpi-explorer 1 /root
local fp_selected='/tmp/.dietpi-explorer_selected_location'
[[ -f $fp_selected ]] || Exit_On_Fail
FP_SOURCE=$(<$fp_selected)
rm $fp_selected
if [[ ! -f $FP_SOURCE ]]; then

G_DIETPI-NOTIFY 1 "Source image file ($FP_SOURCE) does not exist, aborting..."
Exit_On_Fail

fi

fi

# Attach .img file to loop device
modprobe loop || Exit_On_Fail
FP_LOOPBACK=$(losetup -f)
losetup $FP_LOOPBACK "$FP_SOURCE" || Exit_On_Fail
partprobe $FP_LOOPBACK || Exit_On_Fail

# Detect partitions and list for selection
G_WHIP_MENU_ARRAY=($(lsblk -npo NAME,SIZE ${FP_LOOPBACK}?*))
G_WHIP_MENU "Please select the root partition of $FP_LOOPBACK" || Exit_On_Fail
ROOT_PARTITION_INDEX=${G_WHIP_RETURNED_VALUE: -1}

G_WHIP_DEFAULT_ITEM='DietPi_<device>-<arch>-<distro>'
G_WHIP_INPUTBOX "Please enter the new/output filename for $FP_SOURCE\n - DietPi_<device>-<arch>-<distro>\n - EG: DietPi_RPi-ARMv6-Stretch" || Exit_On_Fail
OUTPUT_IMG_NAME=$G_WHIP_RETURNED_VALUE

G_WHIP_DEFAULT_ITEM=$DIETPI_VERSION
G_WHIP_INPUTBOX 'Please enter the DietPi version for this image:' || Exit_On_Fail
DIETPI_VERSION=$G_WHIP_RETURNED_VALUE

}

Main(){

Menu_Main

# Install required packages
G_AG_CHECK_INSTALL_PREREQ gdisk dosfstools parted zerofree p7zip

# Auto detect GPT partition table, failsafe detection of MBR to debug possibly other wording/partition table types
if [[ $(parted $FP_LOOPBACK print) == *'Partition Table: msdos'* ]]; then

GPT=0

elif [[ $(parted $FP_LOOPBACK print) == *'Partition Table: gpt'* ]]; then

GPT=1

else

G_DIETPI-NOTIFY 1 "Unknown partition table type ($(parted $FP_LOOPBACK print | mawk '/^Partition Table:/ {print $3;exit}')), aborting..."
Exit_On_Fail

fi

# GPT images (RockPro64) after reading the image AND again after shrinking
# To fix:
# - GPT PMBR size mismatch (4458495 != 15523839) will be corrected by w(rite).
# - 15523806
# RUN
# - gdisk "$IMAGE_FP/$IMAGE_NAME"
# w | y
(( $GPT )) && echo -e 'w\ny\nq\n' | gdisk $FP_LOOPBACK # Needs testing for automation...

# root partition dev
FP_ROOT_DEV="${FP_LOOPBACK}p${ROOT_PARTITION_INDEX}"

# Fsck
e2fsck -f $FP_ROOT_DEV

# Remount image for any required edits.
fp_mnt='loopback_rootfs'
mkdir -p /mnt/$fp_mnt
if G_ERROR_HANDLER_INFO_ONLY=1 G_RUN_CMD mount $FP_ROOT_DEV /mnt/$fp_mnt; then

G_WHIP_MSG "Image mounted for file editing, make changes if required: $FP_ROOT_DEV > /mnt/$fp_mnt\n\nPress 'Ok' when you are finished."
sync
G_RUN_CMD umount /mnt/$fp_mnt
partprobe $FP_LOOPBACK # Probably not required as no partition changes, regardless, no harm.

fi

# Fsck
e2fsck -f $FP_ROOT_DEV

# Shrink file system to minimum
# - Run multiple times until no change is done any more
local out
FS_SIZE=0
while :
do

resize2fs -M $FP_ROOT_DEV 2>&1 | tee resize2fs_out
if out=$(grep -im1 'nothing to do!' resize2fs_out); then

# Re-add 4 MiB to be failsafe, was required on Raspbian Buster for successful boot
FS_SIZE=$(mawk '{print $5 + 1024}' <<< $out) # 4k blocks
rm resize2fs_out
resize2fs $FP_ROOT_DEV $FS_SIZE
G_DIETPI-NOTIFY 2 "Reduced RootFS size to $(( $FS_SIZE / 256 + 1 )) MiB"
FS_SIZE=$(( $FS_SIZE * 8 )) # 4k blocks => 512 byte sectors
break

elif out=$(grep -im1 'no such file or directory' resize2fs_out); then

G_DIETPI-NOTIFY 1 'Partition not found'
Exit_On_Fail

fi

done

# Estimate minimum end sector
PART_START=$(fdisk -l -o Start $FP_LOOPBACK | tail -1) # 512 byte sectors
PART_END=$(( $PART_START + $FS_SIZE ))

G_DIETPI-NOTIFY 2 "Shrinking root partition to: $(( $FS_SIZE / 2048 + 1 )) MiB"
parted $FP_LOOPBACK unit s resizepart $ROOT_PARTITION_INDEX $PART_END yes
partprobe $FP_LOOPBACK
sync

# Override free space with zeros to purge removed data and allow further image/archive size reduction
zerofree -v $FP_ROOT_DEV

# GPT images (RockPro64) after reading the image AND again after shrinking
# To fix:
# - GPT PMBR size mismatch (4458495 != 15523839) will be corrected by w(rite).
# - 15523806
# RUN
# - gdisk "$IMAGE_FP/$IMAGE_NAME"
# w | y
(( $GPT )) && echo -e 'w\ny\nq\n' | gdisk $FP_LOOPBACK

# Estimate used size
PART_SIZE=$(( ( $(fdisk -l -o End $FP_LOOPBACK | tail -1) + 1 ) * 512 )) # 512 byte sectors => Byte
IMAGE_SIZE=$(( $PART_SIZE + ( 512 * 256 ) )) # 64 byte for secondary GPT + safety net

# Create final image in /root
cd /root

# Truncate image file to used size
truncate --size=$IMAGE_SIZE "$FP_SOURCE"

# Loopback finished, clear loop
partprobe $FP_LOOPBACK
sync
Delete_Loopback

# Add version number to output file name
OUTPUT_7Z_NAME="$OUTPUT_IMG_NAME.7z"
OUTPUT_IMG_NAME="${OUTPUT_IMG_NAME//DietPi_/DietPi_${DIETPI_VERSION}_}.img"

# Move new img to /root
mv $FP_SOURCE $OUTPUT_IMG_NAME # TODO: if not same already location/file...

# Generate hashes: MD5, SHA1, SHA256
G_DIETPI-NOTIFY 2 'Generating hash.txt, please wait...'
cat << _EOF_ > hash.txt
FILE: $OUTPUT_IMG_NAME
DATE: $(date)
MD5: $(md5sum $OUTPUT_IMG_NAME | mawk '{print $1}')
SHA1: $(sha1sum $OUTPUT_IMG_NAME | mawk '{print $1}')
SHA256: $(sha256sum $OUTPUT_IMG_NAME | mawk '{print $1}')
_EOF_

# Download current README
wget https://raw.githubusercontent.com/MichaIng/DietPi/master/README.md -O README.md || Exit_On_Fail

# Generate 7z archive
# NB: LZMA2 ultra compression method requires 2G RAM
[[ -f $OUTPUT_7Z_NAME ]] && rm $OUTPUT_7Z_NAME
if 7zr a -m0=lzma2 -mx=9 $OUTPUT_7Z_NAME $OUTPUT_IMG_NAME hash.txt README.md; then

rm hash.txt README.md
G_WHIP_MSG "[INFO] /root/$OUTPUT_7Z_NAME created"

fi

}

#/////////////////////////////////////////////////////////////////////////////////////
# Main
#/////////////////////////////////////////////////////////////////////////////////////
Main
#-----------------------------------------------------------------------------------
exit
#-----------------------------------------------------------------------------------
}
18 changes: 15 additions & 3 deletions .meta/dietpi-survey_report
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
# NB: PLEASE ENSURE HW_MODEL INDEX ENTRIES MATCH : PREP, dietpi-obtain_hw_model, dietpi-survey_results,
# NBB: DO NOT REORDER INDEX's. These are now fixed and will never change (due to survey results etc)
aHW_NAME=()
aHW_NAME[0]='Raspberry Pi 1'
aHW_NAME[1]='Raspberry Pi 1/Zero'
aHW_NAME[0]='Raspberry Pi 1 256M'
aHW_NAME[1]='Raspberry Pi 1/Zero 512M'
aHW_NAME[2]='Raspberry Pi 2'
aHW_NAME[3]='Raspberry Pi 3/3+'
aHW_NAME[4]='Raspberry Pi 4'
aHW_NAME[10]='Odroid C1'
aHW_NAME[11]='Odroid XU3/XU4/HC1/HC2'
aHW_NAME[12]='Odroid C2'
Expand Down Expand Up @@ -53,6 +54,7 @@
aHW_NAME[69]='Firefly RK3399'
aHW_NAME[70]='Sparky SBC'
aHW_NAME[71]='Beagle Bone Black'
aHW_NAME[72]='ROCK Pi 4'

# - Core Benchmarks
aBENCH_CPU_INDEX=()
Expand Down Expand Up @@ -404,14 +406,24 @@
aSOFTWARE_NAME6_24[$i]=${aSOFTWARE_NAME6_23[$i]}
aSOFTWARE_NAME6_25[$i]=${aSOFTWARE_NAME6_24[$i]}

done
aSOFTWARE_NAME6_25[176]='Mycroft AI'

# - v6.26
aSOFTWARE_NAME6_26=()
for i in ${!aSOFTWARE_NAME6_25[@]}
do

aSOFTWARE_NAME6_26[$i]=${aSOFTWARE_NAME6_25[$i]}

done

Main(){

# Copy files to RAM to speed up grep
#mkdir -p /tmp/dietpi-survey_report
#cp /home/dietpi-survey/survey/*.txt /tmp/dietpi-survey_report/ # /etc/cron.minutely/dietpi-survey_report: line 310: /bin/cp: Argument list too long
[[ -e /tmp/dietpi-survey_report ]] && rm -R /tmp/dietpi-survey_report
[[ -e '/tmp/dietpi-survey_report' ]] && rm -R /tmp/dietpi-survey_report
cp -R /home/dietpi-survey/survey /tmp/dietpi-survey_report

cd /tmp/dietpi-survey_report
Expand Down
Loading

0 comments on commit 6c6dd50

Please sign in to comment.