source: installer/pkg-generator/genpkg.sh

qndtest
Last change on this file was 2cce651a, checked in by ramon <ramongomez@…>, 6 years ago

#837: Integrar código de ticket:837 para generar paquete Deb.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@5719 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 4.2 KB
Line 
1#!/bin/bash
2#####################################################################
3####### This script downloads svn repo and generates a debian package
4####### Autor: Fredy <aluque@soleta.eu>      2018 Q1
5####### First attempt just launches the opengnsys_installer
6#####################################################################
7
8# Needs root priviledges
9if [ "$(whoami)" != 'root' ]; then
10        echo "ERROR: this program must run under root privileges!!"
11        exit 1
12fi
13
14VERSION="1.1"
15SVNURL=https://opengnsys.es/svn/branches/version$VERSION
16PKG_GEN_PATH=/root/debian-pkg
17#DESTDIR=$ROOTDIR/opt/opengnsys
18TMPDIR=/tmp/opengnsys_installer
19
20function help()
21{
22read -r -d '' HELP <<- EOM
23########################################################################
24#  This script creates debian ".deb" packages for the great            #
25#           Opengnsys Deployment Software                              #
26#  - Select which type of package you would like to generate           #
27#  - You will find your ".deb" file inside /root/debian-pkg folder     #
28#  - Send the ".deb" file to your destination machine and install it:  #
29#  - apt install ./opengnsys-*.deb   (use apt instead apt-get or dpkg) #
30#  The script has been tested on Ubuntu Xenial 16.04 LTS               #
31########################################################################
32EOM
33echo "$HELP"
34}
35
36function createControlFile()
37{
38cat > $ROOTDIR/DEBIAN/control << EOF
39Package: $PKG_NAME
40Priority: optional
41Section: misc
42Maintainer: info@opengnsys.es
43Architecture: all
44Version: $VERSION
45$DEPENDS
46Description: Opengnsys Deploy Generator
47Homepage: https://opengnsys.es
48EOF
49}
50
51function createFullPackage()
52{
53PKG_NAME="opengnsys-full"
54ROOTDIR=$PKG_GEN_PATH/$PKG_NAME
55mkdir -p $DESTDIR $TMPDIR $ROOTDIR
56svn export --force $SVNURL $TMPDIR
57mkdir -p $ROOTDIR/DEBIAN $ROOTDIR/tmp
58ln -s $TMPDIR/ $TMPDIR/opengnsys
59DEPENDS="Depends: subversion, apache2, php, php-ldap, libapache2-mod-php, isc-dhcp-server, bittorrent, tftp-hpa, tftpd-hpa, xinetd, build-essential, g++-multilib, libmysqlclient-dev, wget, curl, doxygen, graphviz, bittornado, ctorrent, samba, rsync, unzip, netpipes, debootstrap, schroot, squashfs-tools, btrfs-tools, procps, arp-scan, realpath, php-curl, gettext ,moreutils, jq, wakeonlan, mysql-server, php-mysql, udpcast"
60createControlFile
61# Copy installer to postinst
62cp $TMPDIR/installer/opengnsys_installer.sh $ROOTDIR/DEBIAN/postinst
63
64# Ejemplo de modificacion del postinst al vuelo
65# sed -i 's/wget --spider -q/wget --spider -q --no-check-certificate/g' $ROOTDIR/DEBIAN/postinst
66
67# deactivate svn function
68sed -i '/function svnExportCode/{N;s/$/\nreturn 0/}' $ROOTDIR/DEBIAN/postinst
69
70# copy svn repo structure inside .deb package
71cp -a $TMPDIR $ROOTDIR/tmp
72
73# Finally Generate package
74cd $PKG_GEN_PATH
75dpkg --build $PKG_NAME .
76}
77
78function createClientPackage()
79{
80PKG_NAME="opengnsys-client"
81ROOTDIR=$PKG_GEN_PATH/$PKG_NAME
82mkdir -p $TMPDIR/opengnsys/client/
83mkdir -p $ROOTDIR/tmp/client
84svn checkout $SVNURL/client $TMPDIR/opengnsys/client/
85mkdir -p $ROOTDIR/DEBIAN
86DEPENDS="Depends: debootstrap, subversion, schroot, squashfs-tools, syslinux, genisoimage, ipxe, qemu, lsof"
87createControlFile
88# Copy installer to postinst
89cp $TMPDIR/opengnsys/client/boot-tools/boottoolsgenerator.sh $ROOTDIR/DEBIAN/postinst
90# Modify installer
91sed -i 's/apt-get -y --force-yes install/#apt-get -y --force-yes install/g' $ROOTDIR/DEBIAN/postinst
92# Copy repo to package
93cp -a $TMPDIR $ROOTDIR/tmp
94# Generate package
95cd $PKG_GEN_PATH
96dpkg --build $PKG_NAME .
97}
98
99# Start the Menu
100echo "Main Menu"
101
102# Define the choices to present to the user.
103choices=( 'help' "Create full package" "Client package (testing)" 'exit')
104
105while [ "$menu" != 1 ]; do
106# Present the choices.
107# The user chooses by entering the *number* before the desired choice.
108        select choice in "${choices[@]}"; do
109
110                # Examine the choice.
111                case $choice in
112                help)
113                  echo "Generate Package Help"
114                  help
115
116                  ;;
117                "Create full package")
118                        echo "Creating new full package..."
119                        createFullPackage
120                        exit 0
121                  ;;
122                "Client package (testing)")
123                        echo "Creating Client package..."
124                        createClientPackage
125                        exit 0
126                  ;;             
127                exit)
128                  echo "Exiting. "
129                  exit 0
130                  ;;
131                *)
132                  echo "Wrong choice!"
133                  exit 1
134                esac
135                break
136
137        done
138done
139
140echo "End of the script"
141exit
142
143
144
Note: See TracBrowser for help on using the repository browser.