support pidfd_getfd
[valgrind.git] / solaris / build_solaris_package
blob2a1a62b7a38db37fec424dd9f181fc13df652e73
1 #!/usr/bin/ksh
3 # Builds a Solaris IPS package called "valgrind" from the source
4 # directory. The Valgrind revision is taken from that
5 # source directory and written to solaris/valgrind.p5m IPS manifest.
7 # Requires the following packages to be installed on Solaris 11:
8 # - data/xml-common (install first before any docbook ones!)
9 # - data/docbook/docbook-style-xsl
10 # - data/docbook/docbook-dtds
11 # - developer/build/autoconf
12 # - developer/build/automake-111
13 # - developer/debug/gdb
14 # - developer/gnu-binutils
15 # - developer/versioning/mercurial
16 # - system/header
17 # - and the latest developer/gcc package.
19 # Requires a pre-established IPS repository.
20 # For example to create a file-based repository, do:
21 # - pkgrepo create $repo_uri
22 # - pkgrepo set -s $repo_uri publisher/prefix=valgrind
25 GITREPO=https://sourceware.org/git/valgrind.git/
26 TMPDIR=/var/tmp/valgrind-build
27 SRCDIR=$TMPDIR/sources
28 INSTALLDIR=$TMPDIR/install
29 IPS_MANIFEST=solaris/valgrind.p5m
31 usage() {
32 echo "Usage:"
33 echo "build_solaris_package -p source_dir -s repo_uri [-r lint_repo_uri]"
34 echo "\t-p source_dir contains working copy of the Valgrind sources"
35 echo "\t-s repo_uri publishes to the repository located at the given URI"
36 echo "\t or file system path"
37 echo "\t-r lint_repo_uri location of lint reference repository"
40 fail() {
41 msg=$1
43 echo "\n$msg"
44 echo "Additional information could be found in directory $TMPDIR."
45 exit 1
48 remove_dirs() {
49 rm -rf $TMPDIR
52 create_dirs() {
53 mkdir -p $TMPDIR
54 (( $? != 0 )) && fail "Failed to create directory $TMPDIR."
56 mkdir -p $INSTALLDIR
57 (( $? != 0 )) && fail "Failed to create directory $INSTALLDIR."
60 export_sources() {
61 old_dir=$( pwd )
62 git_commit=$( cd $source_directory; git rev-parse HEAD )
63 echo "Valgrind git commit: $git_commit."
65 printf "Exporting sources... "
66 git clone ${GITREPO} ${SRCDIR} 2> $TMPDIR/git-clone-valgrind.log.stderr
67 (( $? != 0 )) && fail "Failed to clone git repo from $source_directory."
68 cd ${SRCDIR}
69 git checkout ${git_commit} 2> $TMPDIR/git-checkout-valgrind.log.stderr
70 (( $? != 0 )) && fail "Failed to checkout git commit ${git_commit}."
71 cd "$old_dir"
72 printf "done.\n"
75 modify_ips_manifest() {
76 current_date=$( date '+%Y%m%d' )
77 [[ -z $current_date ]] && fail "Failed to determine current date."
79 sed -i -e "s/VVVVV/${current_date}/" $SRCDIR/$IPS_MANIFEST
82 run_autogen() {
83 printf "Creating autotools support files... "
84 ./autogen.sh > $TMPDIR/autogen.log.stdout 2> $TMPDIR/autogen.log.stderr
85 (( $? != 0 )) && fail "Failed to generate autotools support files."
86 printf "done.\n"
89 run_configure() {
90 printf "Running configure... "
91 ./configure CC='gcc -m64' CXX='g++ -m64' --prefix=/usr > $TMPDIR/configure.log
92 (( $? != 0 )) && fail "Failed to run configure."
93 printf "done.\n"
96 run_make_docs() {
97 printf "Making docs... "
98 make --directory=docs html-docs > $TMPDIR/make-docs.log.stdout 2> $TMPDIR/make-docs.log.stderr
99 (( $? != 0 )) && fail "Failed to make html-docs."
100 printf "done.\n"
103 run_make_man_pages() {
104 printf "Making man pages... "
105 make --directory=docs man-pages > $TMPDIR/make-man-pages.log.stdout 2> $TMPDIR/make-man-pages.log.stderr
106 (( $? != 0 )) && fail "Failed to make man-pages."
107 printf "done.\n"
110 run_make() {
111 printf "Running make... "
112 make --quiet > $TMPDIR/make.log
113 (( $? != 0 )) && fail "Failed to run make."
114 printf "done.\n"
117 run_make_install() {
118 printf "Running 'make install'... "
119 make --quiet install DESTDIR=$INSTALLDIR > $TMPDIR/make-install.log
120 (( $? != 0 )) && fail "Failed to run 'make install'."
122 cp AUTHORS COPYING* NEWS NEWS.old README* $INSTALLDIR/usr/share/doc/valgrind
123 (( $? != 0 )) && fail "Failed to copy additional files to $INSTALLDIR."
125 printf "done.\n"
128 run_pkglint() {
129 printf "Running pkglint... "
130 pkglint -c $TMPDIR/lint-cache -r $lint_repo_uri $SRCDIR/$IPS_MANIFEST > $TMPDIR/pkglint.log
131 (( $? != 0 )) && fail "pkglint failed."
132 printf "done.\n"
135 publish_package() {
136 printf "Publishing package... "
137 pkgsend publish -s $repo_uri -d $INSTALLDIR $SRCDIR/solaris/valgrind.p5m > $TMPDIR/pkgsend.log
138 (( $? != 0 )) && fail "Failed to publish the package."
139 printf "done.\n"
142 while getopts "p:r:s:" args; do
143 case $args in
145 source_directory=$OPTARG
148 lint_repo_uri=$OPTARG
151 repo_uri=$OPTARG
154 usage
155 exit 1
157 esac
158 done
160 if [[ -z $source_directory ]]; then
161 echo "No source directory specified.\n"
162 usage
163 exit 1
166 if [[ -z $repo_uri ]]; then
167 echo "No repo_uri specified.\n"
168 usage
169 exit 1
172 # Determine the lint repo_uri to use from the current 'solaris' one
173 # if not specified explicitly.
174 if [[ -z $lint_repo_uri ]]; then
175 publisher=$( pkg publisher | grep solaris | tr -s ' ' )
176 if [[ $publisher == *sticky* ]]; then
177 lint_repo_uri=$( echo "$publisher" | cut -d ' ' -f 6 )
178 else
179 lint_repo_uri=$( echo "$publisher" | cut -d ' ' -f 5 )
181 [[ -z $lint_repo_uri ]] && fail "Failed to determine solaris IPS publisher."
182 echo "lint_repo_uri determined as $lint_repo_uri"
186 remove_dirs
187 create_dirs
188 cd $TMPDIR
190 export_sources
191 modify_ips_manifest
192 cd $SRCDIR
193 run_autogen
194 run_configure
195 run_make_docs
196 run_make_man_pages
197 run_make
198 run_make_install
200 cd $TMPDIR
201 run_pkglint
202 publish_package
204 remove_dirs
205 return 0