mirror of
https://codeberg.org/Toasterson/ips.git
synced 2026-04-10 05:10:42 +00:00
- Update `FileBackend` to store files in a multi-level directory structure (`xx/yy/hash`) based on hash prefixes. - Adjust method signatures and logic across `FileBackend`, `pkg6dev`, and `pkg6repo` to support mutable repository operations. - Add test cases and scripts (`test_file_structure.rs`, `test_repo_operations.sh`) to validate the new file structure. - Refactor catalog manager to use `RefCell` for interior mutability to enable lazy initialization. - Clean up redundant and dead code, enhance comments, and replace outdated logic for file handling and metadata operations.
77 lines
No EOL
2 KiB
Bash
Executable file
77 lines
No EOL
2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Test script to verify that repository operations work with the new directory structure
|
|
|
|
# Create a temporary directory for the test
|
|
TEST_DIR="/tmp/pkg6_repo_operations_test"
|
|
rm -rf "$TEST_DIR"
|
|
mkdir -p "$TEST_DIR"
|
|
|
|
echo "Created test directory: $TEST_DIR"
|
|
|
|
# Create a repository
|
|
echo "Creating repository..."
|
|
cargo run --bin pkg6repo -- create "$TEST_DIR/repo"
|
|
|
|
# Add a publisher
|
|
echo "Adding publisher..."
|
|
cargo run --bin pkg6repo -- add-publisher -r "$TEST_DIR/repo" test
|
|
|
|
# Create a test file
|
|
echo "Creating test file..."
|
|
echo "This is a test file" > "$TEST_DIR/test_file.txt"
|
|
|
|
# Create a simple manifest
|
|
echo "Creating manifest..."
|
|
cat > "$TEST_DIR/test.p5m" << EOF
|
|
{
|
|
"attributes": [
|
|
{
|
|
"key": "pkg.fmri",
|
|
"values": [
|
|
"pkg://test/example@1.0,5.11-0:20250727T123000Z"
|
|
],
|
|
"properties": {}
|
|
}
|
|
],
|
|
"files": [
|
|
{
|
|
"path": "usr/share/doc/example/test.txt",
|
|
"mode": "0644",
|
|
"owner": "root",
|
|
"group": "root"
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
# Create a prototype directory
|
|
echo "Creating prototype directory..."
|
|
mkdir -p "$TEST_DIR/prototype/usr/share/doc/example"
|
|
cp "$TEST_DIR/test_file.txt" "$TEST_DIR/prototype/usr/share/doc/example/test.txt"
|
|
|
|
# Publish the package
|
|
echo "Publishing package..."
|
|
cargo run --bin pkg6repo -- publish -r "$TEST_DIR/repo" -p test -m "$TEST_DIR/test.p5m" "$TEST_DIR/prototype"
|
|
|
|
# Check if the file was stored in the correct directory structure
|
|
echo "Checking file structure..."
|
|
find "$TEST_DIR/repo/file" -type f | while read -r file; do
|
|
hash=$(basename "$file")
|
|
first_two=${hash:0:2}
|
|
next_two=${hash:2:2}
|
|
expected_path="$TEST_DIR/repo/file/$first_two/$next_two/$hash"
|
|
|
|
if [ "$file" = "$expected_path" ]; then
|
|
echo "SUCCESS: File was stored at the correct path: $file"
|
|
else
|
|
echo "ERROR: File was stored at an unexpected path: $file"
|
|
echo "Expected: $expected_path"
|
|
fi
|
|
done
|
|
|
|
# Clean up
|
|
echo "Cleaning up..."
|
|
rm -rf "$TEST_DIR"
|
|
|
|
echo "Test completed." |