Changeset 416 in ProjectBuilder for devel


Ignore:
Timestamp:
Apr 27, 2008, 12:05:30 AM (16 years ago)
Author:
Bruno Cornec
Message:

move the pb_env_init function to a separate module to allow pbinit usage

Location:
devel
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/lib/ProjectBuilder/Conf.pm

    r415 r416  
    5050
    5151=over 4
    52 
    53 =item B<pb_conf_init>
    54 
    55 This function initializes the configuration files analysis.
    56 Pass the configuration files to consider in order of importance (the most important first).
    57 
    58 =cut
    59 
    60 sub pb_conf_init {
    61 
    62 pb_log(2,"DEBUG: pb_conf_init with ".Dumper(@_)."\n");
    63 @pbconffiles = @_;
    64 }
    6552
    6653=item B<pb_conf_add>
  • devel/pb/bin/pb

    r415 r416  
    2525use ProjectBuilder::Distribution;
    2626use ProjectBuilder::CMS;
     27use ProjectBuilder::Env;
    2728use ProjectBuilder::Filter;
    2829
     
    16431644}
    16441645
    1645 sub pb_env_init {
    1646 
    1647 my $proj=shift || undef;
    1648 my $pbinit=shift || undef;
    1649 my $action=shift;
    1650 my $ver;
    1651 my $tag;
    1652 
    1653 $ENV{'PBETC'} = "$ENV{'HOME'}/.pbrc";
    1654 
    1655 # We only have one configuration file for now.
    1656 pb_conf_init("$ENV{'PBETC'}");
    1657 
    1658 #
    1659 # Check project name
    1660 # Could be with env var PBPROJ
    1661 # or option -p
    1662 # if not define take the first in conf file
    1663 #
    1664 if ((defined $ENV{'PBPROJ'}) &&
    1665     (not (defined $proj))) {
    1666     $proj = $ENV{'PBPROJ'};
    1667 }
    1668 
    1669 #
    1670 # We get the pbconf file for that project
    1671 # and use its content
    1672 #
    1673 my ($pbconf) = pb_conf_get("pbconfurl");
    1674 pb_log(2,"DEBUG pbconfurl: ".Dumper($pbconf)."\n");
    1675 
    1676 my %pbconf = %$pbconf;
    1677 if (not defined $proj) {
    1678     # Take the first as the default project
    1679     $proj = (keys %pbconf)[0];
    1680     if (defined $proj) {
    1681         pb_log(1,"WARNING: using $proj as default project as none has been specified\n");
    1682         pb_log(1,"         Please either create a pbconfurl reference for project $proj in $ENV{'PBETC'}\n");
    1683         pb_log(1,"         or call pb with the -p project option or use the env var PBPROJ\n");
    1684         pb_log(1,"         if you want to use another project\n");
    1685     }
    1686 }
    1687 die "No project defined - use env var PBPROJ or -p proj or a pbconfurl entry in $ENV{'PBETC'}" if (not (defined $proj));
    1688 
    1689 # That's always the environment variable that will be used
    1690 $ENV{'PBPROJ'} = $proj;
    1691 pb_log(2,"PBPROJ: $ENV{'PBPROJ'}\n");
    1692 
    1693 if (not defined ($pbconf{$ENV{'PBPROJ'}})) {
    1694     die "Please create a pbconfurl reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n";
    1695 }
    1696 
    1697 # Adds a potential conf file now as it's more
    1698 # important than the project conf file
    1699 my ($vmpath,$vepath) = pb_conf_get("vmpath","vepath");
    1700 pb_conf_add("$vmpath->{$ENV{'PBPROJ'}}/.pbrc") if (-f "$vmpath->{$ENV{'PBPROJ'}}/.pbrc");
    1701 pb_conf_add("$vepath->{$ENV{'PBPROJ'}}/.pbrc") if (-f "$vepath->{$ENV{'PBPROJ'}}/.pbrc");
    1702 
    1703 #
    1704 # Detect the root dir for hosting all the content generated with pb
    1705 #
    1706 # Tree will look like this:
    1707 #
    1708 #             maint pbdefdir                         PBDEFDIR            dev dir (optional)
    1709 #                  |                                                        |
    1710 #            ------------------------                                --------------------
    1711 #            |                      |                                |                  |
    1712 #         pbproj1                pbproj2             PBPROJ       pbproj1           pbproj2   PBPROJDIR
    1713 #            |                                                       |
    1714 #  ---------------------------------------------                ----------
    1715 #  *      *        *       |        |          |                *        *
    1716 # tag    dev    pbconf    ...     build     delivery PBCONFDIR dev      tag                 
    1717 #  |               |                           |     PBDESTDIR           |
    1718 #  ---          ------                        pbrc   PBBUILDDIR       -------
    1719 #    |          |    |                                                |     |
    1720 #   1.1        dev  tag                                              1.0   1.1                PBDIR
    1721 #                    |
    1722 #                 -------
    1723 #                 |     |
    1724 #                1.0   1.1                           PBROOTDIR
    1725 #                       |
    1726 #               ----------------------------------
    1727 #               |          |           |         |
    1728 #             pkg1      pbproj1.pb   pbfilter   pbcl
    1729 #               |
    1730 #        -----------------
    1731 #        |      |        |
    1732 #       rpm    deb    pbfilter
    1733 #
    1734 #
    1735 # (*) By default, if no relocation in .pbrc, dev dir is taken in the maint pbdefdir (when appropriate)
    1736 # Names under a pbproj and the corresponding pbconf should be similar
    1737 #
    1738 
    1739 my ($pbdefdir) = pb_conf_get_if("pbdefdir");
    1740 
    1741 if (not defined $ENV{'PBDEFDIR'}) {
    1742     if ((not defined $pbdefdir) || (not defined $pbdefdir->{$ENV{'PBPROJ'}})) {
    1743         pb_log(1,"WARNING: no pbdefdir defined, using /var/cache\n");
    1744         pb_log(1,"         Please create a pbdefdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n");
    1745         pb_log(1,"         if you want to use another directory\n");
    1746         $ENV{'PBDEFDIR'} = "/var/cache";
    1747     } else {
    1748         # That's always the environment variable that will be used
    1749         $ENV{'PBDEFDIR'} = $pbdefdir->{$ENV{'PBPROJ'}};
    1750     }
    1751 }
    1752 # Expand potential env variable in it
    1753 eval { $ENV{'PBDEFDIR'} =~ s/(\$ENV.+\})/$1/eeg };
    1754 
    1755 pb_log(2,"PBDEFDIR: $ENV{'PBDEFDIR'}\n");
    1756 #
    1757 # Set delivery directory
    1758 #
    1759 $ENV{'PBDESTDIR'}="$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/delivery";
    1760 
    1761 pb_log(2,"PBDESTDIR: $ENV{'PBDESTDIR'}\n");
    1762 #
    1763 # Removes all directory existing below the delivery dir
    1764 # as they are temp dir only
    1765 # Files stay and have to be cleaned up manually if needed
    1766 # those files serves as communication channels between pb phases
    1767 # Removing them prevents a following phase to detect what has been done before
    1768 #
    1769 if (-d $ENV{'PBDESTDIR'}) {
    1770     opendir(DIR,$ENV{'PBDESTDIR'}) || die "Unable to open directory $ENV{'PBDESTDIR'}: $!";
    1771     foreach my $d (readdir(DIR)) {
    1772         next if ($d =~ /^\./);
    1773         next if (-f "$ENV{'PBDESTDIR'}/$d");
    1774         pb_rm_rf("$ENV{'PBDESTDIR'}/$d") if (-d "$ENV{'PBDESTDIR'}/$d");
    1775     }
    1776     closedir(DIR);
    1777 }
    1778 if (! -d "$ENV{'PBDESTDIR'}") {
    1779     pb_mkdir_p($ENV{'PBDESTDIR'}) || die "Unable to recursively create $ENV{'PBDESTDIR'}";
    1780 }
    1781 
    1782 #
    1783 # Set build directory
    1784 #
    1785 $ENV{'PBBUILDDIR'}="$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/build";
    1786 if (! -d "$ENV{'PBBUILDDIR'}") {
    1787     pb_mkdir_p($ENV{'PBBUILDDIR'}) || die "Unable to recursively create $ENV{'PBBUILDDIR'}";
    1788 }
    1789 
    1790 pb_log(2,"PBBUILDDIR: $ENV{'PBBUILDDIR'}\n");
    1791 
    1792 pb_temp_init();
    1793 pb_log(2,"PBTMP: $ENV{'PBTMP'}\n");
    1794 
    1795 #
    1796 # The following part is only useful when in cms2something of newver
    1797 # In VMs/VEs we want to skip that by providing good env vars.
    1798 # return values in that case are useless
    1799 #
    1800 if (($action =~ /^cms2/) || ($action =~ /^newver$/)) {
    1801 
    1802     #
    1803     # Check pbconf cms compliance
    1804     #
    1805     pb_cms_compliant("pbconfdir",'PBCONFDIR',"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/pbconf",$pbconf{$ENV{'PBPROJ'}},$pbinit);
    1806 
    1807     # Check where is our PBROOTDIR (release tag name can't be guessed the first time)
    1808     #
    1809     if (not defined $ENV{'PBROOTDIR'}) {
    1810         if (! -f ("$ENV{'PBDESTDIR'}/pbrc")) {
    1811             opendir(DIR,$ENV{'PBCONFDIR'}) || die "Unable to open directory $ENV{'PBCONFDIR'}: $!";
    1812             my $maxmtime = 0;
    1813             foreach my $d (readdir(DIR)) {
    1814                 pb_log(3,"Looking at \'$d\'...");
    1815                 next if ($d =~ /^\./);
    1816                 next if (! -d "$ENV{'PBCONFDIR'}/$d");
    1817                 my $s = stat("$ENV{'PBCONFDIR'}/$d");
    1818                 next if (not defined $s);
    1819                 pb_log(3,"KEEP\n");
    1820                 # Keep the most recent
    1821                 pb_log(2," $s->mtime\n");
    1822                 if ($s->mtime > $maxmtime) {
    1823                     $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}/$d";
    1824                     $maxmtime = $s->mtime;
    1825                 }
    1826             }
    1827             closedir(DIR);
    1828             die "No directory found under $ENV{'PBCONFDIR'}" if (not defined $ENV{'PBROOTDIR'});
    1829             pb_log(1,"WARNING: no pbroot defined, using $ENV{'PBROOTDIR'}\n");
    1830             pb_log(1,"         Please use -r release if you want to use another release\n");
    1831         } else {
    1832             my ($pbroot) = pb_conf_read_if("$ENV{'PBDESTDIR'}/pbrc","pbroot");
    1833             # That's always the environment variable that will be used
    1834             die "Please remove inconsistent $ENV{'PBDESTDIR'}/pbrc" if ((not defined $pbroot) || (not defined $pbroot->{$ENV{'PBPROJ'}}));
    1835             $ENV{'PBROOTDIR'} = $pbroot->{$ENV{'PBPROJ'}};
    1836         }
    1837     } else {
    1838         # transform in full path if relative
    1839         $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}/$ENV{'PBROOTDIR'}" if ($ENV{'PBROOTDIR'} !~ /^\//);
    1840         pb_mkdir_p($ENV{'PBROOTDIR'}) if (defined $pbinit);
    1841         die "$ENV{'PBROOTDIR'} is not a directory" if (not -d $ENV{'PBROOTDIR'});
    1842     }
    1843 
    1844     # Adds that conf file to the list to consider
    1845     pb_conf_add("$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") if (-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb");
    1846 
    1847     return if ($action =~ /^newver$/);
    1848 
    1849     my %version = ();
    1850     my %defpkgdir = ();
    1851     my %extpkgdir = ();
    1852     my %filteredfiles = ();
    1853     my %supfiles = ();
    1854    
    1855     if ((-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") and (not defined $pbinit)) {
    1856 
    1857         # List of pkg to build by default (mandatory)
    1858         my ($defpkgdir,$pbpackager, $pkgv, $pkgt) = pb_conf_get("defpkgdir","pbpackager","projver","projtag");
    1859         # List of additional pkg to build when all is called (optional)
    1860         # Valid version names (optional)
    1861         # List of files to filter (optional)
    1862         # Project version and tag (optional)
    1863         my ($extpkgdir, $version, $filteredfiles, $supfiles) = pb_conf_get_if("extpkgdir","version","filteredfiles","supfiles");
    1864         pb_log(2,"DEBUG: defpkgdir: ".Dumper($defpkgdir)."\n");
    1865         pb_log(2,"DEBUG: extpkgdir: ".Dumper($extpkgdir)."\n");
    1866         pb_log(2,"DEBUG: version: ".Dumper($version)."\n");
    1867         pb_log(2,"DEBUG: filteredfiles: ".Dumper($filteredfiles)."\n");
    1868         pb_log(2,"DEBUG: supfiles: ".Dumper($supfiles)."\n");
    1869         # Global
    1870         %defpkgdir = %$defpkgdir;
    1871         %extpkgdir = %$extpkgdir if (defined $extpkgdir);
    1872         %version = %$version if (defined $version);
    1873         %filteredfiles = %$filteredfiles if (defined $filteredfiles);
    1874         %supfiles = %$supfiles if (defined $supfiles);
    1875         #
    1876         # Get global Version/Tag
    1877         #
    1878         if (not defined $ENV{'PBPROJVER'}) {
    1879             if ((defined $pkgv) && (defined $pkgv->{$ENV{'PBPROJ'}})) {
    1880                 $ENV{'PBPROJVER'}=$pkgv->{$ENV{'PBPROJ'}};
    1881             } else {
    1882                 die "No projver found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
    1883             }
    1884         }
    1885         die "Invalid version name $ENV{'PBPROJVER'} in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb" if (($ENV{'PBPROJVER'} !~ /[0-9.]+/) && (not defined $version) && ($ENV{'PBPROJVER'} =~ /$version{$ENV{'PBPROJ'}}/));
    1886        
    1887         if (not defined $ENV{'PBPROJTAG'}) {
    1888             if ((defined $pkgt) && (defined $pkgt->{$ENV{'PBPROJ'}})) {
    1889                 $ENV{'PBPROJTAG'}=$pkgt->{$ENV{'PBPROJ'}};
    1890             } else {
    1891                 die "No projtag found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
    1892             }
    1893         }
    1894         die "Invalid tag name $ENV{'PBPROJTAG'} in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb" if ($ENV{'PBPROJTAG'} !~ /[0-9.]+/);
    1895    
    1896    
    1897         if (not defined $ENV{'PBPACKAGER'}) {
    1898             if ((defined $pbpackager) && (defined $pbpackager->{$ENV{'PBPROJ'}})) {
    1899                 $ENV{'PBPACKAGER'}=$pbpackager->{$ENV{'PBPROJ'}};
    1900             } else {
    1901                 die "No pbpackager found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
    1902             }
    1903         }
    1904     } else {
    1905         if (defined $pbinit) {
    1906             my $ptr = pb_get_pkg();
    1907             my @pkgs = @$ptr;
    1908             @pkgs = ("pkg1") if (not @pkgs);
    1909    
    1910             open(CONF,"> $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") || die "Unable to create $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
    1911             print CONF << "EOF";
    1912 #
    1913 # Project Builder configuration file
    1914 # For project $ENV{'PBPROJ'}
    1915 #
    1916 # \$Id\$
    1917 #
    1918 
    1919 #
    1920 # What is the project URL
    1921 #
    1922 #pburl $ENV{'PBPROJ'} = svn://svn.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
    1923 #pburl $ENV{'PBPROJ'} = svn://svn+ssh.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
    1924 #pburl $ENV{'PBPROJ'} = cvs://cvs.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
    1925 #pburl $ENV{'PBPROJ'} = http://www.$ENV{'PBPROJ'}.org/src/$ENV{'PBPROJ'}-devel.tar.gz
    1926 #pburl $ENV{'PBPROJ'} = ftp://ftp.$ENV{'PBPROJ'}.org/src/$ENV{'PBPROJ'}-devel.tar.gz
    1927 #pburl $ENV{'PBPROJ'} = file:///src/$ENV{'PBPROJ'}-devel.tar.gz
    1928 #pburl $ENV{'PBPROJ'} = dir:///src/$ENV{'PBPROJ'}-devel
    1929 
    1930 # Check whether project is well formed
    1931 # (containing already a directory with the project-version name)
    1932 #pbwf $ENV{'PBPROJ'} = 1
    1933 
    1934 #
    1935 # Packager label
    1936 #
    1937 #pbpackager $ENV{'PBPROJ'} = William Porte <bill\@$ENV{'PBPROJ'}.org>
    1938 #
    1939 
    1940 # For delivery to a machine by SSH (potentially the FTP server)
    1941 # Needs hostname, account and directory
    1942 #
    1943 #sshhost $ENV{'PBPROJ'} = www.$ENV{'PBPROJ'}.org
    1944 #sshlogin $ENV{'PBPROJ'} = bill
    1945 #sshdir $ENV{'PBPROJ'} = /$ENV{'PBPROJ'}/ftp
    1946 #sshport $ENV{'PBPROJ'} = 22
    1947 
    1948 #
    1949 # For Virtual machines management
    1950 # Naming convention to follow: distribution name (as per ProjectBuilder::Distribution)
    1951 # followed by '-' and by release number
    1952 # followed by '-' and by architecture
    1953 # a .vmtype extension will be added to the resulting string
    1954 # a QEMU rhel-3-i286 here means that the VM will be named rhel-3-i386.qemu
    1955 #
    1956 #vmlist $ENV{'PBPROJ'} = mandrake-10.1-i386,mandrake-10.2-i386,mandriva-2006.0-i386,mandriva-2007.0-i386,mandriva-2007.1-i386,mandriva-2008.0-i386,redhat-7.3-i386,redhat-9-i386,fedora-4-i386,fedora-5-i386,fedora-6-i386,fedora-7-i386,fedora-8-i386,rhel-3-i386,rhel-4-i386,rhel-5-i386,suse-10.0-i386,suse-10.1-i386,suse-10.2-i386,suse-10.3-i386,sles-9-i386,sles-10-i386,gentoo-nover-i386,debian-3.1-i386,debian-4.0-i386,ubuntu-6.06-i386,ubuntu-7.04-i386,ubuntu-7.10-i386,mandriva-2007.0-x86_64,mandriva-2007.1-x86_64,mandriva-2008.0-x86_64,fedora-6-x86_64,fedora-7-x86_64,fedora-8-x86_64,rhel-4-x86_64,rhel-5-x86_64,suse-10.2-x86_64,suse-10.3-x86_64,sles-10-x86_64,gentoo-nover-x86_64,debian-4.0-x86_64,ubuntu-7.04-x86_64,ubuntu-7.10-x86_64
    1957 
    1958 #
    1959 # Valid values for vmtype are
    1960 # qemu, (vmware, xen, ... TBD)
    1961 #vmtype $ENV{'PBPROJ'} = qemu
    1962 
    1963 # Hash for VM stuff on vmtype
    1964 #vmntp default = pool.ntp.org
    1965 
    1966 # We suppose we can commmunicate with the VM through SSH
    1967 #vmhost $ENV{'PBPROJ'} = localhost
    1968 #vmlogin $ENV{'PBPROJ'} = pb
    1969 #vmport $ENV{'PBPROJ'} = 2222
    1970 
    1971 # Timeout to wait when VM is launched/stopped
    1972 #vmtmout default = 120
    1973 
    1974 # per VMs needed paramaters
    1975 #vmopt $ENV{'PBPROJ'} = -m 384 -daemonize
    1976 #vmpath $ENV{'PBPROJ'} = /home/qemu
    1977 #vmsize $ENV{'PBPROJ'} = 5G
    1978 
    1979 #
    1980 # For Virtual environment management
    1981 # Naming convention to follow: distribution name (as per ProjectBuilder::Distribution)
    1982 # followed by '-' and by release number
    1983 # followed by '-' and by architecture
    1984 # a .vetype extension will be added to the resulting string
    1985 # a chroot rhel-3-i286 here means that the VE will be named rhel-3-i386.chroot
    1986 #
    1987 #velist $ENV{'PBPROJ'} = fedora-7-i386
    1988 
    1989 # VE params
    1990 #vetype $ENV{'PBPROJ'} = chroot
    1991 #ventp default = pool.ntp.org
    1992 #velogin $ENV{'PBPROJ'} = pb
    1993 #vepath $ENV{'PBPROJ'} = /var/lib/mock
    1994 #veconf $ENV{'PBPROJ'} = /etc/mock
    1995 #verebuild $ENV{'PBPROJ'} = false
    1996 
    1997 #
    1998 # Global version/tag for the project
    1999 #
    2000 #projver $ENV{'PBPROJ'} = devel
    2001 #projtag $ENV{'PBPROJ'} = 1
    2002 
    2003 # Hash of valid version names
    2004 #version $ENV{'PBPROJ'} = devel,stable
    2005 
    2006 # Adapt to your needs:
    2007 # Optional if you need to overwrite the global values above
    2008 #
    2009 EOF
    2010        
    2011             foreach my $pp (@pkgs) {
    2012                 print CONF << "EOF";
    2013 #pkgver $pp = stable
    2014 #pkgtag $pp = 3
    2015 EOF
    2016             }
    2017             foreach my $pp (@pkgs) {
    2018                 print CONF << "EOF";
    2019 # Hash of default package/package directory
    2020 #defpkgdir $pp = dir-$pp
    2021 EOF
    2022             }
    2023    
    2024             print CONF << "EOF";
    2025 # Hash of additional package/package directory
    2026 #extpkgdir minor-pkg = dir-minor-pkg
    2027 
    2028 # List of files per pkg on which to apply filters
    2029 # Files are mentioned relatively to pbroot/defpkgdir
    2030 EOF
    2031             foreach my $pp (@pkgs) {
    2032                 print CONF << "EOF";
    2033 #filteredfiles $pp = Makefile.PL,configure.in,install.sh,$pp.8
    2034 #supfiles $pp = $pp.init
    2035 EOF
    2036             }
    2037             close(CONF);
    2038             pb_mkdir_p("$ENV{'PBROOTDIR'}/pbfilter") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter";
    2039             open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/all.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/all.pbf";
    2040             print CONF << "EOF";
    2041 #
    2042 # \$Id\$
    2043 #
    2044 # Filter for all files
    2045 #
    2046 # PBSRC is replaced by the source package format
    2047 #filter PBSRC = ftp://ftp.$ENV{'PBPROJ'}.org/src/%{name}-%{version}.tar.gz
    2048 
    2049 # PBVER is replaced by the version (\$pbver in code)
    2050 filter PBVER = \$pbver
    2051 
    2052 # PBDATE is replaced by the date (\$pbdate in code)
    2053 filter PBDATE = \$pbdate
    2054 
    2055 # PBLOG is replaced by the changelog if value is yes
    2056 #filter PBLOG = yes
    2057 
    2058 # PBTAG is replaced by the tag (\$pbtag in code)
    2059 filter PBTAG = \$pbtag
    2060 
    2061 # PBREV is replaced by the revision (\$pbrev in code)
    2062 filter PBREV = \$pbrev
    2063 
    2064 # PBPKG is replaced by the package name (\$pbpkg in code)
    2065 filter PBPKG = \$pbpkg
    2066 
    2067 # PBPACKAGER is replaced by the packager name (\$pbpackager in code)
    2068 filter PBPACKAGER = \$pbpackager
    2069 
    2070 # PBDESC contains the description of the package
    2071 #filter PBDESC = "Bla-Bla"
    2072 
    2073 # PBURL contains the URL of the Web site of the project
    2074 #filter PBURL = http://www.$ENV{'PBPROJ'}.org
    2075 EOF
    2076             close(CONF);
    2077             open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/rpm.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/rpm.pbf";
    2078             print CONF << "EOF";
    2079 #
    2080 # \$Id\$
    2081 #
    2082 # Filter for rpm build
    2083 #
    2084 
    2085 # PBGRP is replaced by the RPM group of apps
    2086 # Cf: http://fedoraproject.org/wiki/RPMGroups
    2087 #filter PBGRP = Applications/Archiving
    2088 
    2089 # PBLIC is replaced by the license of the application
    2090 # Cf: http://fedoraproject.org/wiki/Licensing
    2091 #filter PBLIC = GPL
    2092 
    2093 # PBDEP is replaced by the list of dependencies
    2094 #filter PBDEP =
    2095 
    2096 # PBSUF is replaced by the package suffix (\$pbsuf in code)
    2097 filter PBSUF = \$pbsuf
    2098 
    2099 # PBOBS is replaced by the Obsolete line
    2100 #filter PBOBS =
    2101 
    2102 EOF
    2103             close(CONF);
    2104             open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/deb.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/deb.pbf";
    2105             print CONF << "EOF";
    2106 #
    2107 # \$Id\$
    2108 #
    2109 # Filter for debian build
    2110 #
    2111 # PBGRP is replaced by the group of apps
    2112 filter PBGRP = utils
    2113 
    2114 # PBLIC is replaced by the license of the application
    2115 # Cf:
    2116 #filter PBLIC = GPL
    2117 
    2118 # PBDEP is replaced by the list of dependencies
    2119 #filter PBDEP =
    2120 
    2121 # PBSUG is replaced by the list of suggestions
    2122 #filter PBSUG =
    2123 
    2124 # PBREC is replaced by the list of recommandations
    2125 #filter PBREC =
    2126 
    2127 EOF
    2128             close(CONF);
    2129             open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/md.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/md.pbf";
    2130             print CONF << "EOF";
    2131 # Specific group for Mandriva for $ENV{'PBPROJ'}
    2132 # Cf: http://wiki.mandriva.com/en/Development/Packaging/Groups
    2133 #filter PBGRP = Archiving/Backup
    2134 
    2135 # PBLIC is replaced by the license of the application
    2136 # Cf: http://wiki.mandriva.com/en/Development/Packaging/Licenses
    2137 #filter PBLIC = GPL
    2138 
    2139 EOF
    2140             close(CONF);
    2141             open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/novell.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/novell.pbf";
    2142             print CONF << "EOF";
    2143 # Specific group for SuSE for $ENV{'PBPROJ'}
    2144 # Cf: http://en.opensuse.org/SUSE_Package_Conventions/RPM_Groups
    2145 #filter PBGRP = Productivity/Archiving/Backup
    2146 
    2147 # PBLIC is replaced by the license of the application
    2148 # Cf: http://en.opensuse.org/Packaging/SUSE_Package_Conventions/RPM_Style#1.6._License_Tag
    2149 #filter PBLIC = GPL
    2150 
    2151 EOF
    2152             close(CONF);
    2153             foreach my $pp (@pkgs) {
    2154                 pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/deb") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb";
    2155                 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/control") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/control";
    2156                 print CONF << "EOF";
    2157 Source: PBPKG
    2158 Section: PBGRP
    2159 Priority: optional
    2160 Maintainer: PBPACKAGER
    2161 Build-Depends: debhelper (>= 4.2.20), PBDEP
    2162 Standards-Version: 3.6.1
    2163 
    2164 Package: PBPKG
    2165 Architecture: amd64 i386 ia64
    2166 Section: PBGRP
    2167 Priority: optional
    2168 Depends: \${shlibs:Depends}, \${misc:Depends}, PBDEP
    2169 Recommends: PBREC
    2170 Suggests: PBSUG
    2171 Description:
    2172  PBDESC
    2173  .
    2174  Homepage: PBURL
    2175 
    2176 EOF
    2177                 close(CONF);
    2178                 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/copyright") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/copyright";
    2179                 print CONF << "EOF";
    2180 This package is debianized by PBPACKAGER
    2181 `date`
    2182 
    2183 The current upstream source was downloaded from
    2184 ftp://ftp.$ENV{'PBPROJ'}.org/src/.
    2185 
    2186 Upstream Authors: Put their name here
    2187 
    2188 Copyright:
    2189 
    2190    This package is free software; you can redistribute it and/or modify
    2191    it under the terms of the GNU General Public License as published by
    2192    the Free Software Foundation; version 2 dated June, 1991.
    2193 
    2194    This package is distributed in the hope that it will be useful,
    2195    but WITHOUT ANY WARRANTY; without even the implied warranty of
    2196    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2197    GNU General Public License for more details.
    2198 
    2199    You should have received a copy of the GNU General Public License
    2200    along with this package; if not, write to the Free Software
    2201    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
    2202    MA 02110-1301, USA.
    2203 
    2204 On Debian systems, the complete text of the GNU General
    2205 Public License can be found in /usr/share/common-licenses/GPL.
    2206 
    2207 EOF
    2208                 close(CONF);
    2209                 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/changelog") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/changelog";
    2210                 print CONF << "EOF";
    2211 PBLOG
    2212 EOF
    2213                 close(CONF);
    2214                 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/compat") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/compat";
    2215                 print CONF << "EOF";
    2216 4
    2217 EOF
    2218                 close(CONF);
    2219                 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/$pp.dirs") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/$pp.dirs";
    2220                 print CONF << "EOF";
    2221 EOF
    2222                 close(CONF);
    2223                 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/$pp.docs") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/$pp.docs";
    2224                 print CONF << "EOF";
    2225 INSTALL
    2226 COPYING
    2227 AUTHORS
    2228 NEWS
    2229 README
    2230 EOF
    2231                 close(CONF);
    2232                 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/rules") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/rules";
    2233                 print CONF << 'EOF';
    2234 #!/usr/bin/make -f
    2235 # -*- makefile -*-
    2236 # Sample debian/rules that uses debhelper.
    2237 # GNU copyright 1997 to 1999 by Joey Hess.
    2238 #
    2239 # $Id$
    2240 #
    2241 
    2242 # Uncomment this to turn on verbose mode.
    2243 #export DH_VERBOSE=1
    2244 
    2245 # Define package name variable for a one-stop change.
    2246 PACKAGE_NAME = PBPKG
    2247 
    2248 # These are used for cross-compiling and for saving the configure script
    2249 # from having to guess our platform (since we know it already)
    2250 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
    2251 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
    2252 
    2253 CFLAGS = -Wall -g
    2254 
    2255 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
    2256         CFLAGS += -O0
    2257 else
    2258         CFLAGS += -O2
    2259 endif
    2260 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
    2261         INSTALL_PROGRAM += -s
    2262 endif
    2263 config.status: configure
    2264         dh_testdir
    2265 
    2266         # Configure the package.
    2267         CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr
    2268  --mandir=\$${prefix}/share/man
    2269 
    2270 # Build both architecture dependent and independent
    2271 build: build-arch build-indep
    2272 
    2273 # Build architecture dependent
    2274 build-arch: build-arch-stamp
    2275 
    2276 build-arch-stamp:  config.status
    2277         dh_testdir
    2278 
    2279         # Compile the package.
    2280         $(MAKE)
    2281 
    2282         touch build-stamp
    2283 
    2284 # Build architecture independent
    2285 build-indep: build-indep-stamp
    2286 
    2287 build-indep-stamp:  config.status
    2288         # Nothing to do, the only indep item is the manual which is available as html in original source
    2289         touch build-indep-stamp
    2290 
    2291 # Clean up
    2292 clean:
    2293         dh_testdir
    2294         dh_testroot
    2295         rm -f build-arch-stamp build-indep-stamp #CONFIGURE-STAMP#
    2296         # Clean temporary document directory
    2297         rm -rf debian/doc-temp
    2298         # Clean up.
    2299         -$(MAKE) distclean
    2300         rm -f config.log
    2301 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
    2302         cp -f /usr/share/misc/config.sub config.sub
    2303 endif
    2304 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
    2305         cp -f /usr/share/misc/config.guess config.guess
    2306 endif
    2307 
    2308         dh_clean
    2309 
    2310 # Install architecture dependent and independent
    2311 install: install-arch install-indep
    2312 
    2313 # Install architecture dependent
    2314 install-arch: build-arch
    2315         dh_testdir
    2316         dh_testroot
    2317         dh_clean -k -s
    2318         dh_installdirs -s
    2319 
    2320         # Install the package files into build directory:
    2321         # - start with upstream make install
    2322         $(MAKE) install prefix=$(CURDIR)/debian/$(PACKAGE_NAME)/usr mandir=$(CURDIR)/debian/$(PACKAGE_NAME)/us
    2323 r/share/man
    2324         # - copy html manual to temporary location for renaming
    2325         mkdir -p debian/doc-temp
    2326         dh_install -s
    2327 
    2328 # Install architecture independent
    2329 install-indep: build-indep
    2330         dh_testdir
    2331         dh_testroot
    2332         dh_clean -k -i
    2333         dh_installdirs -i
    2334         dh_install -i
    2335 
    2336 # Must not depend on anything. This is to be called by
    2337 # binary-arch/binary-indep
    2338 # in another 'make' thread.
    2339 binary-common:
    2340         dh_testdir
    2341         dh_testroot
    2342         dh_installchangelogs ChangeLog
    2343         dh_installdocs
    2344         dh_installman
    2345         dh_link
    2346         dh_strip
    2347         dh_compress
    2348         dh_fixperms
    2349         dh_installdeb
    2350         dh_shlibdeps
    2351         dh_gencontrol
    2352         dh_md5sums
    2353         dh_builddeb
    2354 
    2355 # Build architecture independant packages using the common target.
    2356 binary-indep: build-indep install-indep
    2357         $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
    2358 
    2359 # Build architecture dependant packages using the common target.
    2360 binary-arch: build-arch install-arch
    2361         $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
    2362 
    2363 # Build architecture depdendent and independent packages
    2364 binary: binary-arch binary-indep
    2365 .PHONY: clean binary
    2366 
    2367 EOF
    2368                 close(CONF);
    2369                 pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/rpm") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/rpm";
    2370                 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/rpm/$pp.spec") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/rpm/$pp.spec";
    2371                 print CONF << 'EOF';
    2372 #
    2373 # $Id$
    2374 #
    2375 
    2376 Summary:        bla-bla
    2377 Summary(fr):    french bla-bla
    2378 
    2379 Name:           PBPKG
    2380 Version:        PBVER
    2381 Release:        PBTAGPBSUF
    2382 License:        PBLIC
    2383 Group:          PBGRP
    2384 Url:            PBURL
    2385 Source:         PBSRC
    2386 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -u -n)
    2387 #Requires:       PBDEP
    2388 
    2389 %description
    2390 PBDESC
    2391 
    2392 %description -l fr
    2393 french desc
    2394 
    2395 %prep
    2396 %setup -q
    2397 
    2398 %build
    2399 %configure
    2400 make %{?_smp_mflags}
    2401 
    2402 %install
    2403 %{__rm} -rf $RPM_BUILD_ROOT
    2404 make DESTDIR=$RPM_BUILD_ROOT install
    2405 
    2406 %clean
    2407 %{__rm} -rf $RPM_BUILD_ROOT
    2408 
    2409 %files
    2410 %defattr(-,root,root)
    2411 %doc ChangeLog
    2412 %doc INSTALL COPYING README AUTHORS NEWS
    2413 
    2414 %changelog
    2415 PBLOG
    2416 
    2417 EOF
    2418                 close(CONF);
    2419                 pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/pbfilter") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/pbfilter";
    2420    
    2421                 pb_log(0,"\nDo not to forget to commit the pbconf directory in your CMS if needed\n");
    2422             }
    2423         } else {
    2424             die "Unable to open $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
    2425         }
    2426     }
    2427     umask 0022;
    2428     return(\%filteredfiles, \%supfiles, \%defpkgdir, \%extpkgdir);
    2429 } else {
    2430     # Setup the variables from what has been stored at the end of cms2build
    2431     my ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","pbroot");
    2432     $ENV{'PBROOTDIR'} = $var->{$ENV{'PBPROJ'}};
    2433 
    2434     ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","projver");
    2435     $ENV{'PBPROJVER'} = $var->{$ENV{'PBPROJ'}};
    2436 
    2437     ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","projtag");
    2438     $ENV{'PBPROJTAG'} = $var->{$ENV{'PBPROJ'}};
    2439 
    2440     ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","pbpackager");
    2441     $ENV{'PBPACKAGER'} = $var->{$ENV{'PBPROJ'}};
    2442 
    2443     return;
    2444 }
    2445 }
    24461646
    24471647#
Note: See TracChangeset for help on using the changeset viewer.