PDA

View Full Version : How to package wine programs in RPM format for all users



fastrizwaan
5th January 2014, 01:21 AM
I use some wine programs, but always, .wine folder gets messed up and having rpms for wine programs would be neat and tidy way of handing programs. And RPM is the way for fedora!

After seeing Archlinux guys making utorrent package with wine (https://aur.archlinux.org/packages/utorrent/); I thought why not RPM then? It is possible: i tried with notepad++ and Format Factory (the ultimate media converter);

To package a windows program for all users, we need to create separate wine bottles (directories); and we'll make available the bottle in /usr/share/wine-apps folder, so when the user run the program it installs and runs for the user.

http://www.pcfreetime.com/download.html

Let's try this with FormatFactory:



mkbottle.sh


export WINEPREFIX=$HOME/.wine-$1
export WINEARCH=win32
wineboot
echo "export WINEPREFIX=$HOME/.wine-$1" > $1-bottle.sh
echo "WINEPREFIX=$HOME/.wine-$1 wine \"\$1\"" >> $1-bottle.sh
chmod +rx $1-bottle.sh


Now run these commands $HOME


#create a bottle
sh ./mkbottle.sh format_factory ; # create a bottle wine-format_factory
# we'll check for file changes in .local and .wine-format_factory
find .local > localbaseline.dat
find .wine-format_factory > baseline.dat

#Now install the program
#when we run mkbottle.sh it creates format_factory-bottle.sh
./format_factory-bottle.sh ~/Downloads/FFSetup3.2.1.0.exe

#After the program ends, let's find out the new files/folders
find .local > localcurrent.dat
find .wine-format_factory > current.dat

#uncomment below and run to see new files
#diff localcurrent.dat localbaseline.dat
#diff current.dat baseline.dat

#Let's make tar.bz2 files for .local and .wine-format_factory folders
cd $HOME
tar --no-recursion -jcvf Format_Factory.tar.bz2 `diff current.dat baseline.dat |sed "s/<\ //g"|grep "/"|sed 's/ /*/g'|sed 's/\[/*/g'|sed 's/\]/*/g'|sed 's/\./*/g'|sed 's/^*/\./g'`

#desktop files and icons
tar --no-recursion -jcvf Icons_and_Shorctus.tar.bz2 `diff localcurrent.dat localbaseline.dat| sed "s/<\ //g"|grep "/"|sed 's/ /*/g'|sed 's/\[/*/g'|sed 's/\]/*/g'|sed 's/\./*/g'|sed 's/^*/\./g'`

#system registry files
tar --no-recursion -jcvf Registry_Files.tar.bz2 .wine-format_factory/*.reg

#let's move those files to our rpmbuild/SOURCES
mv ~/Format_Factory.tar.bz2 ~/rpmbuild/SOURCES/
mv ~/Icons_and_Shorctus.tar.bz2 ~/rpmbuild/SOURCES
mv ~/Registry_Files.tar.bz2 ~/rpmbuild/SOURCES

we need icon and custom desktop
cp /home/$USER/.local/share/icons/hicolor/64x64/apps/3396_FormatFactory.0.png ~/rpmbuild/SOURCES


Now we need a desktop file: We'll use format_factory.sh to run and install the program for user


FormatFactory.desktop



[Desktop Entry]
Name=FormatFactory
Exec=format_factory.sh
Type=Application
StartupNotify=true
Icon=3396_FormatFactory.0



format_factory.sh


# rizvan is my username, when you make the program you've to replace rizvan with your username HERE

PROG_NAME=format_factory
SRC_DIR=/usr/share/wine-apps/$PROG_NAME
WINE_DIR="$HOME/.wine-$PROG_NAME"

#if the Program is not installed in user's ~/.wine-PROG_NAME then create it
if [ ! -d "$WINE_DIR" ]; then

echo "Initializing..."
#create wine WINE_DIR
export WINEPREFIX="$WINE_DIR"
export WINEARCH=win32
wineboot ; #create bottle

#copy content to users's WINE_DIR
tar -jxf "$SRC_DIR/Format_Factory.tar.bz2" -C "$HOME"
tar -jxf "$SRC_DIR/Icons_and_Shorctus.tar.bz2" -C "$HOME"
tar -jxf "$SRC_DIR/Registry_Files.tar.bz2" -C "$HOME"

#change user from rizvan to $USER
cd $WINE_DIR/drive_c/users
mv rizvan $USER
chown $USER:$USER $USER

#set current user name in the registry files instead of yours truly :-)
sed "s/rizvan/$USER/g" -i $WINE_DIR/user.reg
sed "s/rizvan/$USER/g" -i $WINE_DIR/userdef.reg
sed "s/rizvan/$USER/g" -i $WINE_DIR/system.reg

#remove double desktop file from user's applications
rm -rf $HOME/.local/share/applications/wine/Programs/FormatFactory/

fi

# and run the program

env WINEPREFIX="/home/$USER/.wine-format_factory" wine C:\\\\windows\\\\command\\\\start.exe /Unix ~/.wine-format_factory/drive_c/Program\ Files/FreeTime/FormatFactory/FormatFactory.exe



Ok now to build the RPM, we need to copy all the required files to `/rpmbuild/SOURCES like this:

~/rpmbuild/SOURCES/3396_FormatFactory.0.png
~/rpmbuild/SOURCES/format_factory.sh
~/rpmbuild/SOURCES/FormatFactory.desktop
~/rpmbuild/SOURCES/Format_Factory.tar.bz2
~/rpmbuild/SOURCES/Icons_and_Shorctus.tar.bz2
~/rpmbuild/SOURCES/Registry_Files.tar.bz2

Ok, Now we need SPEC FILE at ~/rpmbuild/SPECS:

format_factory.spec


Name: format_factory
Version: 3.2.1
Release: 2
Summary: Format Factory is a multifunctional media converter.
License: proprietary
Url: http://www.pcfreetime.com/index.html
Group: Applications/Multimedia

BuildRoot: %{_tmppath}/%{name}-%{version}-build

BuildArch: noarch
Requires: wine

Source1: Format_Factory.tar.bz2
Source2: Icons_and_Shorctus.tar.bz2
Source3: Registry_Files.tar.bz2
Source4: format_factory.sh
Source5: FormatFactory.desktop
Source6: 3396_FormatFactory.0.png

%description
Format Factory is a multifunctional media converter.
Provides functions below:
All to MP4/3GP/MPG/AVI/WMV/FLV/SWF.
All to MP3/WMA/AMR/OGG/AAC/WAV.
All to JPG/BMP/PNG/TIF/ICO/GIF/TGA.
Rip DVD to video file , Rip Music CD to audio file.
MP4 files support iPod/iPhone/PSP/BlackBerry format.
Supports RMVB,Watermark, AV Mux.

Format Factory's Feature:
1 support converting all popular video,audio,picture formats to others.
2 Repair damaged video and audio file.
3 Reducing Multimedia file size.
4 Support iphone,ipod multimedia file formats.
5 Picture converting supports Zoom,Rotate/Flip,tags.
6 DVD Ripper.
7 Supports 62 languages

%install
mkdir -p %{buildroot}%{_datadir}/wine-apps/%{name}
mkdir -p %{buildroot}%{_datadir}/pixmaps/
mkdir -p %{buildroot}%{_datadir}/applications/
mkdir -p %{buildroot}%{_bindir}

install -m 444 -D %{SOURCE1} %{buildroot}%{_datadir}/wine-apps/%{name}
install -m 444 -D %{SOURCE2} %{buildroot}%{_datadir}/wine-apps/%{name}
install -m 444 -D %{SOURCE3} %{buildroot}%{_datadir}/wine-apps/%{name}

install -m 755 -D %{SOURCE4} %{buildroot}/usr/bin/
install -m 444 -D %{SOURCE5} %{buildroot}%{_datadir}/applications
install -m 444 -D %{SOURCE6} %{buildroot}%{_datadir}/pixmaps

%clean
rm -rf %{buildroot}


%files
%attr(755,root,root)
%{_bindir}/%{name}.sh
%attr(644,root,root)
%{_datadir}/applications/FormatFactory.desktop
%{_datadir}/pixmaps/3396_FormatFactory.0.png
%{_datadir}/wine-apps/%{name}


%changelog
* Sun Jan 5 2014 Asif Ali Rizvan <fast.rizwaan@gmail.com>
- Initial package.


OK, let's make the RPM:

rpmbuild -ba format_factory.spec

And we shall get:


Wrote: /home/$USER/rpmbuild/SRPMS/format_factory-3.2.1-2.src.rpm
Wrote: /home/$USER/rpmbuild/RPMS/noarch/format_factory-3.2.1-2.noarch.rpm


So let's install and test:

su -c 'yum localinstall -y ~/rpmbuild/RPMS/noarch/format_factory-3.2.1-2.noarch.rpm'

now from gnome shell we can run format factory, it'll take some time for the 1st time only.

Here are my rpms, and the script files: (https://www.dropbox.com/sh/ni8500p6qbcz5ag/xa5JZA86pt)

Checkout my format_factory-3.2.1-3.noarch.rpm (https://www.dropbox.com/s/3fq1u8kg3d0g56a/format_factory-3.2.1-3.noarch.rpm)

fastrizwaan
5th January 2014, 03:23 AM
OK, here's better notepad++ version: bash script to create rpm, download npp.6.5.3.Installer.exe (http://download.tuxfamily.org/notepadplus/6.5.3/npp.6.5.3.Installer.exe)

get sources (https://www.dropbox.com/sh/k6dtr4isy6xmqbv/oGjDcjTVr3)


notepad++_build.sh



mkdir -p ~/npp-rpm
cd
rm -rf .wine-notepad++/
./mkbottle.sh notepad++
find .local > localbaseline.dat
find .wine-notepad++ > baseline.dat
./notepad++-bottle.sh ~/Downloads/npp.6.5.3.Installer.exe
find .local > localcurrent.dat
find .wine-notepad++ > current.dat

tar --no-recursion -jcvf notepad++.tar.bz2 `diff current.dat baseline.dat |sed "s/<\ //g"|grep "/"|sed 's/ /*/g'|sed 's/\[/*/g'|sed 's/\]/*/g'|sed 's/\./*/g'|sed 's/^*/\./g'`

mv notepad++.tar.bz2 ~/npp-rpm

#do not include application desktop shortcuts, we'll make ours
tar --no-recursion -jcvf Icons.tar.bz2 `diff localcurrent.dat localbaseline.dat| sed "s/<\ //g"|grep "/"|sed 's/ /*/g'|sed 's/\[/*/g'|sed 's/\]/*/g'|sed 's/\./*/g'|sed 's/^*/\./g'|sed '/applications/d'`
mv Icons.tar.bz2 ~/npp-rpm

cd ~/.wine-notepad++
tar -jcvf Registry_Files.tar.bz2 *.reg
mv Registry_Files.tar.bz2 ~/npp-rpm


#need big icon
cp ~/.local/share/icons/hicolor/256x256/apps/33E8_notepad++.0.png ~/npp-rpm/notepad++.png


echo "[Desktop Entry]
Name=Notepad++
Exec=notepad++
Type=Application
StartupNotify=true
Icon=notepad++" > ~/npp-rpm/notepad++.desktop

echo "
Name: notepad++
Version: 6.5.3
Release: 6
Summary: Notepad++ is a free source code editor
License: GPL
Url: http://notepad-plus-plus.org/
Group: Applications/Development

BuildRoot: %{_tmppath}/%{name}-build

BuildArch: noarch
Requires: wine

Source1: notepad++.tar.bz2
Source2: Icons.tar.bz2
Source3: Registry_Files.tar.bz2
Source4: notepad++
Source5: notepad++.desktop
Source6: notepad++.png

%description
Notepad++ is a free (as in \"free speech\" and also as in \"free beer\") source code editor and Notepad replacement that supports several languages. Running in the MS Windows environment, its use is governed by GPL License.

Based on the powerful editing component Scintilla, Notepad++ is written in C++ and uses pure Win32 API and STL which ensures a higher execution speed and smaller program size. By optimizing as many routines as possible without losing user friendliness, Notepad++ is trying to reduce the world carbon dioxide emissions. When using less CPU power, the PC can throttle down and reduce power consumption, resulting in a greener environment.

%install
mkdir -p %{buildroot}%{_datadir}/wine-apps/%{name}
mkdir -p %{buildroot}%{_datadir}/pixmaps/
mkdir -p %{buildroot}%{_datadir}/applications/
mkdir -p %{buildroot}%{_bindir}

install -m 444 -D %{SOURCE1} %{buildroot}%{_datadir}/wine-apps/%{name}
install -m 444 -D %{SOURCE2} %{buildroot}%{_datadir}/wine-apps/%{name}
install -m 444 -D %{SOURCE3} %{buildroot}%{_datadir}/wine-apps/%{name}

install -m 755 -D %{SOURCE4} %{buildroot}/usr/bin/
install -m 444 -D %{SOURCE5} %{buildroot}%{_datadir}/applications
install -m 444 -D %{SOURCE6} %{buildroot}%{_datadir}/pixmaps

%clean
rm -rf %{buildroot}


%files
%attr(755,root,root)
%{_bindir}/%{name}
%attr(644,root,root)
%{_datadir}/applications/notepad++.desktop
%{_datadir}/pixmaps/notepad++.png
%{_datadir}/wine-apps/%{name}


%changelog
* Sun Nov 24 2013 Asif Ali Rizvan <fast.rizwaan@gmail.com>
- Initial package.
- fixed format_factory.sh (delete folder path)
" > ~/npp-rpm/notepad++.spec

echo "# rizvan is my username, when you make the program you've to replace rizvan with your username.
PROG_NAME=notepad++
SRC_DIR=/usr/share/wine-apps/\$PROG_NAME
WINE_DIR=\"\$HOME/.wine-\$PROG_NAME\"

#if the Program is not installed in user's ~/.wine-PROG_NAME then create it
if [ ! -d \"\$WINE_DIR\" ]; then

echo \"Initializing...\"
#create wine WINE_DIR
export WINEPREFIX=\"\$WINE_DIR\"
export WINEARCH=win32
wineboot ; #create bottle

#copy content to users's WINE_DIR
tar -jxf \"\$SRC_DIR/\$PROG_NAME.tar.bz2\" -C \"\$HOME\"
tar -jxf \"\$SRC_DIR/Icons.tar.bz2\" -C \"\$HOME\"

#registry files are extracted inside the wine folder
tar -jxf \"\$SRC_DIR/Registry_Files.tar.bz2\" -C \"\$WINE_DIR\"

#change user from rizvan to \$USER
cd \$WINE_DIR/drive_c/users
mv rizvan \$USER
chown \$USER:\$USER \$USER

#set current user in the desktop file instead of yours truly :-)
sed \"s/rizvan/\$USER/g\" -i \$WINE_DIR/user.reg
sed \"s/rizvan/\$USER/g\" -i \$WINE_DIR/userdef.reg
sed \"s/rizvan/\$USER/g\" -i \$WINE_DIR/system.reg


fi

#else run the program #only 1st time this will run

env WINEPREFIX=\"/home/\$USER/.wine-notepad++\" wine C:\\\\windows\\\\command\\\\start.exe /Unix ~/.wine-notepad++/drive_c/Program\ Files/Notepad++/notepad++.exe

" > ~/npp-rpm/notepad++
chmod +rx ~/npp-rpm/notepad++



cp ~/npp-rpm/*.bz2 ~/rpmbuild/SOURCES
cp ~/npp-rpm/*.png ~/rpmbuild/SOURCES
cp ~/npp-rpm/*.desktop ~/rpmbuild/SOURCES
cp ~/npp-rpm/notepad++ ~/rpmbuild/SOURCES

cp ~/npp-rpm/notepad++.spec ~/rpmbuild/SPECS
cd ~/rpmbuild/SPECS
rpmbuild -ba notepad++.spec




Please checkout: notepad++-6.5.3-6.noarch.rpm (https://www.dropbox.com/s/x9epcjd2oo6pbdd/notepad%2B%2B-6.5.3-6.noarch.rpm)