-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgather-package-data.sh
executable file
·65 lines (56 loc) · 1.48 KB
/
gather-package-data.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /bin/bash
# This script gathers files from install users that *should*
# go into the repository.
# It collects those files, copies them into the local `usr`
# path.
# Note: the script overrides files in `usr`, make sure you
# don't have any unstaged changes.
# Usage: run after you changed something in the package user
# home folder (e.g. added a script to the personal `bin`
# folder, or changed the `.url` file).
# Afterwards look at pending changes in `usr` with git.
gather_file() {
local pkg="$1"
local name="$2"
local src="/usr/src/$pkg/$name"
if ! [ -e "$src" ] ; then
return 0
fi
local dir="usr/src/$pkg"
local file="usr/src/$pkg/$name"
mkdir -p "$dir" || exit $?
if [ -e "$file" ] ; then
if cmp "$src" "$file" >/dev/null ; then
return 0
fi
fi
cp "$src" "$file" || exit $?
echo "Added '$name' for $pkg."
return 0
}
gather_from_dir() {
local pkg="$1"
local dir="$2"
local src="/usr/src/$pkg/$dir"
if ! [ -e "$src" ] ; then
return 0
fi
find "$src" -maxdepth 1 -mindepth 1 -type f -printf '%f\n' | \
while read file ; do
case "$file" in
'*~')
continue
;;
esac
gather_file "$pkg" "$dir/$file"
done
}
find /usr/src -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | \
while read pkg ; do
gather_file "$pkg" ".url" || exit $?
gather_file "$pkg" ".tpkgs.conf" || exit $?
gather_file "$pkg" "notes" || exit $?
gather_from_dir "$pkg" "bin" || exit $?
done
# Special, should be Incorporated into a patch, maybe.
gather_file "lua" "lua.pc" || exit $?