Outils pour utilisateurs

Outils du site


blog

Utiliser Git pour vos logos en SVG

Voir http://w.xuv.be/projects/design_with_git

Faire du diffing graphique (oui ! pas en texte) avec Git sur des images vectorielle en SVG

compare.py

#!/usr/bin/env python
import sys, os
 
inkscape = "inkscape"
 
local = sys.argv[1]
remote = sys.argv[2]
tempdir = "/home/markv/gittemp/"
localpng = tempdir+"local.png"
remotepng = tempdir+"remote.png"
 
if(not (remote.endswith(".svg") and (local != "/dev/null"))):
    os.system("xxdiff %s %s" % (local, remote))
else:
    os.system(inkscape+" "+local+" --export-png="+localpng+" -w600 -h900 -C -bffffff -y1.0")
    os.system(inkscape+" "+remote+" --export-png="+remotepng+" -w600 -h900 -C -bffffff -y1.0")
    os.system("compare "+localpng+" "+remotepng+" - | display")
    os.remove(localpng)
    os.remove(remotepng)

Ajoutez dans votre .gitconfig (adapter le chemin)

~/.gitconfig

[difftool "compare"]
        cmd = "/home/USER/bin/compare.py $LOCAL $REMOTE - | display"

Puis par exemple

git difftool -y -t compare
2025/03/24 15:06

Note commande unzip zip

unzip

$ unzip -l plop.zip

Archive:  plop.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
       39  2015-01-22 17:27   mimetype
      273  2015-01-22 17:27   layout-cache
   921513  2015-01-22 17:27   ObjectReplacements/Obj101
   921513  2015-01-22 17:27   ObjectReplacements/Obj100
    10265  2015-01-22 17:27   ObjectReplacements/Object 1
     1655  2015-01-22 17:27   meta.xml
   233249  2015-01-22 17:27   content.xml
   931840  2015-01-22 17:27   Obj100
   135587  2015-01-22 17:27   styles.xml
      899  2015-01-22 17:27   manifest.rdf
    10111  2015-01-22 17:27   settings.xml
        0  2015-01-22 17:27   Configurations2/toolpanel/
        0  2015-01-22 17:27   Configurations2/statusbar/
        0  2015-01-22 17:27   Configurations2/popupmenu/
        0  2015-01-22 17:27   Configurations2/images/Bitmaps/
        0  2015-01-22 17:27   Configurations2/toolbar/
        0  2015-01-22 17:27   Configurations2/progressbar/
        0  2015-01-22 17:27   Configurations2/floater/
        0  2015-01-22 17:27   Configurations2/accelerator/current.xml
        0  2015-01-22 17:27   Configurations2/menubar/
   931840  2015-01-22 17:27   Obj101
     3765  2015-01-22 17:27   Thumbnails/thumbnail.png
        0  2015-01-22 17:27   Object 1/Configurations2/menubar/
        0  2015-01-22 17:27   Object 1/Configurations2/statusbar/
        0  2015-01-22 17:27   Object 1/Configurations2/toolbar/
        0  2015-01-22 17:27   Object 1/Configurations2/progressbar/
        0  2015-01-22 17:27   Object 1/Configurations2/images/Bitmaps/
        0  2015-01-22 17:27   Object 1/Configurations2/popupmenu/
        0  2015-01-22 17:27   Object 1/Configurations2/accelerator/current.xml
        0  2015-01-22 17:27   Object 1/Configurations2/floater/
        0  2015-01-22 17:27   Object 1/Configurations2/toolpanel/
     3711  2015-01-22 17:27   Object 1/settings.xml
    10400  2015-01-22 17:27   Object 1/content.xml
     7579  2015-01-22 17:27   Object 1/styles.xml
     2455  2015-01-22 17:27   META-INF/manifest.xml
---------                     -------
  4126694                     35 files
$ unzip -Z1 plop.zip
mimetype
layout-cache
ObjectReplacements/Obj101
ObjectReplacements/Obj100
ObjectReplacements/Object 1
meta.xml
content.xml
Obj100
styles.xml
manifest.rdf
settings.xml
Configurations2/toolpanel/
Configurations2/statusbar/
Configurations2/popupmenu/
Configurations2/images/Bitmaps/
Configurations2/toolbar/
Configurations2/progressbar/
Configurations2/floater/
Configurations2/accelerator/current.xml
Configurations2/menubar/
Obj101
Thumbnails/thumbnail.png
Object 1/Configurations2/menubar/
Object 1/Configurations2/statusbar/
Object 1/Configurations2/toolbar/
Object 1/Configurations2/progressbar/
Object 1/Configurations2/images/Bitmaps/
Object 1/Configurations2/popupmenu/
Object 1/Configurations2/accelerator/current.xml
Object 1/Configurations2/floater/
Object 1/Configurations2/toolpanel/
Object 1/settings.xml
Object 1/content.xml
Object 1/styles.xml
META-INF/manifest.xml
Vérifier l'intégrité
unzip -t plop.zip
 
