I'm new to the rpmbuild, googled and copy one spec file paramenters and created rpm successfully when i ran it the rpm nothing is creating

var.tar.gz -- this is my tar file. it hasvar/var/www/var/www/html/index.html

My spec file

[root@kaka1 SPECS]# vi var.spec Name: varVersion: 1Release: 0Summary: Xiph Streaming media server that supports multiple formats.Group: Applications/MultimediaLicense: GPLURL: http################Source: var-1.0.tar.gzPrefix: %{_prefix}Packager: SukamaBuildRoot: %{_tmppath}/%{name}-root%descriptioneasily and supports open standards for commuincation and interaction.%preprm -rf /root/rpmbuild/BUILD/*%setup -n vargzip -dc /root/rpmbuild/SOURCES/var-1.0.tar.gz| tar -xvvf -if [ $? -ne 0 ]; thenexit $?fi

could you help me where can i should mention my files to create under root?

  • 1
    Why are you writing to /var/www/ ? Are you creating your own apache like package ? This directory should be owned by apache rpm. Clarify what you are trying to do here ?– iamauserFeb 13 at 19:39
  • Hi, I want to deploy some index.html files under /var/www/ on multiple hosts through rpm only. if dir not exists wanted to create with rpm those dir and files– Das DFeb 14 at 5:39
  • @iamauser The directory should indeed be owned by apache, but its contents may belong to other packages.– glglglFeb 14 at 15:05
  • @glglgl yes, and that's how I designed it in my answer.– iamauserFeb 14 at 15:07

First, don't use name like var, usr as package name, use that's more relevant to what the package may represent. Here is a simple spec file that should install index.html into the /var/www directory.

%define debug_package %{nil}Summary: Simple SPECName: simpleVersion: 0Release: 1License: NONE # Use your suitable licenseGroup: NONEURL: NONESource0: %{name}-%{version}.tar.gzBuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root## Following lines are commented out, but that's the way to go #BuildRequires: httpd # This needs https RPM during your build#Requires: httpd # This would require httpd to be installed for this RPM %description%prep%setup -q # This untars the source%build # currently empty%install # This moves into the source directory "simple-0" (see below)rm -rf $RPM_BUILD_ROOTmkdir -p $RPM_BUILD_ROOT/var/wwwinstall -m 0644 index.html %{buildroot}/var/www/index.html%cleanrm -rf $RPM_BUILD_ROOT%post%files%defattr(-,root,root,-)%doc/var/www/index.html # Your packages owns the file, but not the directories%changelog* Web Feb 14 2018 <user@localhost> - 0.0- Initial build.

For the above .spec file, one would need a tarball named simple-0.tar.gz. This maps to the Source0 name that is used inside the .spec. The content in this case would be a directory and a file: simple-0/index.html.

    Your Answer


    By posting your answer, you agree to the privacy policy and terms of service.

    Not the answer you're looking for? Browse other questions tagged or ask your own question.