76 lines
No EOL
1.6 KiB
Markdown
76 lines
No EOL
1.6 KiB
Markdown
Scripts
|
|
|
|
- for downloading packages from arch archive
|
|
```sh
|
|
#!/bin/bash
|
|
|
|
# Check if the input file is provided
|
|
if [ -z "$1" ]; then
|
|
echo "Usage: $0 <file_with_package_names>"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if the file exists
|
|
if [ ! -f "$1" ]; then
|
|
echo "File '$1' not found!"
|
|
exit 1
|
|
fi
|
|
|
|
# Read the file line by line
|
|
while IFS= read -r package; do
|
|
# If the line is not empty
|
|
if [ -n "$package" ]; then
|
|
# Construct the URL based on the pattern
|
|
url="https://archive.archlinux.org/packages/${package:0:1}/$package"
|
|
|
|
# Output the URL
|
|
echo "Downloading: $url"
|
|
|
|
# Download the package using wget
|
|
wget "$url"
|
|
fi
|
|
done < "$1"
|
|
|
|
```
|
|
(this one is not working)
|
|
Running it:
|
|
`bash download_packages.sh packages.txt`
|
|
Then to install these all
|
|
`sudo pacman -U $(< packages.txt)`
|
|
or
|
|
`sudo pacman -U *.zst`
|
|
|
|
new one
|
|
```sh
|
|
#!/bin/bash
|
|
|
|
# Check if the input file is provided
|
|
if [ -z "$1" ]; then
|
|
echo "Usage: $0 <file_with_package_names>"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if the file exists
|
|
if [ ! -f "$1" ]; then
|
|
echo "File '$1' not found!"
|
|
exit 1
|
|
fi
|
|
|
|
# Read the file line by line
|
|
while IFS= read -r package; do
|
|
# If the line is not empty
|
|
if [ -n "$package" ]; then
|
|
# Extract the package name (e.g., "binaryen" from "binaryen-1:120-1-x86_64.pkg.tar.zst")
|
|
package_name=$(echo "$package" | cut -d '-' -f 1)
|
|
|
|
# Construct the URL based on the pattern
|
|
url="https://archive.archlinux.org/packages/${package_name:0:1}/$package_name/$package"
|
|
|
|
# Output the URL
|
|
echo "Downloading: $url"
|
|
|
|
# Download the package using wget
|
|
wget "$url"
|
|
fi
|
|
done < "$1"
|
|
``` |