unzip -qt plop.zip
Décompression
unzip plop.zip

zip

Créer une archive / compresser un dossier

zip -r plop.zip dir1/ dir2/

Comparaison /diff

zipcmp file1.zip file2.zip
pkgdiff -hide-unchanged file1.zip file2.zip
2025/03/24 15:06

Un MakeFile pour rpmbuild

Voir aussi :

Makefile

clean:  SHELL:=/bin/bash
 
build:  SHELL:=/bin/bash
 
 
FicSpec = $(shell echo *.spec)
RpmName = $(shell grep -e '^%define name' $(FicSpec) |awk '{print $$3}')
RpmVersion = $(shell grep -e '^%define version' $(FicSpec) |awk '{print $$3}')
RpmRelease = $(shell grep -e '^%define release' $(FicSpec) |awk '{print $$3}')
StringRpmFullname = $(RpmName)-$(RpmVersion)-$(RpmRelease).$(shell uname -m)
 
all:    build clean
 
clean:
        rm -rf $$HOME/rpmbuild
 
cleanall:       clean
        rm -f *.rpm
 
copy:   cleanall
        mkdir -p $$HOME/rpmbuild/{BUILDROOT,SPECS}
        mkdir -p $$HOME/rpmbuild/BUILDROOT/$(StringRpmFullname)
        cp -a ROOT/* $$HOME/rpmbuild/BUILDROOT/$(StringRpmFullname)
        cp -p $(FicSpec) ~/rpmbuild/SPECS/
 
build:  copy
        rpmbuild -bb ~/rpmbuild/SPECS/*.spec
        mv  ~/rpmbuild/RPMS/*/*.rpm .

Le clean se fait bien avant, mais pas après le build.

C'est comme si :

all:    build clean

Etait

all:    build

Solution :

Makefile

clean:  SHELL:=/bin/bash
 
build:  SHELL:=/bin/bash
 
 
FicSpec = $(shell echo *.spec)
RpmName = $(shell grep -e '^%define name' $(FicSpec) |awk '{print $$3}')
RpmVersion = $(shell grep -e '^%define version' $(FicSpec) |awk '{print $$3}')
RpmRelease = $(shell grep -e '^%define release' $(FicSpec) |awk '{print $$3}')
StringRpmFullname = $(RpmName)-$(RpmVersion)-$(RpmRelease).$(shell uname -m)
 
all:    build cleanagain
 
clean:
        rm -rf $$HOME/rpmbuild
 
cleanall:       clean
        rm -f *.rpm
 
cleanagain:
        ${MAKE} clean
 
copy:   cleanall
        mkdir -p $$HOME/rpmbuild/{BUILDROOT,SPECS}
        mkdir -p $$HOME/rpmbuild/BUILDROOT/$(StringRpmFullname)
        cp -a ROOT/* $$HOME/rpmbuild/BUILDROOT/$(StringRpmFullname)
        cp -p $(FicSpec) ~/rpmbuild/SPECS/
 
build:  copy
        rpmbuild -bb ~/rpmbuild/SPECS/*.spec
        mv  ~/rpmbuild/RPMS/*/*.rpm .

Exemple avec le paquet Python mycli

mkdir -p ~/rpm/ROOT
cd ~/rpm

Déposez le Makefile dans ~/rpm/

~/rpm/mycli.spec

%define name mycli
%define version 1.21.1
%define release 1
%define debug_package %{nil}

Summary:        CLI for MySQL/MariaDB
Name: %{name}
Version: %{version}
Release: %{release}
Vendor: NC


Group:          Database
License:        MIT License
URL:            https://www.mycli.net
Source0:        https://github.com/dbcli/mycli

BuildRequires:  rpm-build
Requires:       python38
#BuildArch:     noarch

%description
This is a command line interface for MySQL, MariaDB, and Percona with
auto-completion and syntax highlighting. The CLI is also capable of pretty
printing tabular data.

#%post
#set -e

%doc


