How can I repack initramfs image on RHEL7? - redhat

On RHEL 7 the initramfs image file format changed. To unpack the image the skipcpio is needed. for example
/usr/lib/dracut/skipcpio /boot/initramfs-3.10.0-957.el7.x86_64.img | gunzip -c | cpio -idmv
I succeeded to unpack the image with the command above but I cannot pack it back.
The old way (like it was on RHEL 6) is not working (
find . | cpio -o -c | gzip -9 > /boot/new.img
Is it possible to pack the image back on RHEL7?
Thanks

I got a solution when RHEL7 has the .img file packed in more complex way. Hints to its structure were described in https://ahelpme.com/linux/tips/unpack-centos-7-initramfs-file-with-and-without-dracut-skipcpio/, however there were no instructions for repacking after modification. Here I show the whole process:
cd /tmp
rm -f tryMe.img
rm -f initramfs-tmp.img
rm -rf cc
rm -f modified.gz
mkdir cc
cd cc
cat /boot/initramfs-3.10.0-1062.4.1.el7.x86_64.img | cpio -idmv # note number of blocks in
# output; I assume 4976
find . | cpio -o -H newc > /tmp/tryMe.img
rm -rf *
dd if=/boot/initramfs-3.10.0-1062.4.1.el7.x86_64.img of=../initramfs-tmp.img bs=512 skip=4976
zcat ../initramfs-tmp.img | cpio -idm
find . | cpio --create --format='newc' > /tmp/modified
gzip -9 /tmp/modified
cat /tmp/modified.gz >> /tmp/tryMe.img
#backup your original somehow and then
mv /tmp/tryMe.img /boot/initramfs-3.10.0-1062.4.1.el7.x86_64.img

The packing is the same as old Red Hat Enterprise Linux (RHEL) versions:
find . | cpio -o -H newc > ../initramfsFile
gzip -c ../initramfsFile > initramfsFils.img

Related

RPM with bash skript

Pls answer me 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
Try it make rpmbuild but have fehler when start rpmbuild read skript what i try put

Generate a file hash similar to the one output by nix-prefetch-url

Suppose i've got a zip file available under some URL. I need to get its hash, which should be identical to the one output by nix-prefetch-url --unpack <URL>, but without a working Nix installation. How can one do it?
Seems there is no easy way, as nix-prefetch-url adds the file to the store. More details here: https://discourse.nixos.org/t/generate-a-file-hash-similar-to-the-one-output-by-nix-prefetch-url/19907 (many thanks to prompt and thorough community member's response)
Use Docker.
Demo:
$ nix-prefetch-url --unpack https://github.com/hraban/git-hly/archive/06ff628d5f2b02d1a883c94b01d58187d117f4f3.tar.gz
path is '/nix/store/gxx1pfp19s3a39j6gl0xw197b4409cmp-06ff628d5f2b02d1a883c94b01d58187d117f4f3.tar.gz'
164gyvpdm6l6rdvn2rwjz95j1jz0w2igcbk9shy862sdx2rdw9hn
$ # Or .zip: it's the same, because of --unpack:
$ nix-prefetch-url --unpack https://github.com/hraban/git-hly/archive/06ff628d5f2b02d1a883c94b01d58187d117f4f3.zip
path is '/nix/store/1bpjlzknnmq1x3hq213r44jwag1xkaqs-06ff628d5f2b02d1a883c94b01d58187d117f4f3.zip'
164gyvpdm6l6rdvn2rwjz95j1jz0w2igcbk9shy862sdx2rdw9hn
Download to a local directory
$ cd "$(mktemp -d)"
$ curl -sSL --fail https://github.com/hraban/git-hly/archive/06ff628d5f2b02d1a883c94b01d58187d117f4f3.tar.gz | tar xz
$ cd *
And test it:
$ # Using the modern nix command:
$ nix hash path --base32 .
164gyvpdm6l6rdvn2rwjz95j1jz0w2igcbk9shy862sdx2rdw9hn
$ # Or the same, using nix-hash:
$ nix-hash --type sha256 --base32 .
164gyvpdm6l6rdvn2rwjz95j1jz0w2igcbk9shy862sdx2rdw9hn
Same in Docker:
$ docker run --rm -v "$PWD":/data nixos/nix nix --extra-experimental-features nix-command hash path --base32 /data
164gyvpdm6l6rdvn2rwjz95j1jz0w2igcbk9shy862sdx2rdw9hn
$ docker run --rm -v "$PWD":/data nixos/nix nix-hash --type sha256 --base32 /data
164gyvpdm6l6rdvn2rwjz95j1jz0w2igcbk9shy862sdx2rdw9hn
P.S.: I'm not a huge fan of nix-prefetch-url's default output (base32). The default output of nix hash path is better, if you can use it:
$ nix hash path .
sha256-FibesuhNC4M81Gku9qLg4MsgS/qSZ2F3y4aa2u72j5g=
$ # Sanity check:
$ nix-hash --type sha256 --to-base32 $(<<<"FibesuhNC4M81Gku9qLg4MsgS/qSZ2F3y4aa2u72j5g=" base64 -d | hexdump -v -e '/1 "%02x"' )
164gyvpdm6l6rdvn2rwjz95j1jz0w2igcbk9shy862sdx2rdw9hn

PostgreSQL - HyperLogLog extension not found

Can someone explain in a better way (well, in a way for dummies to understand), or more correctly how to install HyperLogLog hll extension for PostgreSQL on my Mac M1 machine.
When running CREATE EXTENSION hll;
I get:
Query 1 ERROR: ERROR: could not open extension control file "/opt/homebrew/share/postgresql/extension/hll.control": No such file or directory
I am new at this, so this documentation https://github.com/citusdata/postgresql-hll did not helped me a lot.
I installed all other extensions that I need except this one..
When typing which postgres I get:
/opt/homebrew/bin/postgres
And version: postgres (PostgreSQL) 14.3
I saw about configuring PG_CONFIG but I do not understand what exactly I should be doing here?
I will appreciate the help and I hope that this post will be of use for other dummies as I. :)
We can simplify the script above and execute it inline by copying and pasting all of the following into your terminal:
> yes |
#!/bin/bash
# download latest release
curl -s https://api.github.com/repos/citusdata/postgresql-hll/releases/latest \
| grep '"tarball_url":' \
| sed -E 's/.*"([^"]+)".*/\1/' \
| xargs curl -o package.tar.gz -L
# extract to new hll directory
mkdir hll && tar xf package.tar.gz -C hll --strip-components 1
# build and install extension to postgres extensions folder
cd hll
make
make install
# remove hll directory
cd ../
rm -r ./hll
# connect to PostgreSQL and install extension
psql -U postgres -c "CREATE EXTENSION hll;"
I wrote the script for myself to get the last package and install it.
I build it by using make.
# check if Makefile installed
make -v
# download latest release
curl -s https://api.github.com/repos/citusdata/postgresql-hll/releases/latest \
| grep '"tarball_url":' \
| sed -E 's/.*"([^"]+)".*/\1/' \
| xargs curl -o package.tar.gz -L
# extract to hll directory
mkdir hll && tar xf package.tar.gz -C hll --strip-components 1
cd hll
# build and instll extension to postgres extensions folder
make
make install
# remove hll directory
cd ../
rm -r ./hll
# connect to PostgreSQL
psql -U postgres
# install extension in your DB
CREATE EXTENSION hll;

