Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
dralley committed Nov 17, 2024
1 parent c2a36e5 commit bbe6d06
Show file tree
Hide file tree
Showing 5 changed files with 396 additions and 2 deletions.
45 changes: 44 additions & 1 deletion src/rpm/headers/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,50 @@ pub const REGULAR_FILE_TYPE: u16 = 0o100000; // bit representation = "100000000
pub const DIR_FILE_TYPE: u16 = 0o040000; // bit representation = "0100000000000000"
pub const SYMBOLIC_LINK_FILE_TYPE: u16 = 0o120000; // bit representation = "1010000000000000"

// @todo: <https://github.com/rpm-rs/rpm/issues/52>
use bitflags::bitflags;

// typedef enum rpmFileTypes_e {
// = 1, /*!< pipe/fifo */
// CDEV = 2, /*!< character device */
// XDIR = 4, /*!< directory */
// BDEV = 6, /*!< block device */
// REG = 8, /*!< regular file */
// LINK = 10, /*!< hard link */
// SOCK = 12 /*!< socket */
// } rpmFileTypes;

bitflags! {
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub struct FileModeFlags: u16 {
const PERMISSIONS_BIT_MASK = 0b0000111111111111; // 0o007777

const SUID_BIT_MASK = 0b0000100000000000; // 0o007777
const SGID_BIT_MASK = 0b0000010000000000; // 0o007777
const STICKY_BIT_MASK = 0b0000001000000000; // 0o007777

const USER_PERM_BIT_MASK = 0b0000000111000000; // 0o007777
const GROUP_PERM_BIT_MASK = 0b0000000000111000; // 0o007777
const OTHER_PERM_BIT_MASK = 0b0000000000000111;

// The set-user-ID bit (setuid bit).

// On execution, set the process’s effective user ID to that of the file. For directories on a few systems, give files created in the directory the same owner as the directory, no matter who creates them, and set the set-user-ID bit of newly-created subdirectories.
// The set-group-ID bit (setgid bit).

// On execution, set the process’s effective group ID to that of the file. For directories on most systems, give files created in the directory the same group as the directory, no matter what group the user who creates them is in, and set the set-group-ID bit of newly-created subdirectories.
// The restricted deletion flag or sticky bit.

// Prevent unprivileged users from removing or renaming a file in a directory unless they own the file or the directory; this is commonly found on world-writable directories like /tmp. For regular files on some older systems, save the program’s text image on the swap device so it will load more quickly when run, so that the image is “sticky”.

const FILE_TYPE_BIT_MASK = 0b1111000000000000; // 0o170000
const REGULAR_FILE_TYPE = 0b1000000000000000; // 0o100000
const DIR_FILE_TYPE = 0b0100000000000000; // 0o040000
const SYMBOLIC_LINK_FILE_TYPE = 0b1010000000000000; // 0o120000
}
}



impl From<u16> for FileMode {
fn from(raw_mode: u16) -> Self {
// example
Expand Down
69 changes: 69 additions & 0 deletions tests/assets/SPECS/rpm-rich-deps.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Name: rpm-rich-deps
Epoch: 1
Version: 2.3.4
Release: 5.el8
License: MPL-2.0
Summary: A package for testing rich dependencies

Group: Development/Tools
Url: http://bobloblaw.com
Packager: Michael Bluth
Vendor: Bluth Company
Vcs: https://github.com/rpm-rs/rpm

BuildArch: noarch
BuildRequires: file-devel

Requires: (fur <= 2 or arson >= 1.0.0-1)
Requires: staircar <= 99.1-3
Requires: /usr/bin/bash

Requires(pre): zstd
Requires(pre): glibc > 2.16
Requires(post): gzip

Provides: laughter = 33
Provides: narration(ronhoward)
Provides: /usr/bin/ls

Obsoletes: cornballer < 444
Obsoletes: bluemangroup < 32.1-0

Conflicts: foxnetwork > 5555

Recommends: yacht > 9:11.0-0
Recommends: GeneParmesan(PI)
Recommends: ((hiding and attic) if light-treason)

Suggests: (job or money > 9000)
Suggests: (dove and return)
Suggests: (bobloblaw >= 1.1 if maritimelaw else anyone < 0.5.1-2)

Supplements: comedy = 0:11.1-4
Supplements: ((hiding and illusion) unless alliance-of-magicians)

Enhances: (bananas or magic)

%description
This package tests rich dependencies.

%build
echo "Now the story of a wealthy man who lost everything, and the one son who had no choice but to keep them all together." > README
echo OK

%install

%clean

%files
%doc README

%changelog
* Mon Jun 14 2021 George Bluth <[email protected]> - 3.3.3-3
- There’s always money in the banana stand

* Sun Apr 25 2021 Job Bluth <[email protected]> - 2.2.2-2
- I've made a huge mistake

* Wed Mar 31 2021 Lucille Bluth <[email protected]> - 1.1.1-1
- It's a banana, Michael. How much could it cost, $10?
44 changes: 44 additions & 0 deletions tests/assets/SPECS/rpm-triggers-and-scriptlets.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Name: triggers
Version: 1.0
Release: %{rel}
Summary: Testing trigger behavior
Group: Testing
License: GPL
BuildArch: noarch

%description
%{summary}

%files
%defattr(-,root,root,-)

%triggerprein -- %{trigpkg}
echo %{name}-%{version}-%{release} TRIGGERPREIN $*

%triggerin -- %{trigpkg}
echo %{name}-%{version}-%{release} TRIGGERIN $*

%triggerun -- %{trigpkg}
echo %{name}-%{version}-%{release} TRIGGERUN $*

%triggerpostun -- %{trigpkg}
echo %{name}-%{version}-%{release} TRIGGERPOSTUN $*


%pre

%post

%preun

%postun

%pretrans

%posttrans

%preuntrans

%postuntrans

%verifyscript
2 changes: 1 addition & 1 deletion tests/assets/build_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rm -r ./BUILD/

# Add signatures
RSA_KEY_OPTS=( --define "_gpg_name rpm-signing-key-rsa4096" )
EDDSA_KEY_OPTS=( --define "_gpg_name rpm-signing-key-rsa4096" )
EDDSA_KEY_OPTS=( --define "_gpg_name rpm-signing-key-ed25519" )
IMA_SIGNING_OPTS=( --signfiles --fskpath signing_keys/ima_signing.pem --define "_file_signing_key_password i_am_a_ima_signing_password" )

BASIC_RPM="RPMS/noarch/rpm-basic-2.3.4-5.el9.noarch.rpm"
Expand Down
Loading

0 comments on commit bbe6d06

Please sign in to comment.