Author Topic: First package  (Read 1276 times)

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
First package
« on: November 03, 2011, 02:56:38 PM »
You can get the SRPM here: http://www.utechia.com/Linux/SRPMS/repair-database-0.1-1glamdring2011.src.rpm

Here is what my spec looks like:
Code: [Select]
%define prefix /usr
%define name repair-database
%define version 0.1
%define release %mkrel 1
%define url http://www.pclinuxos.com/forum/index.phptopic,85630.0.html

Name:          %{name}
Version:       %{version}
Release:       %{release}
License:       GPL
Group:         System/Configuration  
URL:           %{url}
Source:        %{name}-%{version}.tar.xz      
Summary:       Rebuilds and cleans the repository database
Summary(de):   Erneuert und reinigt die Repository-Datenbank  
BuildRoot:     %{_tmppath}/%{name}-buildroot      
Requires:      yad
Obsoletes:     %name < %version

 
%description
Rebuilds and cleans the repository database.
The script rebuilds and cleans the repository database according to Texstars requirements.
 
#german
%description -l de
Erneuert und reinigt die Repository-Datenbank.
Das Skript baut und reinigt die Repository-Datenbank nach Texstars Anforderungen.
 
%prep
 
%setup -q -n %{name}-%{version}  
 
rm -rf $RPM_BUILD_ROOT
 
%install
#script, or bin file
mkdir -p %{buildroot}%{_bindir}
install -m 755 %{name} %{buildroot}%{_bindir}/%{name}

#desktop file
mkdir -p %{buildroot}%{_datadir}/applications
cat > %{buildroot}%{_datadir}/applications/%{name}.desktop << EOF
[Desktop Entry]
Version=0.1
Type=Application
Name=Repair Database
Name[de]=Datenbank reparieren
Exec=repair-database
Icon=dbrepair.png
Comment=Repair Database
Comment[de]=Datenbank reparieren
Categories=RepairDatabase;System;X-MandrivaLinux-System-Configuration;X-MandrivaLinux-System-Configuration-Packaging;
Terminal=false
Encoding=UTF-8
StartupNotify=true
EOF

#icon
mkdir -p %{buildroot}%{_datadir}/icons
install -m 655 dbrepair.png %{buildroot}%{_datadir}/icons/dbrepair.png
 
%files
%defattr(-,root,root)
%{_bindir}/%{name}
%{_datadir}/icons/dbrepair.png
%{_datadir}/applications/%{name}.desktop
 
%clean
rm -rf %{buildroot}
rm -rf $RPM_BUILD_DIR/%{name}-%{version}

%changelog
*Thu Nov 03 2011 glamdring <glamdring02 at gmail.com> 0.1-1pclos2011
- created for pclinuxos

[SOLVED]I'm getting the error -ba unknown in terminal. I just installed pkgutils.
[SOLVED]Getting an error when trying to build the RPM.

-Thank You
« Last Edit: November 04, 2011, 10:59:07 AM by glamdring »

Offline daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3737
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: First package -ba unkown
« Reply #1 on: November 03, 2011, 02:59:07 PM »
I'm getting the error -ba unknown in terminal. I just installed pkgutils.

Here is what my spec looks like:
Code: [Select]
%define prefix /usr
 %define name repair-database
 %define version 0.1
 %define release %mkrel 1
 %define url http://www.pclinuxos.com/forum/index.php/topic,85630.0.html
Name:           %{name}
 Version:       %{version}
 Release:       %{release}
 License:       GPL
 Group:         System/Configuration  
 URL:           %{url}
 Source:        %{name}-%{version} .tar.xz      
 Summary:       The script rebuilds and cleans the repository database according to Texstars requirements.
 Summary(de):   Das Skript baut und reinigt die Repository-Datenbank nach Texstars Anforderungen.  
 BuildRoot:     %{_tmppath}/%{name}-buildroot      
 Requires:      yad
 Obsoletes:     %name < %version

 
%description Rebuilds and cleans the repository database
 
#german %description -l de Umbauten und reinigt die Repository-Datenbank
 