How to stop or uninstall screenly on raspberry pi?

As I am implementing digital signage with Dell Monitor.
First thing as I already google there is no option to stop or uninstall screenly & get back to raspberry pi desktop.
I want to know, how we can do that?
pi#raspberrypi ~ $ /opt/vc/bin/tvservice -s
state 0x120016 [DVI DMT (4) RGB full 4:3], 640x480 # 60Hz, progressive
My monitor maximum resolution is 1920x1200 with 16:10 aspect ratio, why tvservice giving me above mentioned output?
thanks in advanced,
Bhushan Vaiude
Here is ans:
ps aux | grep creen
less ~/screenly/misc/gtkrc-2.0
less ~/.config/openbox/lxde-rc.xml.bak
less ~/.config/openbox/lxde-rc.xml
less ~/.config/lxpanel/LXDE/panels/panel.bak
less /etc/xdg/lxsession/LXDE/autostart.bak
ulink /etc/supervisor/conf.d/screenly.conf
unlink /etc/supervisor/conf.d/screenly.conf
sudo unlink /etc/supervisor/conf.d/screenly.conf
sudo unlink ~/.gtkrc-2.0
ls -l ~/.config/openbox/lxde-rc.xml
ls -l ~/.config/
unlink ~/.config/openbox/lxde-rc.xml
ls -l ~/.config/
ls -l ~/.config/openbox/lxde-rc.xml
ls -l ~/.config/mv ~/.config/openbox/lxde-rc.xml.bak ~/.config/openbox/lxde-rc.xml
mv ~/.config/openbox/lxde-rc.xml.bak ~/.config/openbox/lxde-rc.xml
ls -l ~/.config/openbox/lxde-rc.xml
ls ~/.config/lxpanel/LXDE/panels/panel
ls ~/.config/lxpanel/LXDE/panels/pane*
mv ~/.config/lxpanel/LXDE/panels/panel.bak ~/.config/lxpanel/LXDE/panels/panel
sudo ls -l /etc/xdg/lxsession/LXDE/autostart
sudo ls -l /etc/xdg/lxsession/LXDE/autostart*
sudo mv /etc/xdg/lxsession/LXDE/autostart.bak /etc/xdg/lxsession/LXDE/autostart
less /etc/lightdm/lightdm.conf
sudo nano /etc/lightdm/lightdm.conf
#comment xserver-command
sudo shutdown -r now
thanks!

