[Gambas-user] Problems with "Make installation packages"
Carsten Olsen
carsten at ...500...
Thu Jun 24 20:39:20 CEST 2004
I tried to change the Package.module (attached), the shell at line 320
from rpm to rpmbuild. It looks like, it did the job (for rpm-4.3.1-0.3 /
rpmbuild-4.3.1-0.3)
SHELL "rpmbuild -ba " & Project.Quote(sHome &/ "RPM/SPECS" &/ sName &
".spec") & " > " & Project.Quote(sTemp) & " 2>&1" WAIT
Carsten
On Thu, 2004-06-24 at 17:28, Georg Brandl wrote:
> Benoit Minisini wrote:
> > On Thursday 24 June 2004 01:11, Benoit Minisini wrote:
> >> On Wednesday 23 June 2004 15:56, Carsten Olsen wrote:
> >> > Hi
> >> >
> >> > I have tried the new function "Make installation packages""Make
> >> > installation packages". I tried to build RPM to Redhat / Fedora (on a
> >> > Fedora Core 2 box) but I get this message in the make... dialog.
> >> >
> >> > Creating package for Redhat /Fedora.
> >> > Creating source package.
> >> > Creating .spec file.
> >> > Creating RPM packages.
> >> > The package build has failed.
> >> >
> >> > -ba: unknown option
> >> >
> >> > Kind regards
> >> > Carsten Olsen
> >>
> >> Can you send me the result of "man rpm" on your Fedora ?
> >
> > Because if you read http://www.rpm.org/max-rpm/ch-rpm-b-command.html, the "rpm
> > -ba" means something!
>
> In the newer rpm versions, the build commands have been swapped out to a
> separate command, named "rpmbuild". It could be that the newer RPM
> versions (mine too, v4.2.1) do not understand the -ba switch.
>
> mfg
> Georg
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by Black Hat Briefings & Training.
> Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
> digital self defense, top technical experts, no vendor pitches,
> unmatched networking opportunities. Visit www.blackhat.com
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20040624/9df2d31a/attachment.html>
-------------- next part --------------
' Gambas module file
PUBLIC Name AS String
PUBLIC Address AS String
PUBLIC Path AS String
PUBLIC Change AS String
PRIVATE SUB AddLog(sText AS String)
FMakeInstall.AddLog(sText)
END
PUBLIC FUNCTION Make() AS Boolean
DIM sSys AS String
FormatChange
FOR EACH sSys IN Project.Systems
IF MakePackage(sSys) THEN RETURN TRUE
NEXT
AddLog(("Saving CHANGELOG file."))
File.Save(Project.Dir &/ "CHANGELOG", Change)
AddLog(("The packages have been successfully created."))
Message(("The packages have been successfully created."))
END
PUBLIC FUNCTION GetChangeDate() AS String
DIM sLang AS String
DIM sDate AS String
sLang = System.Language
System.Language = "C"
sDate = Format$(Now, "ddd mmm dd yyyy") & " " & Name & " "
IF Address THEN sDate = sDate & "<" & Address & "> "
sDate = sDate & Subst("&1.&2-&3", Project.MajorVersion, Project.MinorVersion, Project.ReleaseVersion)
System.Language = sLang
RETURN sDate
END
PRIVATE SUB FormatChange()
DIM aLine AS String[]
DIM sLine AS String
aLine = Split(Change, "\n")
Change = ""
FOR EACH sLine IN aLine
sLine = Trim(sLine)
IF NOT sLine THEN CONTINUE
IF Left(sLine) <> "-" THEN sLine = "- " & sLine
Change = Change & sLine & "\n"
NEXT
Change = "* " & GetChangeDate() & "\n" & Change
TRY Change = Change & "\n" & File.Load(Project.Dir &/ "CHANGELOG")
END
PRIVATE FUNCTION IsConsoleProject() AS Boolean
DIM sLib AS String
FOR EACH sLib IN Project.Libraries
IF CComponent.All[sLib].Type = "Form" THEN RETURN FALSE
NEXT
RETURN TRUE
END
PRIVATE FUNCTION MakePackage(sSys AS String) AS Boolean
DIM sName AS String
DIM sProjectName AS String
DIM sHome AS String
DIM sSrc AS String
DIM sDir AS String
DIM sCmd AS String
DIM hFile AS File
DIM sArch AS String
DIM sTemp AS String
DIM sOutput AS String
DIM sLang AS String
DIM sPackage AS String
DIM sVersionSuffix AS String
DIM hIcon AS NEW Image
DIM sIcon AS String
DIM sPrefix AS String
'DIM bKillRpm AS Boolean
DIM sDistribution AS String
DIM sVendor AS String
DIM bDebianMenu AS Boolean
DIM bRedhatMenu AS Boolean
DIM sRelease AS String
INC Application.Busy
SELECT CASE sSys
CASE "mandrake"
sDistribution = "MandrakeLinux"
sVendor = "MandrakeSoft"
bDebianMenu = TRUE
sVersionSuffix = "mdk"
CASE "debian"
sDistribution = "Debian"
sVendor = "Debian"
bDebianMenu = TRUE
CASE "redhat"
sDistribution = "RedHat"
sVendor = "RedHat"
bRedhatMenu = TRUE
END SELECT
sProjectName = Conv(Project.Name, Desktop.Charset, System.Charset)
IF Project.Prefix THEN sPrefix = "gambas-"
sName = sPrefix & LCase(sProjectName)
sHome = System.Home
' step 1, set up RPM dirs and macros if they're not there already
AddLog(Subst(("Creating package for &1."), FMakeInstall.GetSystemName(sSys)))
sLang = System.Language
System.Language = "C"
IF NOT Exist(sHome &/ "RPM") THEN
AddLog(("Initializing ~/RPM directory."))
FOR EACH sCmd IN [ "RPM/", "RPM/BUILD/", "RPM/RPMS/", "RPM/SOURCES/", "RPM/SPECS/", "RPM/SRPMS/", "RPM/tmp/" ]
TRY MKDIR sHome &/ sCmd
NEXT
ENDIF
OPEN sHome &/ ".rpmmacros" FOR CREATE AS hFile
PRINT #hFile, "%_topdir " & sHome &/ "RPM"
PRINT #hFile, "%_tmppath " & sHome &/ "RPM/tmp"
PRINT #hFile, "%distribution "; sDistribution
PRINT #hFile, "%vendor "; sVendor
PRINT #hFile, "%packager "; Name & "<" & Conv(Address, Desktop.Charset, System.Charset) & ">"
PRINT #hFile, "%buildhost "; System.Host
CLOSE #hFile
' step 2, write source tarball (with bzip) to SOURCES dir
AddLog(("Creating source package."))
sSrc = sHome &/ "RPM/SOURCES"
sDir = Project.Dir &/ ".icon"
SHELL "rm -rf " & Project.Quote(sDir) WAIT
TRY MKDIR sDir
IF Project.Icon THEN
hIcon.Load(Project.Dir &/ Project.Icon)
ELSE
hIcon.Load("img/gambas.png")
ENDIF
hIcon.Stretch(16, 16, TRUE).Save(sDir &/ "16.png")
hIcon.Stretch(32, 32, TRUE).Save(sDir &/ "32.png")
hIcon.Stretch(48, 48, TRUE).Save(sDir &/ "48.png")
sArch = sSrc &/ (sPrefix & Subst("&1-&2.&3.tar.bz2", LCase(Project.Name), Project.MajorVersion, Project.MinorVersion, Project.ReleaseVersion))
Project.MakeSourcePackageTo(sArch)
AddLog(("Creating .spec file."))
OPEN sHome &/ "RPM/SPECS" &/ sName & ".spec" FOR CREATE AS hFile
PRINT #hFile, "%define name " & sName
PRINT #hFile, "%define version " & Subst("&1.&2", Project.MajorVersion, Project.MinorVersion)
sRelease = Project.ReleaseVersion & sVersionSuffix
PRINT #hFile, "%define release "; sRelease
PRINT #hFile
PRINT #hFile, "Summary: " & IIf(Project.Title, Project.Title, "Gambas project " & Project.Name)
PRINT #hFile, "Name: %{name}"
PRINT #hFile, "Version: %{version}"
PRINT #hFile, "Release: %{release}"
PRINT #hFile, "Source0: %{name}-%{version}.tar.bz2"
PRINT #hFile, "License: GPL"
PRINT #hFile, "Group: " & Project.Groups[sSys]
PRINT #hFile, "BuildRoot: %{_tmppath}/%{name}-buildroot"
PRINT #hFile, "Prefix: %{_prefix}"
'PRINT #hFile, "BuildRequires: gambas-gui"
PRINT #hFile, "BuildArch: noarch"
PRINT #hFile, "Requires: gambas"
PRINT #hFile,"AutoReqProv: no"
PRINT #hFile, "\n%description\n" & Project.Description & "\nThis program is written in Gambas, so you will need Gambas to be installed."
PRINT #hFile, "\n%prep"
PRINT #hFile, "rm -rf $RPM_BUILD_ROOT"
PRINT #hFile, "\n%setup -q -n " & Project.Quote(sProjectName)
PRINT #hFile, "\n%build"
PRINT #hFile, Project.GetCompileCommand(TRUE, NOT Project.KeepDebugInfo, FALSE) & "\ngba"
PRINT #hFile, "\n%install"
PRINT #hFile, "install -d $RPM_BUILD_ROOT/usr/bin"
PRINT #hFile, "install -Cp "; Project.Quote(sProjectName); " $RPM_BUILD_ROOT/usr/bin/"; sName
sIcon = Project.Quote(sName) & ".png"
IF bDebianMenu THEN
PRINT #hFile, "install -d $RPM_BUILD_ROOT/%{_miconsdir}"
PRINT #hFile, "install -d $RPM_BUILD_ROOT/%{_iconsdir}"
PRINT #hFile, "install -d $RPM_BUILD_ROOT/%{_liconsdir}"
PRINT #hFile, "install -Cp .icon/16.png $RPM_BUILD_ROOT/%{_miconsdir}" &/ sIcon
PRINT #hFile, "install -Cp .icon/32.png $RPM_BUILD_ROOT/%{_iconsdir}" &/ sIcon
PRINT #hFile, "install -Cp .icon/48.png $RPM_BUILD_ROOT/%{_liconsdir}" &/ sIcon
PRINT #hFile, "install -d $RPM_BUILD_ROOT/%{_menudir}"
PRINT #hFile, "cat << EOF > $RPM_BUILD_ROOT/%{_menudir}/"; Project.Quote(sName)
PRINT #hFile, Subst("?package(&1):command=\"/usr/bin/&1\" icon=\"&1.png\" ", sName);
IF IsConsoleProject() THEN
PRINT #hFile, "needs=\"text\"";
ELSE
PRINT #hFile, "needs=\"X11\"";
ENDIF
PRINT #hFile," section=\""; Project.Menus[sSys]; "\" title=\"";
IF Project.Title THEN
PRINT #hFile, Project.Title;
ELSE
PRINT #hFile, Project.Name;
ENDIF
PRINT #hFile, "\" ";
PRINT #hFile, "longtitle=\"";
IF Project.Description THEN
PRINT #hFile, Replace(Project.Description, "\n", " ");
ELSE
PRINT #hFile, Project.Name;
ENDIF
PRINT #hFile, "\" ";
PRINT #hFile, "startup_notify=\"true\""
PRINT #hFile, "EOF"
PRINT #hFile, "\n%post"
PRINT #hFile, "%{update_menus}"
PRINT #hFile, "\n%postun"
PRINT #hFile, "%{clean_menus}"
ENDIF
IF bRedHatMenu THEN
PRINT #hFile, "install -d $RPM_BUILD_ROOT/%{_datadir}/pixmaps"
PRINT #hFile, "install -d $RPM_BUILD_ROOT/%{_datadir}/applications"
PRINT #hFile, "install -Cp .icon/32.png $RPM_BUILD_ROOT/%{_datadir}/pixmaps" &/ sIcon
PRINT #hFile, "cat << EOF > $RPM_BUILD_ROOT/%{_datadir}/applications" &/ Project.Quote(sName) & ".desktop"
PRINT #hFile, "[Desktop Entry]"
PRINT #hFile, "Name="; Project.Title
PRINT #hFile, "Comment="; Replace(Project.Description, "\n", " ")
PRINT #hFile, "Categories="; Replace(Replace(Project.Menus[sSys], " ", ""), "/", ";"); ";X-Red-Hat-Extra"
PRINT #hFile, "Icon=/usr/share/pixmaps" &/ sIcon
PRINT #hFile, "Exec=/usr/bin" &/ sName
PRINT #hFile, "Type=Application"
PRINT #hFile, "Terminal="; IIf(IsConsoleProject(), "True", "False")
PRINT #hfile, "Encoding=UTF-8"
PRINT #hFile, "EOF"
ENDIF
PRINT #hFile, "\n%clean"
PRINT #hFile, "rm -rf $RPM_BUILD_ROOT"
PRINT #hFile, "\n%files"
PRINT #hFile, "%defattr(-,root,root)"
PRINT #hFile, "/usr/bin/" & sName
IF bDebianMenu THEN
PRINT #hFile, "/%{_miconsdir}" &/ sIcon
PRINT #hFile, "/%{_iconsdir}" &/ sIcon
PRINT #hFile, "/%{_liconsdir}" &/ sIcon
PRINT #hFile, "/%{_menudir}" &/ sName
ENDIF
IF bRedHatMenu THEN
PRINT #hFile, "%{_datadir}/pixmaps" &/ sIcon
PRINT #hFile, "%{_datadir}/applications" &/ Project.Quote(sName) & ".desktop"
ENDIF
PRINT #hFile, "\n%changelog\n"
PRINT #hFile, Change
CLOSE #hFile
' and step 4.... build that sucker.
AddLog(("Creating RPM packages."))
sTemp = Temp$
SHELL "rpmbuild -ba " & Project.Quote(sHome &/ "RPM/SPECS" &/ sName & ".spec") & " > " & Project.Quote(sTemp) & " 2>&1" WAIT
sOutput = Conv(Replace(File.Load(sTemp), "\r", ""), System.Charset, Desktop.Charset)
System.Language = sLang
DEC Application.Busy
FOR EACH sCmd IN Split(sOutput, "\n")
IF Left(sCmd, 6) = "Wrote:" AND Right$(sCmd, 10) = "noarch.rpm" THEN
sPackage = sPrefix & Subst("&1-&2.&3-&4.noarch.rpm", LCase(Project.Name), Project.MajorVersion, Project.MinorVersion, sRelease)
IF sSys = "debian" THEN
SHELL "cd " & ProjectQuote(sHome &/ "RPM/RPMS/noarch") & "; alien --to-deb -k " & Project.Quote(sPackage) WAIT
sPackage = sPrefix & Subst("&1_&2.&3-&4_all.deb", LCase(Project.Name), Project.MajorVersion, Project.MinorVersion, sRelease)
IF NOT Exist(sHome &/ "RPM/RPMS/noarch" &/ sPackage) THEN Error.Raise("alien command has failed")
ENDIF
RENAME sHome &/ "RPM/RPMS/noarch" &/ sPackage AS Path &/ sPackage
sPackage = sPrefix & Subst("&1-&2.&3-&4.src.rpm", LCase(Project.Name), Project.MajorVersion, Project.MinorVersion, sRelease)
IF sSys = "debian" THEN
SHELL "cd " & ProjectQuote(sHome &/ "RPM/SRPMS") & "; alien --to-deb -k " & Project.Quote(sPackage) WAIT
sPackage = sPrefix & Subst("&1_&2.&3-&4_all.deb", LCase(Project.Name), Project.MajorVersion, Project.MinorVersion, sRelease)
IF NOT Exist(sHome &/ "RPM/SRPMS" &/ sPackage) THEN Error.Raise("alien command has failed")
ENDIF
RENAME sHome &/ "RPM/SRPMS" &/ sPackage AS Path &/ sPackage
RETURN
END IF
NEXT
Error.Raise(sOutput)
CATCH
PRINT sOutput
AddLog(("The package build has failed.") &"\n")
AddLog(Error.Text)
Message.Error(("The package build has failed."))
RETURN TRUE
END
More information about the User
mailing list