scripts/gen_image_generic.sh: make ext4 bootfs reproducible
[openwrt/staging/stintel.git] / scripts / target-metadata.pl
index 123958799fe3fc0ca34192f175bccd92622c96a9..e1d4ef242b865d8351ae3ad2d159a4e1eefded96 100755 (executable)
@@ -10,38 +10,44 @@ sub target_config_features(@) {
 
        while ($_ = shift @_) {
                /^arm_v(\w+)$/ and $ret .= "\tselect arm_v$1\n";
-               /^broken$/ and $ret .= "\tdepends on BROKEN\n";
                /^audio$/ and $ret .= "\tselect AUDIO_SUPPORT\n";
+               /^boot-part$/ and $ret .= "\tselect USES_BOOT_PART\n";
+               /^broken$/ and $ret .= "\tdepends on BROKEN\n";
+               /^cpiogz$/ and $ret .= "\tselect USES_CPIOGZ\n";
                /^display$/ and $ret .= "\tselect DISPLAY_SUPPORT\n";
                /^dt$/ and $ret .= "\tselect USES_DEVICETREE\n";
+               /^dt-overlay$/ and $ret .= "\tselect HAS_DT_OVERLAY_SUPPORT\n";
+               /^emmc$/ and $ret .= "\tselect EMMC_SUPPORT\n";
+               /^ext4$/ and $ret .= "\tselect USES_EXT4\n";
+               /^fpu$/ and $ret .= "\tselect HAS_FPU\n";
                /^gpio$/ and $ret .= "\tselect GPIO_SUPPORT\n";
+               /^jffs2$/ and $ret .= "\tselect USES_JFFS2\n";
+               /^jffs2_nand$/ and $ret .= "\tselect USES_JFFS2_NAND\n";
+               /^legacy-sdcard$/ and $ret .= "\tselect LEGACY_SDCARD_SUPPORT\n";
+               /^low_mem$/ and $ret .= "\tselect LOW_MEMORY_FOOTPRINT\n";
+               /^minor$/ and $ret .= "\tselect USES_MINOR\n";
+               /^mips16$/ and $ret .= "\tselect HAS_MIPS16\n";
+               /^nand$/ and $ret .= "\tselect NAND_SUPPORT\n";
+               /^nommu$/ and $ret .= "\tselect NOMMU\n";
                /^pci$/ and $ret .= "\tselect PCI_SUPPORT\n";
                /^pcie$/ and $ret .= "\tselect PCIE_SUPPORT\n";
-               /^usb$/ and $ret .= "\tselect USB_SUPPORT\n";
-               /^usbgadget$/ and $ret .= "\tselect USB_GADGET_SUPPORT\n";
                /^pcmcia$/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
+               /^powerpc64$/ and $ret .= "\tselect powerpc64\n";
+               /^pwm$/ and $ret .= "\select PWM_SUPPORT\n";
+               /^ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n";
+               /^rfkill$/ and $ret .= "\tselect RFKILL_SUPPORT\n";
+               /^rootfs-part$/ and $ret .= "\tselect USES_ROOTFS_PART\n";
                /^rtc$/ and $ret .= "\tselect RTC_SUPPORT\n";
+               /^separate_ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n\tselect USES_SEPARATE_INITRAMFS\n";
+               /^small_flash$/ and $ret .= "\tselect SMALL_FLASH\n";
+               /^spe_fpu$/ and $ret .= "\tselect HAS_SPE_FPU\n";
                /^squashfs$/ and $ret .= "\tselect USES_SQUASHFS\n";
-               /^jffs2$/ and $ret .= "\tselect USES_JFFS2\n";
-               /^jffs2_nand$/ and $ret .= "\tselect USES_JFFS2_NAND\n";
-               /^ext4$/ and $ret .= "\tselect USES_EXT4\n";
                /^targz$/ and $ret .= "\tselect USES_TARGZ\n";
-               /^cpiogz$/ and $ret .= "\tselect USES_CPIOGZ\n";
-               /^minor$/ and $ret .= "\tselect USES_MINOR\n";
+               /^testing-kernel$/ and $ret .= "\tselect HAS_TESTING_KERNEL\n";
                /^ubifs$/ and $ret .= "\tselect USES_UBIFS\n";
-               /^fpu$/ and $ret .= "\tselect HAS_FPU\n";
-               /^spe_fpu$/ and $ret .= "\tselect HAS_SPE_FPU\n";
-               /^ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n";
-               /^powerpc64$/ and $ret .= "\tselect powerpc64\n";
-               /^nommu$/ and $ret .= "\tselect NOMMU\n";
-               /^mips16$/ and $ret .= "\tselect HAS_MIPS16\n";
-               /^rfkill$/ and $ret .= "\tselect RFKILL_SUPPORT\n";
-               /^low_mem$/ and $ret .= "\tselect LOW_MEMORY_FOOTPRINT\n";
-               /^small_flash$/ and $ret .= "\tselect SMALL_FLASH\n";
-               /^nand$/ and $ret .= "\tselect NAND_SUPPORT\n";
+               /^usb$/ and $ret .= "\tselect USB_SUPPORT\n";
+               /^usbgadget$/ and $ret .= "\tselect USB_GADGET_SUPPORT\n";
                /^virtio$/ and $ret .= "\tselect VIRTIO_SUPPORT\n";
-               /^rootfs-part$/ and $ret .= "\tselect USES_ROOTFS_PART\n";
-               /^boot-part$/ and $ret .= "\tselect USES_BOOT_PART\n";
        }
        return $ret;
 }
