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