%prep
 
%setup -q -n %{name}-%{version}  
 
rm -rf $RPM_BUILD_ROOT
 
%install
 
install -d -m 755 $RPM_BUILD_ROOT%{_bindir}

install -m 755 repair-database.sh $RPM_BUILD_ROOT%{_bindir}

mkdir -p %{buildroot}%{_datadir}/applications

cat > %{buildroot}%{_datadir}/applications/%{name}.desktop

EOF

[Desktop Entry]
Version=0.1
Type=Application
Name=Repair Database
Exec=repair-database
Icon=dbrepair.png
Comment=Repair Database
Categories=RepairDatabase;System;X-MandrivaLinux-System-Configuration;X-MandrivaLinux-System-Configuration-Packaging;
Terminal=false
Encoding=UTF-8
StartupNotify=true
EOF
 
%makeinstall_std
 
%files
 %defattr(-,root,root)
 %{_bindir}/%{name}
 %{_sharedir}/icons/dbrepair.png
 
%clean
 rm -rf %{buildroot}
 rm -rf $RPM_BUILD_DIR/%{name}-%{version}
 
%changelog
Thu Nov 03 2011 glamdring <glamdring02 at gmail.com> 0.1pclos
- created for pclinuxos

-Thank You


If you use the command rpmbuild -ba, or rpm -ba.
The latest command don't working with rpm 4.8.

Offline daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3737
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: First package -ba unkown
« Reply #2 on: November 03, 2011, 03:08:21 PM »
Edit script

Here is what my spec looks like:
Code: [Select]
%define prefix /usr
 %define name repair-database
 %define version 0.1
 %define release %mkrel 1
 %define url http://www.pclinuxos.com/forum/index.php/topic,85630.0.html
Name:           %{name}
 Version:       %{version}
 Release:       %{release}
 License:       GPL
 Group:         System/Configuration  
 URL:           %{url}
 Source:        %{name}-%{version} .tar.xz      
 Summary:       The script rebuilds and cleans the repository database according to Texstars requirements.
 Summary(de):   Das Skript baut und reinigt die Repository-Datenbank nach Texstars Anforderungen.  
 BuildRoot:     %{_tmppath}/%{name}-buildroot      
 Requires:      yad
 Obsoletes:     %name < %version

 
%description
Rebuilds and cleans the repository database
 
#german
%description -l de
Umbauten und reinigt die Repository-Datenbank
 
%prep
 
%setup -q -n %{name}-%{version}  
 
rm -rf $RPM_BUILD_ROOT
 
%install
 
install -d -m 755 $RPM_BUILD_ROOT%{_bindir}

install -m 755 repair-database.sh $RPM_BUILD_ROOT%{_bindir}

mkdir -p %{buildroot}%{_datadir}/applications

cat > %{buildroot}%{_datadir}/applications/%{name}.desktop << EOF
[Desktop Entry]
Version=0.1
Type=Application
Name=Repair Database
Exec=repair-database
Icon=dbrepair.png
Comment=Repair Database
Categories=RepairDatabase;System;X-MandrivaLinux-System-Configuration;X-MandrivaLinux-System-Configuration-Packaging;
Terminal=false
Encoding=UTF-8
StartupNotify=true
EOF
 
#not needed by your script
#%makeinstall_std
 
%files
 %defattr(-,root,root)
 %{_bindir}/%{name}
#if icon installed by default?
 %{_sharedir}/icons/dbrepair.png
%{_datadir}/applications/%{name}.desktop

 
%clean
 rm -rf %{buildroot}
 rm -rf $RPM_BUILD_DIR/%{name}-%{version}
 
%changelog
Thu Nov 03 2011 glamdring <glamdring02 at gmail.com> 0.1-1pclos2011
- created for pclinuxos

From where comes the icon?

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: First package -ba unkown
« Reply #3 on: November 03, 2011, 03:10:27 PM »
The icon is located in the sources folder. If I can't sue those commands to build RPM, than what can I use?

