Update test_status_update.sh
This commit is contained in:
@@ -1,49 +1,37 @@
|
|||||||
#!/bin/ash
|
#!/bin/ash
|
||||||
|
|
||||||
# Define the path to the status file
|
# Function to update the status file with a properly formatted entry
|
||||||
STATUS_FILE="/usr/lib/opkg/status"
|
add_to_status_file() {
|
||||||
|
local package_name="$1"
|
||||||
|
local version="$2"
|
||||||
|
local depends="$3"
|
||||||
|
local arch="$4"
|
||||||
|
local installed_time="$5"
|
||||||
|
|
||||||
# Define the control files for bundled packages
|
# Status file location
|
||||||
CONTROL_FILES="/usr/lib/opkg/info/libinotifytools.control /usr/lib/opkg/info/inotifywait.control"
|
local status_file="/usr/lib/opkg/status"
|
||||||
|
|
||||||
# Function to update the status file for a given control file
|
# Check if the package already exists and remove the old entry
|
||||||
update_status_file() {
|
if grep -q "Package: $package_name" "$status_file"; then
|
||||||
local control_file="$1"
|
echo "Removing old entry for $package_name"
|
||||||
local bundled_package_name=$(basename "$control_file" .control)
|
sed -i "/Package: $package_name/,/^$/d" "$status_file"
|
||||||
|
|
||||||
if [ ! -f "$control_file" ]; then
|
|
||||||
echo "Error: Control file not found for $bundled_package_name at $control_file"
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Append a newline and then add the control file contents to the status file
|
# Append the new formatted entry
|
||||||
echo "" >> "$STATUS_FILE"
|
echo "Adding new entry for $package_name to $status_file"
|
||||||
echo "Adding entry for $bundled_package_name to $STATUS_FILE"
|
cat << EOF >> "$status_file"
|
||||||
|
Package: $package_name
|
||||||
{
|
Version: $version
|
||||||
# Read the control file contents
|
Depends: $depends
|
||||||
cat "$control_file"
|
Status: install user installed
|
||||||
|
Architecture: $arch
|
||||||
# Add a 'Status' line indicating the package is 'user installed'
|
Installed-Time: $installed_time
|
||||||
echo "Status: install user installed"
|
|
||||||
|
|
||||||
# Add the architecture (modify this as per your system's architecture if needed)
|
EOF
|
||||||
echo "Architecture: aarch64_cortex-a53"
|
|
||||||
|
|
||||||
# Timestamp for when the package was installed
|
|
||||||
echo "Installed-Time: $(date +%s)"
|
|
||||||
} >> "$STATUS_FILE"
|
|
||||||
|
|
||||||
echo "Successfully added $bundled_package_name to $STATUS_FILE"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Iterate through each control file and update the status file
|
# Example usage: adding `libinotifytools` and `inotifywait` with dummy values
|
||||||
for control_file in $CONTROL_FILES; do
|
add_to_status_file "libinotifytools" "3.20.11.0-1" "libc" "aarch64_cortex-a53" "315965672"
|
||||||
update_status_file "$control_file"
|
add_to_status_file "inotifywait" "3.20.11.0-1" "libc, libinotifytools" "aarch64_cortex-a53" "315965672"
|
||||||
done
|
|
||||||
|
|
||||||
# Output the status file content for verification
|
echo "Status file updated!"
|
||||||
echo "Contents of $STATUS_FILE:"
|
|
||||||
grep -A 5 -E "Package: (libinotifytools|inotifywait)" "$STATUS_FILE"
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|||||||
Reference in New Issue
Block a user