Does the "%defattr" directive affect the "%post" section also in rpm spec file? - package

I have a .spec file with code somewhat like this:
%files
%defattr(-,xyz, xyz)
%verify(md5 size mtime mode) %attr(755, xyz, xyz) /usr/bin/app1
%verify(md5 size mtime mode) %attr(755, xyz, xyz) /usr/bin/app2
%post
mkdir -p /apps/1/logs
mkdir -p /apps/2/logs
mkdir -p /apps/3/logs
mkdir -p /apps/4/logs
mkdir -p /apps/5/logs
ln -sf /usr/bin/app1 /usr/bin/app3
touch /home/xyz/abc.log
will the %defattr also affect the default attributes of files and directories getting created in the post section??

No. You'll need to explicitly chown/chmod anything you do in %post. It's preferred to not have them in %post because things can break that way (like rpm -V). Why wouldn't you want that to be done in %build?

Related

Init build environment within a batch

I'm using a windows batch file to run vxWorks build.
In order to run the build, I need to run the wrenv.exe utility that set up the build environment.
I'm trying the following, but the update operation fails
call C:\WindRiver32\wrenv.exe -p vxworks-6.8
call wrws_update.bat -data "%WORKSPACE%" -l %APP_MODULE% -b build -c %CPU%
How can I force the batch to "remember" the wrenv.exe settings?
The two commands may be combined, like this:
call C:\WindRiver32\wrenv.exe -p vxworks-6.8 wrws_update.bat -data %WORKSPACE% -l %APP_MODULE% -b build -c %CPU%
This will run the command "wrws_update.bat -data %WORKSPACE% -l %APP_MODULE% -b build -c %CPU%", inside the "C:\WindRiver32\wrenv.exe -p vxworks-6.8" shell, returning control upon completion.

extracting and creating ipk files

ipk packages are the intallation packages used by opkg.
I'm trying to extract the contents of one of them and also create my own ipk.
I've read that I should be able to untar them but that is not true.
I've tried:
tar -zxvf mypack.ipk
and I get:
zip: stdin: not in gzip format
I've also tried:
tar -xvf mypack.ipk
and I get:
tar: This does not look like a tar archive
I've found that most of the information on the internet regarding ipk's are inaccurate.
My ipk was generated by bitbake. I'm having a hard time with bitbake and want to avoid using it.
Any ideas on how to extract and how to create ipk files? A simple template with a single package would be useful to have.
I figured it out.
You can extract the main package with the ar x command, then extract the control.tar.gz with the tar -zxf command.
I have tested "ar x package-name.ipk" command but it didn't help
I found bellow command which worked perfectly
tar zxpvf package-name.ipk
This extracts three files:
debian-binary
data.tar.gz
control.tar.gz
use the same command to open data.tar.gz and control.tar.gz files
for more information refer to
https://cognito.me.uk/computers/manual-extractioninstallation-of-ipk-packages-on-gargoyleopenwrt/
You need to create a control file, and then do some archiving using tar and ar. In my case, I was distributing just python scripts, so there was no architecture dependency. You should check the control and Makefile into version control, and delete all the other intermediate files.
Here are the contents of control
Package: my-thing-python
Version: 1.0
Description: python scripts for MyCompany
Section: extras
Priority: optional
Maintainer: John
License: CLOSED
Architecture: all
OE: my-thing-python
Homepage: unknown
Depends: python python-distutils python-pyserial python-curses python-mmap python-ctypes
Source: N/A
Here is my Makefile which sits in the same directory as all my python scripts.
all: my-thing-python.ipk
my-thing-python.ipk:
rm -rf ipk
mkdir -p ipk/opt/my-thing-python
cp *.py ipk/opt/my-thing-python
tar czvf control.tar.gz control
cd ipk; tar czvf ../data.tar.gz .; cd ..
echo 2.0 > debian-binary
ar r my-thing-python.ipk control.tar.gz data.tar.gz debian-binary
clean: FORCE
rm -rf ipk
rm -f control.tar.gz
rm -f data.tar.gz
rm -f my-thing-python.ipk
FORCE:
Extracting with these commands:
Extract the file by running the command:
ar -xv <.ipk file>
Extract the control.tar.gz file by running the command:
tar -zxvf control.tar.gz
data.tar.gz : untar by running the command:
tar –zxvf data.tar.gz
If you want a list of files in an ipk, you can do something like:
#!/bin/sh
for f
do
tar -x -z -f $f ./data.tar.gz -O | tar tvzf -
done
-O is extract to standard output.
ipk files used to be AR (like DPKG), but are now tgz.
I feel that some dpkg utility ought to cope with ipkg files, but I haven't found the right one.