Offline daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3737
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: First package -ba unkown
« Reply #4 on: November 03, 2011, 03:22:14 PM »
The icon is located in the sources folder. If I can't sue those commands to build RPM, than what can I use?

You have pgkutils installed?

You have in your home directory this hidden files
rpmmarcros
rpmrc
?

Then you need only this command
Code: [Select]
rpmbuild -ba repair-database.spec
The icon comes from your source archive, you must install it, too

Code: [Select]
mkdir -p %{buildroot}%{_datadir}/icons
install -m 644 dbrepair.png %{buildroot}%{_datadir}/icons/dbrepair.png

good luck

EDIT:

%{_sharedir}/icons/dbrepair.png this is wrong.
Use
%{_datadir}/icons/dbrepair.png
or
%{_iconsdir}/dbrepair.png
« Last Edit: November 03, 2011, 03:25:07 PM by Leiche »

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: First package -ba unkown
« Reply #5 on: November 03, 2011, 03:32:34 PM »
Okay, thnaks.

If you don't mind can you explain to me why I'm making a directory in _datadir/icons? The icon needs to end up in /usr/share/icons. I guess I still don't understand exactly how an RPM install works.

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15847
  • LXDE! Coffee, Bacon and Cheesecake!
Re: First package -ba unkown
« Reply #6 on: November 03, 2011, 03:41:08 PM »
_datadir/icons is /usr/share/icons.     

Offline daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3737
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: First package -ba unkown
« Reply #7 on: November 03, 2011, 03:42:24 PM »
_datadir/icons is /usr/share/icons.     

you make an test package in your home directory, and so you must say, where what must install. And if no icon directory available, so you must generate it before you can install your icon inside  ;)
This is the magic of rpm.

If you have generate your package. So use
Code: [Select]
apt-get install <your package.rpm> to test your package.

Or install rpm-installer, to test your package.

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: First package -ba unkown
« Reply #8 on: November 03, 2011, 03:45:48 PM »
_datadir/icons is /usr/share/icons.     

Okay, never would have guessed that. I had changed it to _sharedir assuming the _datadir was for a folder named data.

I'm getting error to many names for line 20:
Code: [Select]
error: line 20: Too many names: %description Rebuilds and cleans the repository database

Offline daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3737
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: First package -ba unkown
« Reply #9 on: November 03, 2011, 03:49:02 PM »
_datadir/icons is /usr/share/icons.    

Okay, never would have guessed that. I had changed it to _sharedir assuming the _datadir was for a folder named data.

I'm getting error to many names for line 20:
Code: [Select]
error: line 20: Too many names: %description Rebuilds and cleans the repository database

see my second post, i edit a little your specfile, use it, and change icon install, it should work.

You get this error, while %description and your <description> is on the same line.
It must wrote
%description
Rebuilds and cleans the repository database
« Last Edit: November 03, 2011, 03:51:32 PM by Leiche »

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: First package -ba unkown
« Reply #10 on: November 03, 2011, 03:51:38 PM »
_datadir/icons is /usr/share/icons.    

Okay, never would have guessed that. I had changed it to _sharedir assuming the _datadir was for a folder named data.

I'm getting error to many names for line 20:
Code: [Select]
error: line 20: Too many names: %description Rebuilds and cleans the repository database

see my second post, i edit a little your specfile, use it, and change icon install, it should work

I did use your edit, but I still get the error in line 20.

I updated the code to the most recent version.

Offline daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3737
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: First package -ba unkown
« Reply #11 on: November 03, 2011, 04:05:05 PM »
_datadir/icons is /usr/share/icons.    


Okay, never would have guessed that. I had changed it to _sharedir assuming the _datadir was for a folder named data.

I'm getting error to many names for line 20:
Code: [Select]
error: line 20: Too many names: %description Rebuilds and cleans the repository database


see my second post, i edit a little your specfile, use it, and change icon install, it should work


I did use your edit, but I still get the error in line 20.

I updated the code to the most recent version.

Okay maybe wrong (Zeilensprung)

