forked from Soviet-Linux/OUR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
122 lines (101 loc) · 3.08 KB
/
build.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
CCCP_ARGS="debug 3 verbose"
buildpkg() {
echo "Building " $1 "..."
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
# Path: build.sh
srcpath=$1
binpath=$(realpath $(dirname $(dirname $srcpath))/bin/$(basename $srcpath).tar.gz)
echo "Source path: " $srcpath
echo "Binary path: " $binpath
#check if binary exists
if [ -f $binpath ]; then
echo "Binary already exists"
# check if source is newer
if [ $srcpath -nt $binpath ]; then
echo "Source is newer than binary"
echo "Rebuilding..."
else
echo "Binary is newer than source"
echo "Skipping..."
return 0
fi
fi
# Execute cccp build
cccp $CCCP_ARGS create $srcpath $binpath
if [ $? -ne 0 ]; then
echo "Build failed"
fails=$((fails+1))
failedpkgs=$(echo $failedpkgs $srcpath)
echo $fails " packages failed"
echo "Failed packages: " $failedpkgs
exit 1
fi
return 0
}
cleanall() {
echo "Cleaning all packages..."
find . -name '*.tar.gz' | while read file; do rm $file; done
}
buildall() {
#check if we are runnning in a soviet system
cat /etc/os-release| head -n1 | grep 'Soviet Linux' > /dev/null
if [ $? -ne 0 ]; then
echo "This script is intended to be run on Soviet Linux"
read -r -p "Do you wan to launch the docker container ? [y/N] " res
res=${res,,} # tolower
if [[ "$res" =~ ^(yes|y)$ ]] ; then
#chekc if docker is installed
docker --version > /dev/null
if [ $? -ne 0 ]; then
echo "Docker is not installed"
exit 1
fi
docker run -v `pwd`:`pwd` -w `pwd` pkd667/sovietlinux bash build.sh buildall
exit $?
else
read -r -p "Do you wan to continue executing on current system ? [y/N] " res
res=${res,,} # tolower
if [[ "$res" =~ ^(yes|y)$ ]] ; then
echo "Continuing..."
else
echo "Aborting..."
exit 1
fi
fi
fi
echo "Building all packages..."
find . -name '*.ecmp' | while read file; do buildpkg $file; done
}
if [ "$1" == "clean" ]; then
cleanall
exit 0
elif [ "$1" == "buildall" ] || [ "$1" == "all" ] || [ "$1" == "" ]; then
buildall
exit 0
elif [ "$1" == "buildpkg" ] || [ "$1" == "build" ] || [ "$1" == "pkg" ] ; then
buildpkg $2
exit 0
elif [ "$1" == "help" ]; then
echo "Usage: build.sh [command] [package]"
echo
echo "Commands:"
echo
echo " buildpkg|build|pkg [package] - build a single package"
echo " --> The package argument is the path to the package's .ecmp file in the repository"
echo
echo " buildall|all - build all packages"
echo " --> If no command is specified, buildall is used"
echo
echo " clean - clean all packages"
echo
echo " help - show this help"
echo
exit 0
else
echo "Unknown command"
exit 1
fi