How to replace MacPort's libiconv with Mac's default 64-bit version?

MacPorts installed "libiconv #1.14_0+universal" as a dependency on my system. This happens to be a 32-bit flavor and it started causing issue when I tried to compile a voice recognition software called Simon Listens.
While googling I found out that that Mac actually ships with a 64-bit flavor of libiconv by default and I was able to locate the said files on my system:
$ find /usr/lib -name libiconv*
/usr/lib/libiconv.2.4.0.dylib
/usr/lib/libiconv.2.dylib
/usr/lib/libiconv.dylib
In order to use the system library, the quickest way I could think of was to uninstall MacPort's version of libiconv so that the system's library would end up getting selected as a fallback as it has to present (my guess) somewhere downstairs on the PATH already.
But that failed due to dependecies:
$ sudo port uninstall libiconv #1.14_0+universal
Unable to uninstall libiconv #1.14_0+universal, the following ports depend on it:
...
So now my question is how can I tell MacPort to replace its dependency graph to point to and use the library already on my system?
Another approach to avoid MacPorts libiconv issues would be to build simon against a fresh MacPorts system plus the necessary packages such as cyrus-sasl2, zlib, portaudio and kdesdk4 in a custom location, e. g. /opt/macports-simon.
The following code worked for me on my machine running Mac OS X 10.6.8:
# compile simon on Mac OS X 10.6.8 using MacPorts for the installation of zlib, portaudio and kdesdk4
# http://www.simon-listens.org
# http://sourceforge.net/projects/speech2text/
# get a root shell
sudo -H -i
# prevent idle sleep
pmset -a force sleep 0 displaysleep 0 disksleep 0
mv -i /opt/local /opt/local-off
mv -i /usr/local /usr/local-off
cd /tmp
mkdir buildsimon || exit 1
cd buildsimon || exit 1
# create custom /opt/macports-simon to install zlib, portaudio and kdesdk4
# cf. http://guide.macports.org/#installing.macports.source.multiple
MP_PREFIX='/opt/macports-simon'
unset PATH
export PATH='/bin:/sbin:/usr/bin:/usr/sbin'
curl -L -O https://distfiles.macports.org/MacPorts/MacPorts-2.0.4.tar.bz2
tar -xjf MacPorts-2.0.4.tar.bz2
cd MacPorts-2.0.4 || exit 1
./configure --prefix="${MP_PREFIX}" --with-applications-dir="${MP_PREFIX}/Applications"
make
make install
cd /tmp/buildsimon
unset PATH
export PATH="${MP_PREFIX}/bin:/bin:/sbin:/usr/bin:/usr/sbin"
# get the Portfiles and update the system
port -v selfupdate
# install cyrus-sasl2
port -f uninstall cyrus-sasl2
port clean --all cyrus-sasl2
port extract cyrus-sasl2
cd "$(port dir cyrus-sasl2)"/work/cyrus-sasl-2.1.23
printf '%s\n' H '/\(darwin\[15\]\)/s//\1./g' wq | sudo ed -s config/ltconfig
printf '%s\n' H '/\(darwin\[15\]\)/s//\1./g' wq | sudo ed -s saslauthd/config/ltconfig
cd /tmp/buildsimon
port -f -s install cyrus-sasl2
otool -L /opt/macports-simon/lib/libsasl2.dylib
port -f install zlib
port -f install portaudio
port -f install kdesdk4
port installed zlib portaudio kdesdk4 cyrus-sasl2
# enable dbus with launchd
# http://www.freedesktop.org/wiki/Software/dbus
# open -e dbus-1.5.8/README.launchd
launchctl load -w /Library/LaunchDaemons/org.freedesktop.dbus-system.plist
launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist
sudo -u _mysql mysql_install_db5
sudo port load mysql5-server
# todo: how to configure simon to use /opt/macports-simon directly?
ln -isv "${MP_PREFIX}" /usr/local
cd /tmp/buildsimon
# http://sourceforge.net/projects/speech2text/
curl -L -O http://netcologne.dl.sourceforge.net/project/speech2text/simon/0.3.0/simon-0.3.0.tar.bz2
tar -xjf simon-0.3.0.tar.bz2
cd simon-0.3.0 || exit 1
# Note that /usr/local got symlinked to "${MP_PREFIX}" above!
unset PATH
export PATH='/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin'
# the following commands are taken from simon-0.3.0/build.sh
mkdir build 2> /dev/null
cd build || exit 1
cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ..
# append ${MP_PREFIX}/lib/libiconv.dylib to gcc command in link.txt file
printf '%s\n' H '/\/usr\/bin\/gcc/s|\(.*\)|\1 '"${MP_PREFIX}"'/lib/libiconv.dylib|' wq |
ed -s julius/julius/CMakeFiles/juliusexe.dir/link.txt
# replace gcc option ' -bundle ' with ' -dynamiclib '
egrep -Ilsr -Z -e ' -bundle ' . |
xargs -0 -n 1 /bin/sh -c 'printf "%s\n" H "g/ -bundle /s// -dynamiclib /g" wq | /bin/ed -s "${1}"' argv0
make
touch ./julius/gramtools/mkdfa/mkfa-1.44-flex/*
make
make install
# ldconfig # not needed on Mac OS X
kbuildsycoca4
echo -e "**** Build completed ****\n\nThe executable file \"simon\" is now ready and has been installed.\n\nIssue \"simon\" to start it."
unset PATH
export PATH="${MP_PREFIX}/bin:/bin:/sbin:/usr/bin:/usr/sbin"
otool -L "${MP_PREFIX}/bin/simon"
simon
mv -i /opt/local-off /opt/local
mv -i /usr/local-off /usr/local

tar exclude file pattern

I am trying to create a tar with follwing command:
tar -cvf myFile.tar -X exclude-files.txt myContentDirectory
and my exclude-file has follwing patterns to exclude:
**/*.bak
**/*.db
**/*.html
But i dont see these file types being excluded out in my tar.
What am I doing wrong here?
I found that when i have just one pattern in my exclude-files.txt, lets say only
**/*.bak
it does work. But not with multiple file patterns (EACH ON NEW LINE)
I think this:
*.bak
*.db
*.html
is the correct format for the exclude file if you want to exclude a particular directory you could do:
some-dir/*.db
Also your command should look like this:
tar -cvf myFile.tar -X exclude-files.txt myContentDirectory
Sorry if this answer is a little late.
tar -cO --exclude=*.bak myContentDirectory | tar -O --delete '*.db' | tar -O --delete '*.html' > myFile.tar
See, what you're doing here is creating the tar, but sending it to stdout instead of to a file then piping that into tar to delete the stuff you don't want, one or more times and finally writing the output to a file.
You can even test it first like this:
tar -cO --exclude=*.bak myContentDirectory | tar -O --delete '*.db' | tar -O --delete '*.html' | tar -tv
Which will spit out a list of all the files remaining in the archive.
Most likely the order of the command is incorrect.
tar -cvf myFile.tar -X exclude-files.txt myContentDirectory
should be something like
tar cv -X exclude-files.txt -f myFile.tar myContentDirectory
PS. I haven't looked into the filters itself. Most likely order of the parameters is the issue.
If issues is in the filters/patterns - it's easier to test one by one with --exclude option.

Required help in make file

i just want to implement below statement
"if bin folder is not available in current directory then make new bin folder &
if bin folder is available then its do nothing"
can anybody give me any idea how can i do this?
EDIT :
i dont want any error like
mkdir: cannot create directory `./bin `./bin': File exists
You can just do this:
-mkdir ./bin
If ./bin already exists then mkdir will fail silently, otherwise it will create the directory.
Use a rule like this:
bin:
mkdir bin
Then instead of writing mkdir bin as part of other rules, make them depend on the bin rule. The bin rule will only be executed if bin does not exist.
For your requirement you can use the rule as follows:
bindir:
if [ ! -d bin ];then \
mkdir bin; \
fi
Please note that if statement checks for existence of directory named bin in the current directory where makefile resides, if directory named bin does not exist then it will create it, if it exists it does nothing, but if there is a regular file (not a directory) with the name bin exists then this rule will fail.
Suggest you to use a variable say BINDIR to store the value of your "bin" directory as that is the general norm followed, it is good for maintenance of makefile.
BINDIR:=bin
bindir:
if [ ! -d $(BINDIR) ];then \
mkdir $(BINDIR); \
fi

Resources