Ticket #43431: bacula.diff

File bacula.diff, 10.2 KB (added by ryandesign (Ryan Carsten Schmidt), 6 years ago)

example of proposed general purpose mysql/postgresql/sqlite variant generating code

  • sysutils/bacula/Portfile

    diff --git a/sysutils/bacula/Portfile b/sysutils/bacula/Portfile
    index 4105992446..ce39ed0d4d 100644
    a b startupitem.stop "\[ -r \${PID} \] && /bin/kill \$(cat \${PID})" 
    7373notes "To use the Bacula FD client, you'll need to configure \"${prefix}/etc/bacula/bacula-fd.conf\"."
    7474notes-append "To use bconsole, you'll need to configure \"${prefix}/etc/bacula/bconsole.conf\"."
    7575
    76 variant client_only conflicts mysql51 mysql55 postgresql83 postgresql84 sqlite3 description "Install bacula client (bacula-fd) only" {
     76set db_ports {mariadb mariadb-10.0 mariadb-10.1 mariadb-10.2 mysql51 mysql55 mysql56 mysql57 percona postgresql83 postgresql84 postgresql90 postgresql91 postgresql92 postgresql93 postgresql94 postgresql95 postgresql96 postgresql10 postgresql11 sqlite3}
     77set db_variants [string map {- {}} ${db_ports}]
     78proc db_variant_isset {} {
     79    global db_variants
     80    foreach db_variant ${db_variants} {
     81        if [variant_isset ${db_variant}] {
     82            return yes
     83        }
     84    }
     85    return no
     86}
     87foreach db_port ${db_ports} {
     88    set db_type [regsub -nocase {[^a-z].*$} ${db_port} {}]
     89    set db_index [lsearch -exact ${db_ports} ${db_port}]
     90    set db_variant [lindex ${db_variants} ${db_index}]
     91    set db_conflicts [lreplace ${db_variants} ${db_index} ${db_index}]
     92    variant ${db_variant} description "Install bacula client and server with ${db_port} backend" conflicts client_only {*}${db_conflicts} "
     93        depends_lib-append      port:${db_port}
     94
     95        configure.args-append --enable-batch-insert
     96
     97        switch ${db_type} {
     98            mariadb -
     99            mysql -
     100            percona {
     101                configure.args-replace      --without-mysql --with-mysql=${prefix}/include/${db_port}/mysql
     102                configure.cppflags-append   -I${prefix}/include/${db_port}/mysql
     103
     104                patchfiles-append           patch-configure-mysql.diff
     105
     106                post-patch {
     107                    reinplace \"s|@@PREFIX@@|${prefix}|g\" ${worksrcpath}/configure
     108                }
     109
     110                notes-append {
     111                    To use the Bacula Director, you'll need to perform the following steps:
     112                      1. create user \"bacula\" on a mysql database
     113                      2. execute \"${prefix}/etc/bacula/create_bacula_database -h <mysql_server> -u <db_admin_user> -p\"
     114                      3. execute \"${prefix}/etc/bacula/make_bacula_tables -h <mysql_server> -u <db_admin_user> -p\"
     115                      4. execute \"${prefix}/etc/bacula/grant_bacula_privileges -h <mysql_server> -u <db_admin_user> -p\"
     116                      5. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
     117                }
     118            }
     119            postgresql {
     120                configure.args-replace      --without-postgresql --with-postgresql
     121
     122                configure.env-append        PATH=${prefix}/lib/${db_port}/bin:$env(PATH)
     123
     124                patchfiles-append           patch-create_postgresql_database.diff
     125
     126                notes-append {
     127                    To use the Bacula Director, you'll need to perform the following steps:
     128                      1. create user \"bacula\" on a PostgreSQL database
     129                      2. execute \"${prefix}/etc/bacula/create_bacula_database -h <postgresql-server> -U <db_admin_user>\"
     130                      3. execute \"${prefix}/etc/bacula/make_bacula_tables -h <postgresql-server> -U <db_admin_user>\"
     131                      4. execute \"${prefix}/etc/bacula/grant_bacula_privileges -h <postgresql-server> -U <db_admin_user> -p\"
     132                      5. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
     133                }
     134            }
     135            sqlite {
     136                configure.args-replace      --without-sqlite3 --with-sqlite3=${prefix}
     137
     138                notes-append {
     139                    To use the Bacula Director, you'll need to perform the following steps:
     140                      1. execute \"${prefix}/etc/bacula/create_bacula_database\"
     141                      2. execute \"${prefix}/etc/bacula/make_bacula_tables\"
     142                      3. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
     143                }
     144            }
     145        }
     146    "
     147}
     148
     149variant client_only conflicts {*}${db_variants} description "Install bacula client (bacula-fd) only" {
    77150    configure.args-append --enable-client-only
    78151}
    79152
    variant console_bat description "Install BAT console GUI application" { 
    98171    notes-append "To use the Bacula BAT GUI, you'll need to configure \"${prefix}/etc/bacula/bat.conf\"."
    99172}
    100173
    101 variant mysql51 conflicts client_only mysql55 postgresql83 postgresql84 sqlite3 description "Install bacula client and server with mysql 5.1 backend" {
    102     depends_lib-append    port:mysql51
    103     configure.args-append --with-mysql=${prefix}/include/mysql51/mysql
    104     configure.args-delete --without-mysql
    105     configure.args-append --enable-batch-insert
    106     configure.cppflags-append   -I${prefix}/include/mysql51/mysql
    107 
    108     patchfiles-append     patch-configure-mysql.diff
    109     post-patch {
    110                      reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/configure
    111     }
    112     notes-append "
    113        To use the Bacula Director, you'll need to perform the following steps:
    114          1. create user \"bacula\" on a mysql database
    115          2. execute \"${prefix}/etc/bacula/create_bacula_database -h <mysql_server> -u <db_admin_user> -p\"
    116          3. execute \"${prefix}/etc/bacula/make_bacula_tables -h <mysql_server> -u <db_admin_user> -p\"
    117          4. execute \"${prefix}/etc/bacula/grant_bacula_privileges -h <mysql_server> -u <db_admin_user> -p\"
    118          5. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
    119     "
    120 }
    121 
    122 variant mysql55 conflicts client_only mysql51 postgresql83 postgresql84 sqlite3 description "Install bacula client and server with mysql 5.5 backend" {
    123     depends_lib-append    port:mysql55
    124     configure.args-append --with-mysql=${prefix}/include/mysql55/mysql
    125     configure.args-delete --without-mysql
    126     configure.args-append --enable-batch-insert
    127     configure.cppflags-append   -I${prefix}/include/mysql55/mysql
    128 
    129     patchfiles-append     patch-configure-mysql.diff
    130     post-patch {
    131                      reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/configure
    132     }
    133     notes-append "
    134        To use the Bacula Director, you'll need to perform the following steps:
    135          1. create user \"bacula\" on a mysql database
    136          2. execute \"${prefix}/etc/bacula/create_bacula_database -h <mysql_server> -u <db_admin_user> -p\"
    137          3. execute \"${prefix}/etc/bacula/make_bacula_tables -h <mysql_server> -u <db_admin_user> -p\"
    138          4. execute \"${prefix}/etc/bacula/grant_bacula_privileges -h <mysql_server> -u <db_admin_user> -p\"
    139          5. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
    140     "
    141 }
    142 
    143 variant postgresql83 conflicts mysql51 mysql55 postgresql84 sqlite3 client_only description "Install bacula client and server with postgresql 8.3 backend" {
    144     depends_lib-append    port:postgresql83
    145     configure.args-append --with-postgresql
    146     configure.args-delete --without-postgresql
    147     configure.args-append --enable-batch-insert
    148     configure.env-append  PATH=${prefix}/lib/postgresql83/bin:$env(PATH)
    149 
    150     patchfiles-append     patch-create_postgresql_database.diff
    151 
    152     notes-append "
    153        To use the Bacula Director, you'll need to perform the following steps:
    154          1. create user \"bacula\" on a PostgreSQL database
    155          2. execute \"${prefix}/etc/bacula/create_bacula_database -h <postgresql-server> -U <db_admin_user>\"
    156          3. execute \"${prefix}/etc/bacula/make_bacula_tables -h <postgresql-server> -U <db_admin_user>\"
    157          4. execute \"${prefix}/etc/bacula/grant_bacula_privileges -h <postgresql-server> -U <db_admin_user> -p\"
    158          5. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
    159     "
    160 }
    161 
    162 variant postgresql84 conflicts mysql51 mysql55 postgresql83 sqlite3 client_only description "Install bacula client and server with postgresql 8.4 backend" {
    163     depends_lib-append    port:postgresql84
    164     configure.args-append --with-postgresql
    165     configure.args-delete --without-postgresql
    166     configure.args-append --enable-batch-insert
    167     configure.env-append  PATH=${prefix}/lib/postgresql84/bin:$env(PATH)
    168 
    169     patchfiles-append     patch-create_postgresql_database.diff
    170 
    171     notes-append "
    172        To use the Bacula Director, you'll need to perform the following steps:
    173          1. create user \"bacula\" on a PostgreSQL database
    174          2. execute \"${prefix}/etc/bacula/create_bacula_database -h <postgresql-server> -U <db_admin_user>\"
    175          3. execute \"${prefix}/etc/bacula/make_bacula_tables -h <postgresql-server> -U <db_admin_user>\"
    176          4. execute \"${prefix}/etc/bacula/grant_bacula_privileges -h <postgresql-server> -U <db_admin_user> -p\"
    177          5. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
    178     "
    179 }
    180 
    181 variant sqlite3 conflicts client_only mysql51 mysql55 postgresql83 postgresql84 description "Install bacula client and server with sqlite 3 backend" {
    182     depends_lib-append    port:sqlite3
    183     configure.args-append --with-sqlite3=${prefix}
    184     configure.args-delete --without-sqlite3
    185     configure.args-append --enable-batch-insert
    186     notes-append "
    187        To use the Bacula Director, you'll need to perform the following steps:
    188          1. execute \"${prefix}/etc/bacula/create_bacula_database\"
    189          2. execute \"${prefix}/etc/bacula/make_bacula_tables\"
    190          3. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
    191     "
    192 }
    193 
    194174default_variants +console_bat
    195175
    196 if {![variant_isset mysql51] && ![variant_isset mysql55] && ![variant_isset postgresql83] && ![variant_isset postgresql84] && ![variant_isset sqlite3]} {
     176if {![db_variant_isset]} {
    197177    default_variants-append +client_only
    198178} else {
    199179    # is a server installation