-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcopy_from_pkg.sh
executable file
·69 lines (56 loc) · 1.45 KB
/
copy_from_pkg.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
65
66
67
68
69
#!/bin/bash
# If you did changes in a package and want the changelog included:
# ./copy_from_package /path/to/kolibri-0.16~b1 -c
set -e
if
[ "$1" == "" ] ||
[ "$1" == "-h" ] ||
[ "$1" == "--help" ]
then
echo "Copies the debian/ contents of a package to this folder "
echo "where we maintain the debian/ source in Git."
echo "usage: ./copy_from_pkg [path-of-pkg]"
exit
fi
# Goto location of this script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
test_dir=$1
if [ "$2" == "-c" ]
then
also_changelog=1
else
also_changelog=0
fi
dest_dir=`realpath $DIR`
if ! [ -d $test_dir/debian ]
then
echo "No debian/ found in $test_dir"
exit 1
fi
test_dir=`realpath $test_dir`
echo "This will overwrite the contents of"
echo "$dest_dir"
echo "with the contents of"
echo "$test_dir"
echo ""
read -p "Are you sure? [y/N] " choice
case "$choice" in
y|Y )
git rm -rf --ignore-unmatch --cached $dest_dir/debian/*
git add $dest_dir/debian
# Copy everything except the assessment zip from the test pkg dir to this dir
cd $test_dir
debclean
# The below has to run with respect to relative paths, hence the cd and the cp --parents
cd $test_dir
find debian -mindepth 1 -not -name '*.zip' -exec cp -rp \{\} --parents $dest_dir \;
if [ $also_changelog -eq 0 ]
then
rm $dest_dir/debian/changelog
git reset -- $dest_dir/debian/changelog
git checkout $dest_dir/debian/changelog
fi
;;
n|N ) echo "no" ;;
* ) echo "Okay leaving then..." ;;
esac