# hellorpm
**Repository Path**: liikii/hellorpm
## Basic Information
- **Project Name**: hellorpm
- **Description**: simple hello world rpm
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-05-23
- **Last Updated**: 2025-05-23
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
### create shell
```
sudo yum install rpm-build gcc make
rpmdev-setuptree
rpmbuild -ba --nodebuginfo helloworld.spec
rpm -ivh ~/rpmbuild/RPMS/x86_64/helloworld-1.0-1.x86_64.rpm
rpm -qlp ~/rpmbuild/RPMS/x86_64/helloworld-1.0-1.x86_64.rpm
rpm -qip ~/rpmbuild/RPMS/x86_64/helloworld-1.0-1.x86_64.rpm
rpm --scripts -qp ~/rpmbuild/RPMS/x86_64/helloworld-1.0-1.x86_64.rpm
```
#### make your repository
```
1. yum install createrepo
2. mkdir /opt/myrepo
3. cp helloworld.rpm /opt/myrepo/
4. createrepo /opt/myrepo
5. /etc/yum.repos.d/myrepo.repo
6. yum makecache
7. yum install helloworld
```
#### myrepo.repo
```
[myrepo]
name=myrepo
baseurl=file:///opt/myrepo
enabled=1
gpgcheck=0
```
#### install log
```
Running transaction
Running scriptlet: helloworld-1.0-1.x86_64 1/1
pretrans section helloworld-1.0
Preparing : 1/1
Running scriptlet: helloworld-1.0-1.x86_64 1/1
pre section helloworld-1.0
Installing : helloworld-1.0-1.x86_64 1/1
Running scriptlet: helloworld-1.0-1.x86_64 1/1
post section helloworld-1.0
posttrans section helloworld-1.0
Verifying : helloworld-1.0-1.x86_64 1/1
Installed:
helloworld-1.0-1.x86_64
Complete!
```
#### upgrade log
```
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Running scriptlet: helloworld-2.0-1.x86_64 1/1
pretrans section helloworld-2.0
Preparing : 1/1
Running scriptlet: helloworld-2.0-1.x86_64 1/2
pre section helloworld-2.0
Upgrading : helloworld-2.0-1.x86_64 1/2
Running scriptlet: helloworld-2.0-1.x86_64 1/2
post section helloworld-2.0
Running scriptlet: helloworld-1.0-1.x86_64 2/2
preun section helloworld-1.0
Cleanup : helloworld-1.0-1.x86_64 2/2
Running scriptlet: helloworld-1.0-1.x86_64 2/2
postun section helloworld-1.0
Running scriptlet: helloworld-2.0-1.x86_64 2/2
posttrans section helloworld-2.0
Verifying : helloworld-2.0-1.x86_64 1/2
Verifying : helloworld-1.0-1.x86_64 2/2
Upgraded:
helloworld-2.0-1.x86_64
Complete!
[root@euler2 ~]#
```
### downgrade log
```
Running transaction
Running scriptlet: helloworld-1.0-1.x86_64 1/1
pretrans section helloworld-1.0
Preparing : 1/1
Running scriptlet: helloworld-1.0-1.x86_64 1/2
pre section helloworld-1.0
Downgrading : helloworld-1.0-1.x86_64 1/2
Running scriptlet: helloworld-1.0-1.x86_64 1/2
post section helloworld-1.0
Running scriptlet: helloworld-2.0-1.x86_64 2/2
preun section helloworld-2.0
Cleanup : helloworld-2.0-1.x86_64 2/2
Running scriptlet: helloworld-2.0-1.x86_64 2/2
postun section helloworld-2.0
Running scriptlet: helloworld-1.0-1.x86_64 2/2
posttrans section helloworld-1.0
Verifying : helloworld-1.0-1.x86_64 1/2
Verifying : helloworld-2.0-1.x86_64 2/2
Downgraded:
helloworld-1.0-1.x86_64
Complete!
```
#### remove log
```
Running transaction
Preparing : 1/1
Running scriptlet: helloworld-1.0-1.x86_64 1/1
preun section helloworld-1.0
Erasing : helloworld-1.0-1.x86_64 1/1
Running scriptlet: helloworld-1.0-1.x86_64 1/1
postun section helloworld-1.0
Verifying : helloworld-1.0-1.x86_64 1/1
Removed:
helloworld-1.0-1.x86_64
Complete!
```
In an RPM spec file, `$1` is a **positional parameter** passed to scriptlets (e.g., `%pre`, `%post`, `%preun`, `%postun`) by RPM during package installation/upgrade/removal. Its value indicates the **current transaction state**. Below is a detailed breakdown:
---
### **1. Meaning of `$1` in Different Scriptlets**
| **Scriptlet** | **`$1` Value** | **Description** |
|---------------|-------------------------|---------------------------------------------------------------------------------|
| `%pre` | `1` (install)
`2` (upgrade) | Before installation: `1` = fresh install, `2` = upgrade. |
| `%post` | `1` (install)
`2` (upgrade) | After installation: `1` = fresh install, `2` = upgrade. |
| `%preun` | `0` (uninstall)
`1` (upgrade) | Before removal: `0` = complete uninstall, `1` = removal due to upgrade. |
| `%postun` | `0` (uninstall)
`1` (upgrade) | After removal: `0` = complete uninstall, `1` = removal due to upgrade. |
---