@@ -83,11 +89,14 @@ sub print_target($) {
        }
 
        my $v = kver($target->{version});
+       my $tv = kver($target->{testing_version});
+       $tv or $tv = $v;
        if (@{$target->{subtargets}} == 0) {
        $confstr = <<EOF;
 config TARGET_$target->{conf}
        bool "$target->{name}"
-       select LINUX_$v
+       select LINUX_$v if !TESTING_KERNEL
+       select LINUX_$tv if TESTING_KERNEL
 EOF
        }
        else {
@@ -235,6 +244,7 @@ config TARGET_$target->{conf}_$profile->{id}
        bool "$profile->{name}"
        depends on TARGET_$target->{conf}
 EOF
+                       $profile->{broken} and print "\tdepends on BROKEN\n";
                        my @pkglist = merge_package_lists($target->{packages}, $profile->{packages});
                        foreach my $pkg (@pkglist) {
                                print "\tselect DEFAULT_$pkg\n";
@@ -292,8 +302,9 @@ EOF
 menuconfig TARGET_DEVICE_$target->{conf}_$profile->{id}
        bool "$profile->{name}"
        depends on TARGET_$target->{conf}
-       default y if TARGET_ALL_PROFILES
+       default $profile->{default}
 EOF
+                       $profile->{broken} and print "\tdepends on BROKEN\n";
                        my @pkglist = merge_package_lists($target->{packages}, $profile->{packages});
                        foreach my $pkg (@pkglist) {
                                print "\tselect DEFAULT_$pkg if !TARGET_PER_DEVICE_ROOTFS\n";
@@ -387,15 +398,18 @@ EOF
 
        my %kver;
        foreach my $target (@target) {
-               my $v = kver($target->{version});
-               next if $kver{$v};
-               $kver{$v} = 1;
-               print <<EOF;
+               foreach my $tv ($target->{version}, $target->{testing_version}) {
+                       next unless $tv;
+                       my $v = kver($tv);
+                       next if $kver{$v};
+                       $kver{$v} = 1;
+                       print <<EOF;
 
 config LINUX_$v
        bool
 
 EOF
+               }
        }
        foreach my $def (sort keys %defaults) {
                print <<EOF;
@@ -419,7 +433,8 @@ sub gen_profile_mk() {
        my @targets = parse_target_metadata($file);
        foreach my $cur (@targets) {
                next unless $cur->{id} eq $target;
-               print "PROFILE_NAMES = ".join(" ", map { $_->{id} } @{$cur->{profiles}})."\n";
+               my @profile_ids_unique =  do { my %seen; grep { !$seen{$_}++} map { $_->{id} } @{$cur->{profiles}}};
+               print "PROFILE_NAMES = ".join(" ", @profile_ids_unique)."\n";
                foreach my $profile (@{$cur->{profiles}}) {
                        print $profile->{id}.'_NAME:='.$profile->{name}."\n";
                        print $profile->{id}.'_HAS_IMAGE_METADATA:='.$profile->{has_image_metadata}."\n";