#%changelog

%files
%defattr(755,root,root,644)
export http_proxy=http://127.0.0.1:3128
export https_proxy=http://127.0.0.1:3128
 
pip3 install --user mycli
mkdir -p ~/rpm/ROOT/opt/mycli
cp -a ~/.local/* ~/rpm/ROOT/opt/mycli/
 
 
mkdir -p ~/rpm/ROOT/usr/local/bin/
 
find /home/etudes/rpm/ROOT/ -type f -name "*.pyc" -delete

~/rpm/ROOT/usr/local/bin/mycli

#!/bin/sh
 
env PYTHONPATH=/opt/mycli/lib/python3.8/site-packages/ /opt/mycli/bin/mycli "$@"
cd ~/rpm/ROOT
find . -type f |sed -e 's/^\.//' >> ../mycli.spec
 
cd ~/rpm/
make

Pb

did you mean TAB instead of 8 spaces?
$ make           
Makefile:18: *** missing separator (did you mean TAB instead of 8 spaces?).  Stop.
Solution
sed -i.bak -e 's/^[ ]\+/\t/g' Makefile
2025/03/24 15:06

Umask par defaut - Droits des fichiers par defaut

Pour Debian Jessie

Voir :

Voir aussi :

/etc/login.defs

#UMASK          022
UMASK           027

/etc/pam.d/common-session

session optional pam_umask.so

Infos

umask 27
umask -S

Source : http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html

umask Niveau de sécurité Permission effectives (sur les dossiers)
022 Permissif 755
026 Modéré 751
027 Modéré 750
077 Sévère 700

Changer le umask par défaut d'un utilisateur

Voir http://stackoverflow.com/questions/10220531/how-to-set-system-wide-umask

Il est possible d'utiliser

  • le champ GECOS de /etc/passwd
  • de modifier le fichier .profile, .barshrc etc… de l'utilisateur
  • d'utiliser pam

Champ GECOS de /etc/passwd

#chfn --other='umask=002' username
chfn -o 'umask=0002' username

NOTE : A tester en console tty & xterm, et aussi en scp, sftp.

Changer le umask pour un service Systemd

/etc/systemd/system/plop.service

[Service]
UMask=006

https://ask.fedoraproject.org/en/question/7148/setting-apaches-umask-not-working-in-fedora-16-and-17/

/etc/systemd/system/httpd.service

.include /lib/systemd/system/httpd.service
[Service]
UMask = 0002

Autres

Exemple
source /var/lib/awx/venv/ansible/bin/activate
umask 0022
pip install --upgrade pywinrm
deactivate
2025/03/24 15:06

Ultra fast reboot

Technique pas recommandé

Voir

Source article complet :

echo 1 > /proc/sys/kernel/sysrq 
echo b > /proc/sysrq-trigger

Ultra fast shutdown

echo 1 > /proc/sys/kernel/sysrq 
echo o > /proc/sysrq-trigger

Autres

last |head
root     pts/0        192.168.3.81    Thu May 11 09:19   still logged in
reboot   system boot  3.10.0-327.el7.x Thu May 11 09:17 - 09:24  (00:07)
process  pts/0        192.168.3.81    Wed May 10 16:42 - down   (00:00)
root     pts/0        192.168.3.81    Wed May 10 16:34 - 16:42  (00:07)
reboot   system boot  3.10.0-327.el7.x Wed May 10 16:31 - 16:42  (00:10)
process  pts/0        192.168.3.81    Wed May 10 16:30 - 16:30  (00:00)
root     pts/0        192.168.3.81    Wed May 10 16:28 - 16:29  (00:01)
reboot   system boot  3.10.0-327.el7.x Wed May 10 16:27 - 16:42  (00:15)
root     pts/0        192.168.3.81    Wed May 10 16:19 - crash  (00:08)
reboot   system boot  3.10.0-327.el7.x Wed May 10 16:15 - 16:42  (00:26)
last -x shutdown
shutdown system down  3.10.0-327.el7.x Wed May 10 16:42 - 09:17  (16:34)
shutdown system down  3.10.0-327.el7.x Fri May  5 18:17 - 09:04 (3+14:46)
shutdown system down  3.10.0-327.el7.x Wed Apr  5 16:09 - 15:07 (29+22:58)
systemctl mask sleep.target suspend.target
uptime
ps -p 1 -o stime
lastb
chmod +s /sbin/halt
chmod +s /sbin/reboot

Autres

exec /sbin/init
2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki