Add __install_update, __install_ports

This commit is contained in:
0x1eef 2023-05-28 23:53:43 -03:00
parent 4b67365b54
commit 03e42c185e

View file

@ -1,29 +1,13 @@
#!/bin/sh
__changed_files() {
rev=$1
echo $(
git diff --name-only --diff-filter=RAM "$rev"..HEAD | \
cut -d / -f1 -f2 | \
uniq
)
}
__removed_files() {
rev=$1
echo $(git diff --name-only --diff-filter=D "$rev"..HEAD)
}
install() {
ports_dir=$1
portzap_dir=$2
__install_update() {
portzap_file=$1
ports_dir=$2
libexec_dir=$3
portzap_file=$4
cd "$portzap_dir" || exit 1
if [ -e "$portzap_file" ]; then
rev=$(cat "$portzap_file")
ch_files=$(eval __changed_files "$rev")
rm_files=$(eval __removed_files "$rev")
rm_files=$(git diff --name-only --diff-filter=D "$rev"..HEAD)
ch_files=$(git diff --name-only --diff-filter=RAM "$rev"..HEAD | \
cut -d / -f1 -f2 | uniq)
for file in $rm_files; do
echo RM "$ports_dir/$file"
rm "$ports_dir/$file"
@ -37,7 +21,12 @@ install() {
"$libexec_dir/install-directory" "$ports_dir" "$libexec_dir" "$dir"
fi
done
else
}
__install_ports() {
ports_dir=$1
libexec_dir=$2
find -s . -maxdepth 1 -type f \
\( -not -name ".gitignore" \) \
\( -not -name ".arcconfig" \) \
@ -47,6 +36,18 @@ install() {
\( -not -name ".git" \) \
\( -not -name ".hooks" \) \
-exec "$libexec_dir/install-directory" "$ports_dir" "$libexec_dir" {} +
}
install() {
ports_dir=$1
portzap_dir=$2
libexec_dir=$3
portzap_file=$4
cd "$portzap_dir" || exit 1
if [ -e "$portzap_file" ]; then
__install_update "$portzap_file" "$ports_dir" "$libexec_dir"
else
__install_ports "$portzap_dir" "$libexec_dir"
fi
git rev-parse HEAD > "$portzap_file"
}