iOS DOxygen adding docSet to Xcode Documents

Hey Everyone just having a problem with DOxygen, Ive generated my documentation and its allthere, but i find i am unable to add it to Xcode.
I currently have a script which takes the HTML directory containing all the files, and generates the .docset file.
# Run the makefile. The --silent parameter stops it from spamming us with too much output.
#/Applications/Xcode.app/Contents/Developer/usr/bin/docsetutil
make --silent -C "$DOCSET_OUTPUT/html" install
# Load docset
osascript "$[location of personal library]/Scripts/XcodeLoadDocSet.scpt"
"~/Library/Developer/Shared/Documentation/DocSets/$DOXYGEN_ID.docset"
This should also add the item to xcode, but running it manually reveals a problem..
/Developer/usr/bin/docsetutil index com.[my app].docset
make: /Developer/usr/bin/docsetutil: No such file or directory
make: *** [docset] Error 1
This is what i have atm for the makefile,
DOCSET_NAME=com.[my app].docset
DOCSET_CONTENTS=$(DOCSET_NAME)/Contents
DOCSET_RESOURCES=$(DOCSET_CONTENTS)/Resources
DOCSET_DOCUMENTS=$(DOCSET_RESOURCES)/Documents
DESTDIR=~/Library/Developer/Shared/Documentation/DocSets
XCODE_INSTALL=$(shell xcode-select -print-path)
all: docset
docset:
mkdir -p $(DOCSET_DOCUMENTS)
cp Nodes.xml $(DOCSET_RESOURCES)
cp Tokens.xml $(DOCSET_RESOURCES)
cp Info.plist $(DOCSET_CONTENTS)
tar --exclude $(DOCSET_NAME) \
--exclude Nodes.xml \
--exclude Tokens.xml \
--exclude Info.plist \
--exclude Makefile -c -f - . \
| (cd $(DOCSET_DOCUMENTS); tar xvf -)
$(XCODE_INSTALL)/usr/bin/docsetutil index $(DOCSET_NAME)
rm -f $(DOCSET_DOCUMENTS)/Nodes.xml
rm -f $(DOCSET_DOCUMENTS)/Info.plist
rm -f $(DOCSET_DOCUMENTS)/Makefile
rm -f $(DOCSET_RESOURCES)/Nodes.xml
rm -f $(DOCSET_RESOURCES)/Tokens.xml
install: docset
mkdir -p $(DESTDIR)
cp -R $(DOCSET_NAME) $(DESTDIR)
uninstall:
rm -rf $(DESTDIR)/$(DOCSET_NAME)
always:
If anyone has had a similer problem please let me know.
Cheers
Michael.
With Xcode 4, docsetutil is located under /Applications/Xcode.app/Contents/Developer/usr/bin/