Use this script
Code: [Select]
%define prefix /usr
%define name repair-database
%define version 0.1
%define release %mkrel 1
%define url http://www.pclinuxos.com/forum/index.phptopic,85630.0.html
Name:           %{name}
Version:       %{version}
Release:       %{release}
License:       GPL
Group:         System/Configuration  
URL:           %{url}
Source:        %{name}-%{version} .tar.xz      
Summary:       The script rebuilds and cleans the repository database according to Texstars requirements.
Summary(de):   Das Skript baut und reinigt die Repository-Datenbank nach Texstars Anforderungen.  
BuildRoot:     %{_tmppath}/%{name}-buildroot      
Requires:      yad
Obsoletes:     %name < %version

 
%description
Rebuilds and cleans the repository database
 
#german
%description -l de
Umbauten und reinigt die Repository-Datenbank
 
%prep
 
%setup -q -n %{name}-%{version}  
 
rm -rf $RPM_BUILD_ROOT
 
%install
#script, or bin file
install -d -m 755 $RPM_BUILD_ROOT%{_bindir}
install -m 755 repair-database.sh $RPM_BUILD_ROOT%{_bindir}
#desktop file
mkdir -p %{buildroot}%{_datadir}/applications
cat > %{buildroot}%{_datadir}/applications/%{name}.desktop << EOF
[Desktop Entry]
Version=0.1
Type=Application
Name=Repair Database
Exec=repair-database
Icon=dbrepair.png
Comment=Repair Database
Categories=RepairDatabase;System;X-MandrivaLinux-System-Configuration;X-MandrivaLinux-System-Configuration-Packaging;
Terminal=false
Encoding=UTF-8
StartupNotify=true
EOF
#icon
mkdir -p %{buildroot}%{_datadir}/icons
install -m 644 dbrepair.png %{buildroot}%{_datadir}/icons/dbrepair.png
 
%files
%defattr(-,root,root)
%{_bindir}/%{name}
%{_datadir}/icons/dbrepair.png
%{_datadir}/applications/%{name}.desktop

 
%clean
 rm -rf %{buildroot}
 rm -rf $RPM_BUILD_DIR/%{name}-%{version}
 
%changelog
Thu Nov 03 2011 glamdring <glamdring02 at gmail.com> 0.1-1pclos2011
- created for pclinuxos

best is kwrite or gedit for specfiles

EDIT:
fixed share to data
« Last Edit: November 03, 2011, 04:06:50 PM by Leiche »

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: First package -ba unkown
« Reply #12 on: November 03, 2011, 04:16:09 PM »
I see what you did, it was my own fault, I changed those thinking when I copied the commands I copied them down wrong.

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: First package -ba unkown
« Reply #13 on: November 03, 2011, 04:19:35 PM »
New problem  ::)
Code: [Select]
[glamdring@localhost SPECS]$ rpmbuild -ba repair-database.spec
Executing(%prep): /bin/sh -e /home/glamdring/src/tmp/rpm-tmp.j8kSmU
+ umask 022
+ cd /home/glamdring/src/rpm/BUILD
+ '[' 1 -eq 1 ']'
+ '[' 1 -eq 1 ']'
+ '[' 1 -eq 1 ']'
+ cd /home/glamdring/src/rpm/BUILD
+ rm -rf repair-database-0.1
+ /usr/bin/xz -dc /home/glamdring/src/rpm/SOURCES/repair-database-0.1.tar.xz
+ /bin/tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd repair-database-0.1
/home/glamdring/src/tmp/rpm-tmp.j8kSmU: line 37: cd: repair-database-0.1: No such file or directory
error: Bad exit status from /home/glamdring/src/tmp/rpm-tmp.j8kSmU (%prep)


RPM build errors:
    Bad exit status from /home/glamdring/src/tmp/rpm-tmp.j8kSmU (%prep)

Offline daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3737
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: First package -ba unkown
« Reply #14 on: November 03, 2011, 04:24:50 PM »
 ;)
How you compress your archive?

Create a folder, and rename it repair-database-0.1.
Copy all your files inside (script, and icon)
Compress the folder as repair-database-0.1.tar.xz