Pls answer me and hope my question not so stupid but i first time put inside rpm bash skrip. May someone can sent link or tip what i must coorrect in my .spec
This rpm pakage must make just two thing - copy in linux folder /bin/ one file(inet.dbg) and next when cp make must start bash skrip for check library for this file.
This my bash skript
#!/bin/bash
ldd inet.dbg > t.t
ERR=`grep -i "not" t.t | wc -l`
if [[ $ERR -gt 0 ]]; then
grep -i "not" t.t > erg.e
echo "Die folgenden Bibliotheken wurden nicht gefunden:"
cat erg.e
rm t.t erg.e
else
ls -a ss.tar &> t.t
if [[ $? -eq 0 ]]; then
echo alles ok
else
echo no
fi
fi '
This .spec
# %_topdir and %_tmppath are defined in ~/.rpmmacros
%define name inetdbg
%define version 0.1
%define release 1
%define buildroot %{_tmppath}/%{name}-%{version}-%{release}
%define tarfile %{tarversion}.tar
%define installscript /home/adis/rpmbuild/SOURCES/skript.sh
Name: %{name}
Version: %{version}
Release: %{release}
BuildArch: noarch
Summary: adisc
License: -
Source1: %{installscript}
Source2: /home/adis/rpmbuild/SOURCES/inetdbg.tar.xz
BuildRoot: %{_builddir}/%{name}-root
%description
Tested RPM
%prep
%build
%install
mkdir -p %{buildroot}%{_bindir}
install -D -pm 755 %{SOURCE2} %{buildroot}/bin/inetdbg.tar.xz
cp -a %{installscript} %{buildroot}%{_bindir}/
chmod a+x %{buildroot}%{_bindir}/%{installscript}
%files
%{_bindir}/%{installscript}
%{SOURCE2}
%post
%{_bindir}%{installscript}
%clean
[ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT}
%changelog
* 25 Jan 2023 <user>
- Add script.sh
- Add definit
Related
I have two servers, one with Nexus Repository and one with JFrog Artifactory OSS.
I would like to migrate to JFrog Artifactory but because it is open source there is no tool to migrate. If it were the pro version I could migrate easily.
I need some idea how to migrate from Nexus Repository to JFrog Artifactory OSS.
The way that I accomplished this task was to:
manually download the repos from Nexus. For nexus2 you can directly copy the repos from the filesystem. For nexus3 you will need to use the API. For nexus3 I used a script that I will put below.
Zip the repos into a folder
Upload the zipped file to artifactory with their import tool. Go to admin panel, artifactory, import, repositories.
You should be good to go from there more or less. I had to manually set some permissions and snapshot settings.
WARNING! This script doesn't work 100% you may/will have to modify it. WARNING!
sourceServer=
sourceRepo=
sourceUser=
sourcePassword=
logfile=$sourceRepo-backup.log
outputFile=$sourceRepo-artifacts.txt
# ======== GET DOWNLOAD URLs =========
url=$sourceServer"/service/rest/v1/assets?repository="$sourceRepo
contToken="initial"
while [ ! -z "$contToken" ]; do
if [ "$contToken" != "initial" ]; then
url=$sourceServer"/service/rest/v1/assets?continuationToken="$contToken"&repository="$sourceRepo
fi
echo Processing repository token: $contToken | tee -a $logfile
response=`curl -ksSL -u "$sourceUser:$sourcePassword" -X GET --header 'Accept: application/json' "$url"`
readarray -t artifacts < <( jq '[.items[].downloadUrl]' <<< "$response" )
printf "%s\n" "${artifacts[#]}" > artifacts.temp
sed 's/\"//g' artifacts.temp > artifacts1.temp
sed 's/,//g' artifacts1.temp > artifacts.temp
sed 's/[][]//g' artifacts.temp > artifacts1.temp
cat artifacts1.temp >> $outputFile
#for filter in "${filters[#]}"; do
# cat artifacts.temp | grep "$filter" >> $outputFile
#done
#cat maven-public-artifacts.txt
contToken=( $(echo $response | sed -n 's|.*"continuationToken" : "\([^"]*\)".*|\1|p') )
done
# ======== DOWNLOAD EVERYTHING =========
echo Downloading artifacts...
urls=($(cat $outputFile)) > /dev/null 2>&1
for url in "${urls[#]}"; do
path=${url#http://*:*/*/*/}
dir=$sourceRepo"/"${path%/*}
mkdir -p $dir
cd $dir
pwd
curl -vks -u "$sourceUser:$sourcePassword" -D response.header -X GET "$url" -O >> /dev/null 2>&1
responseCode=`cat response.header | sed -n '1p' | cut -d' ' -f2`
if [ "$responseCode" == "200" ]; then
echo Successfully downloaded artifact: $url
else
echo ERROR: Failed to download artifact: $url with error code: $responseCode
fi
rm response.header > /dev/null 2>&1
cd $curFolder
done
I get below error when tried to run the following breeze build command to build airflow docker. I clone the git airflow master branch to build this image.
Build Command:
./breeze build-image --production-image --python 3.7 --install-airflow-version 2.0.0 --additional-extras=jdbc --additional-python-deps="pandas" --additional-runtime-apt-deps="default-jre-headless"
Error:
Step 83/94 : COPY scripts/docker/install*.sh /scripts/docker/
---> 8363694670bb
Step 84/94 : RUN if [[ ${INSTALL_FROM_PYPI} == "true" ]]; then bash /scripts/docker/install_airflow.sh; fi; if [[ ${INSTALL_FROM_DOCKER_CONTEXT_FILES} == "true" ]]; then bash /scripts/docker/install_from_docker_context_files.sh; fi; if [[ -n "${ADDITIONAL_PYTHON_DEPS}" ]]; then bash /scripts/docker/install_additional_dependencies.sh; fi; find /root/.local/ -name '*.pyc' -print0 | xargs -0 rm -r || true ; find /root/.local/ -type d -name '__pycache__' -print0 | xargs -0 rm -r || true
---> Running in 01f3dd4b7f57
+ [[ true == \t\r\u\e ]]
+ bash /scripts/docker/install_airflow.sh
Installing all packages with constraints and upgrade if needed
ERROR: Invalid requirement: 'apache-airflow[async,amazon,celery,cncf.kubernetes,docker,dask,elasticsearch,ftp,grpc,hashicorp,http,ldap,google,microsoft.azure,mysql,postgres,redis,sendgrid,sftp,slack,ssh,statsd,virtualenv,jdbc]2.0.0'
WARNING: You are using pip version 20.2.4; however, version 21.0.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
The command '/bin/bash -o pipefail -e -u -x -c if [[ ${INSTALL_FROM_PYPI} == "true" ]]; then bash /scripts/docker/install_airflow.sh; fi; if [[ ${INSTALL_FROM_DOCKER_CONTEXT_FILES} == "true" ]]; then bash /scripts/docker/install_from_docker_context_files.sh; fi; if [[ -n "${ADDITIONAL_PYTHON_DEPS}" ]]; then bash /scripts/docker/install_additional_dependencies.sh; fi; find /root/.local/ -name '*.pyc' -print0 | xargs -0 rm -r || true ; find /root/.local/ -type d -name '__pycache__' -print0 | xargs -0 rm -r || true' returned a non-zero code: 1
ERROR: The previous step completed with error. Please take a look at output above
Edit (1):
I tried the same thing on an aws ec2 instance and get the same error. Something looks like is broken on the airflow side. Below is the screenshot.
Replace
--install-airflow-version 2.0.0
with
--install-airflow-version="2.0.0"
So the command is:
./breeze build-image --production-image --python 3.7 --install-airflow-version "2.0.0" --additional-extras=jdbc --additional-python-deps="pandas" --additional-runtime-apt-deps="default-jre-headless"
This worked for me:
./breeze build-image --production-image --python 3.7 --install-airflow-version "==2.0.0" --additional-extras=jdbc --additional-python-deps="pandas" --additional-runtime-apt-deps="default-jre-headless"
had to add the "==".
I wrote a bash script to install multiple packages and calling the bash script in %post. But its not executing the script. I am new to this area and I am not sure what I am missing.
If i manually execute the script its working fine but not through the rpm package.
InstallRPM.spec file:
Name: InstallRPM
Version: 1
Release: 1%{?dist}
Summary: Install RPM Packages
License: Script
URL: NA
Source0: InstallRPM-1.tar.gz
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-buildroot
Requires: /bin/sh
%description
Install RPM files from the /tmp/ folder
%prep
%setup -q
%install
mkdir -p "$RPM_BUILD_ROOT"
cp -R * "$RPM_BUILD_ROOT"
%post
echo "Executing the script /tmp/InstallRPM.sh"
/tmp/InstallRPM.sh
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
/tmp/InstallRPM.sh
Shell Script:
#!/bin/bash
echo "Installing package using YUM"
package="vim zip"
echo "Install $package ..."
if [ "`cat /etc/centos-release | awk '{print $1}'`" == "CentOS" ]
then
{
for i in $package
do
{
#if [ "`/bin/rpm -qa $i | cut -d. -f1`" == "" ]
if [ "`/bin/rpm -qa $i`" == "" ]
then
{
echo "Clean Install"
/usr/bin/sudo /bin/yum install -y $i
}
else
{
echo "Upgrade"
/usr/bin/sudo /bin/yum update -y $i
}
fi
echo "****************"
}
done
}
fi
I ran the rpmbuild -ba InstallRPM.spec and it created a rpm file which I executed but nothing happened. Its getting hung in the below mentioned spot.
Downloading packages:
vim-enhanced-7.4.629-6.el7.x86_64.rpm | 1.1 MB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
^C
You are using rpm the wrong way. Don't install dependencies in a %post script. I suggest you to read the rpm packaging guide first.
You should use Requires in your spec file, like this:
Requires: vim
Requires: zip
#define program installation destination
%define app_destination /opt
%define app_name MY_APP_NAME
%define app_version 2.1
%define app_release 7%{?dist}
%define app_dir %{app_name}-%{app_version}
%define compress_file %{app_dir}.tar.gz
%define app_service_softlink /etc/init.d/%{app_name}
%define app_dir_softlink %{app_destination}/%{app_name}
Name: %{app_name}
Version: %{app_version}
Release: %{app_release}
Summary: MY APP ONE-SENTENCE SUMMARY %{app_version}
# An open source software license
License: GPLv3+
URL: http://www.starscriber.com/
Source0: http://ftp.gnu.org/gnu/%{compress_file}
%description
MY APP DESCRIPTION
%pre
#each time before install/upgrade RPM, check and remove the softlinks provided below
echo "pre..."
if [ -L %{app_service_softlink} ];then
rm %{app_service_softlink}
elif [ -f %{app_service_softlink} ];then
rm %{app_service_softlink}
fi
if [ -L %{app_dir_softlink} ]; then
rm %{app_dir_softlink}
elif [ -d %{app_dir_softlink} ]; then
rmdir %{app_dir_softlink}
fi
%prep
%setup -q
echo "prep..."
# Script commands to "build" the program (e.g. to compile it) and
# get it ready for installing. The program should come with
# instructions on how to do this.
%build
%install
echo "install..."
# uses relative paths
# creates buildroot/destination directory
mkdir -p %{buildroot}%{app_destination}
# copies tar.gz file from source directory to buildroot/destination directory
cp %{_sourcedir}/%{compress_file} %{buildroot}%{app_destination}
# changes directory to buildroot/destination
cd %{buildroot}%{app_destination}
# extracts compression file
tar xf %{compress_file}
# removes the compression file
rm -rf %{compress_file}
cd %{buildroot}%{app_destination}
#invoked after %post when RPM pkg is removal or upgrade
%preun
echo "preun..."
#leftover cleanup
#invoked after %preun when RPM pkg is removal or upgrade
%postun
echo "postun..."
if [ "$1" == "0" ]; then
rm -rf %{app_destination}/%{app_dir}
fi
if [ ! -d %{app_destination}/%{app_dir} ]; then
if [ -L %{app_service_softlink} ]; then
rm %{app_service_softlink}
elif [ -f %{app_service_softlink} ]; then
rm %{app_service_softlink}
fi
if [ -L %{app_dir_softlink} ]; then
rm %{app_dir_softlink}
elif [ -d %{app_dir_softlink} ]; then
rmdir %{app_dir_softlink}
fi
fi
%files
#all files under the provided folder will be gathered up to create RPM pkg
%{app_destination}/%{app_dir}/bin
%{app_destination}/%{app_dir}/conf
%{app_destination}/%{app_dir}/misc
%post
echo "post"
#symbolic link to the new appdir with version
echo "builds new symbolic link for the app folder"
ln -sf %{app_destination}/%{app_dir} %{app_dir_softlink}
echo "builds new symbolic link for the app service"
# make a symbolic for the service file using the new created softlink
ln -sf %{app_destination}/%{app_name}/misc/%{app_name} %{app_service_softlink}
I am trying to create my own RPM package, and here's the SPEC file, it works properly when install(rpm -ivh app-2.1-6.el6.x86_64.rpm), or upgrade(rpm -Uvh app-2.1-7.el6.x86_64.rpm) or remove (rpm -e app-2.1-7.el6.x86_64.rpm)
For RPM package app-2.1-7.el6.x86_64.rpm, the version is 2.1 and release number is 7.
My question is, no matter how I modify the release number, install/upgrade/remove are working properly, but if I modify the version number to 2.2 or 3.2, the previous version folder(/opt/app-2.1) will not be deleted, can anyone help me, how should I delete the previous version folder(/opt/app-2.1) when I update(-Uvh) the RPM package?
The problem is that your package doesn't "own"
the directory /opt/2.1 directory.
Just like tar, rpm will create all "missing" directories
in order to install content on a path.
But on erase, rpm will only remove directories that are
mentioned explicitly in the %files manifest.
Short answer:
If you want rpm --erase to remove a directory path,
the mention in %files.
Shorter anser:
Add
%dir /opt/app-%{version}
to %files. If the directory is empty (i.e. all other files
in /opt/app-%{version} are "owned" and can be removed), the
the "owned /opt/app=%{version} will be removed as well.
I'm trying to build my first RPM, but getting an error. My .rpmmarcos files looks like this:
%packager Your Name
%_topdir /home/snort/test
%_tmppath /home/snort/test/tmp
%_smp_mflags -j3
%__arch_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot
When I run: "rpmbuild -v -bb SPECS/test.spec" I receive this error:
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd test-1
/home/snort/test/tmp/rpm-tmp.55712: line 36: cd: test-1: No such file or directory
error: Bad exit status from /home/snort/test/tmp/rpm-tmp.55712 (%prep)
File rpm-tmp.55712 ends with this:
cd '/home/snort/test/BUILD'
rm -rf 'test-1'
/bin/gzip -dc '/home/snort/test/SOURCES/test-1.c55.tar.gz' | tar -xvvf -
STATUS=$?
if [ $STATUS -ne 0 ]; then
exit $STATUS
fi
cd 'test-1'
I'm guessing rpmbuild does the "rm -rf 'test-1'" to remove any old/un-needed directories, then it untar's the test-1.c55.tar.gz file, then tries to "cd test-1" but the untar command doesn't make the directory so the scripts errors out. I'm not sure what to do now.
My spec file: more SPECS/test.spec
Name: test
Version: 1
Release: .c55
Summary: Just a Test
Group: MyJunk
License: GPL
URL: http://www.somesite.com
Source0: test-1.c55.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description
This is just a test
<br>
%prep
%setup BUILD
%build<br>
%configure<br>
make %{?_smp_mflags}<br>
%install<br>
rm -rf $RPM_BUILD_ROOT<br>
make install DESTDIR=$RPM_BUILD_ROOT
<br>
%clean<br>
rm -rf $RPM_BUILD_ROOT<br>
%files
%defattr(-,root,root,-)
%doc
%changelog
Any ideas?
Thanks for the Help
Gary
RPM (or, to be exact, %setup macro) expects your source tarbal test-1.c55.... to contain the directory test-1.
If the directory there is different, you can fix that by using
%setup -n yourdir
See http://www.rpm.org/max-rpm/s1-rpm-inside-macros.html for more details.